org.jnetstream.protocol
Interface ProtocolInfo.ID

All Superinterfaces:
FilterTarget, ProtocolFilterTarget
Enclosing interface:
ProtocolInfo<T extends Header>

public static interface ProtocolInfo.ID
extends ProtocolFilterTarget

Defines a unique identification of a protocol. There are 2 forms of identification possible. The first is a unique string. The protocol name should include company or organization or suite name in a form of a java package and class naming conventions.

For example protocols.lan.Ethernet describes uniquely Ethernet 2 protocol. com.slytechs.protocols.jnetstream.server uniqueuely identifies the custom protocol utilized by the jNetStream's RemoteServer communication. The string does not signify that there exists such a real package or class. It is simply means of unqiuely assigning, non conflicting names that carry the organization which is responsible for the protocol.

The integer based ID is generated based on the above metioned unique string based id. If the string ID changes the numerical ID will change as well. The integer ID is a complex hash of the string, not the hash function provided by java's implementation of hash on string, but a more refined function that guarrantees uniqueness for each different string and also guarrantees that the id will always be the same for the same string on any platform.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Method Summary
 int bitIndex()
          Returns a special bit index for core protocols.
 java.lang.String getIdString()
          A java style ID as a string that uniquely identifies the protocol
 java.lang.String getName()
           
<T extends Header>
ProtocolInfo<T>
getProtocol()
           
 java.lang.Class<? extends Header> getType()
          Returns the type, as an instance of a class type, which is also a unique type for this protocol.
 int hashValue()
          Overrides and implements a more efficient and stringent hash value.
 

Method Detail

getIdString

java.lang.String getIdString()
A java style ID as a string that uniquely identifies the protocol

Returns:
id string

hashValue

int hashValue()
Overrides and implements a more efficient and stringent hash value. The hash value is guarranteed never to match a hash of another ID on the same java VM. For example, the implementations may (or may not) use static tables to store all of the registered IDs and use indexes into the tables as hash values. The hash value is not persinstant between different invocations of a java VM. It is used only as a fast runtime property of a protocol that can be used for comparison between protocols.

Returns:
a unique hash value guarranteed to be unique on this java VM

getProtocol

<T extends Header> ProtocolInfo<T> getProtocol()

getName

java.lang.String getName()
Returns:

getType

java.lang.Class<? extends Header> getType()
Returns the type, as an instance of a class type, which is also a unique type for this protocol.

Returns:
class file of this protocol

bitIndex

int bitIndex()
Returns a special bit index for core protocols. Bit indexes are used to significantly speedup the process of caching certain protocol information within a packet. Only the core protocols can provide a bit index. All other non-core protocols must return value of 0.

Returns:
bit index if this is a core protocol, otherwise 0