Class Protocol

  • All Implemented Interfaces:
    IProtocol

    public class Protocol
    extends java.lang.Object
    implements IProtocol
    Class which represents the protocol used as Sec-WebSocket-Protocol
    Since:
    1.3.7
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.regex.Pattern patternComma  
      private static java.util.regex.Pattern patternSpace  
      private java.lang.String providedProtocol
      Attribute for the provided protocol
    • Constructor Summary

      Constructors 
      Constructor Description
      Protocol​(java.lang.String providedProtocol)
      Constructor for a Sec-Websocket-Protocol
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean acceptProvidedProtocol​(java.lang.String inputProtocolHeader)
      Check if the received Sec-WebSocket-Protocol header field contains a offer for the specific protocol
      IProtocol copyInstance()
      To prevent protocols to be used more than once the Websocket implementation should call this method in order to create a new usable version of a given protocol instance.
      boolean equals​(java.lang.Object o)  
      java.lang.String getProvidedProtocol()
      Return the specific Sec-WebSocket-protocol header offer for this protocol if the endpoint.
      int hashCode()  
      java.lang.String toString()
      Return a string which should contain the protocol name as well as additional information about the current configurations for this protocol (DEBUG purposes)
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • patternSpace

        private static final java.util.regex.Pattern patternSpace
      • patternComma

        private static final java.util.regex.Pattern patternComma
      • providedProtocol

        private final java.lang.String providedProtocol
        Attribute for the provided protocol
    • Constructor Detail

      • Protocol

        public Protocol​(java.lang.String providedProtocol)
        Constructor for a Sec-Websocket-Protocol
        Parameters:
        providedProtocol - the protocol string
    • Method Detail

      • acceptProvidedProtocol

        public boolean acceptProvidedProtocol​(java.lang.String inputProtocolHeader)
        Description copied from interface: IProtocol
        Check if the received Sec-WebSocket-Protocol header field contains a offer for the specific protocol
        Specified by:
        acceptProvidedProtocol in interface IProtocol
        Parameters:
        inputProtocolHeader - the received Sec-WebSocket-Protocol header field offered by the other endpoint
        Returns:
        true, if the offer does fit to this specific protocol
      • getProvidedProtocol

        public java.lang.String getProvidedProtocol()
        Description copied from interface: IProtocol
        Return the specific Sec-WebSocket-protocol header offer for this protocol if the endpoint. If the extension returns an empty string (""), the offer will not be included in the handshake.
        Specified by:
        getProvidedProtocol in interface IProtocol
        Returns:
        the specific Sec-WebSocket-Protocol header for this protocol
      • copyInstance

        public IProtocol copyInstance()
        Description copied from interface: IProtocol
        To prevent protocols to be used more than once the Websocket implementation should call this method in order to create a new usable version of a given protocol instance.
        Specified by:
        copyInstance in interface IProtocol
        Returns:
        a copy of the protocol
      • toString

        public java.lang.String toString()
        Description copied from interface: IProtocol
        Return a string which should contain the protocol name as well as additional information about the current configurations for this protocol (DEBUG purposes)
        Specified by:
        toString in interface IProtocol
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string containing the protocol name as well as additional information
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object