net.clackrouter.protocol.commands
Class VNSProtocolCommand

java.lang.Object
  extended by net.clackrouter.protocol.commands.VNSProtocolCommand
Direct Known Subclasses:
VNSAuthReplyProtocolCommand, VNSAuthRequestProtocolCommand, VNSAuthStatusProtocolCommand, VNSBannerProtocolCommand, VNSCloseProtocolCommand, VNSHWInfoProtocolCommand, VNSOpenProtocolCommand, VNSPacketProtocolCommand

public abstract class VNSProtocolCommand
extends java.lang.Object


Field Summary
static int LENGTH_LEN
           
protected  int m_type
           
static int TYPE_AUTHREPLY
           
static int TYPE_AUTHREQUEST
           
static int TYPE_AUTHSTATUS
           
static int TYPE_BANNER
           
static int TYPE_CLOSE
           
static int TYPE_HWINFO
           
static int TYPE_INVALID
           
static int TYPE_LEN
           
static int TYPE_OPEN
           
static int TYPE_OPENTEMPLATE
           
static int TYPE_PACKET
           
static int TYPE_RTABLE
           
 
Constructor Summary
protected VNSProtocolCommand(java.nio.ByteBuffer commandBuffer)
          Constructor for receiving the command.
protected VNSProtocolCommand(int type)
          Constructor for sending the command.
 
Method Summary
protected  void constructByteBuffer()
          Contruct the bytes that will be ready to be sent to the server by prepending the length and the type.
protected  void constructByteBuffer(java.nio.ByteBuffer commandBuffer)
          Contruct the bytes that will be ready to be sent to the server by prepending length and type to the data passed in from the subclass.
protected  java.nio.ByteBuffer extractByteBuffer()
          Extract the bytes that are relevant to the subclass.
 java.nio.ByteBuffer getByteBuffer()
          Get all the bytes of this command.
 VNSData getData()
           
 int getLength()
          Return the length of the command, in bytes, which is the length of the bytes sent by the subclass plus "length length" plus "type length".
 int getType()
          Return the type of the command.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LENGTH_LEN

public static final int LENGTH_LEN
See Also:
Constant Field Values

TYPE_LEN

public static final int TYPE_LEN
See Also:
Constant Field Values

TYPE_INVALID

public static final int TYPE_INVALID
See Also:
Constant Field Values

TYPE_OPEN

public static final int TYPE_OPEN
See Also:
Constant Field Values

TYPE_CLOSE

public static final int TYPE_CLOSE
See Also:
Constant Field Values

TYPE_PACKET

public static final int TYPE_PACKET
See Also:
Constant Field Values

TYPE_BANNER

public static final int TYPE_BANNER
See Also:
Constant Field Values

TYPE_HWINFO

public static final int TYPE_HWINFO
See Also:
Constant Field Values

TYPE_RTABLE

public static final int TYPE_RTABLE
See Also:
Constant Field Values

TYPE_OPENTEMPLATE

public static final int TYPE_OPENTEMPLATE
See Also:
Constant Field Values

TYPE_AUTHREQUEST

public static final int TYPE_AUTHREQUEST
See Also:
Constant Field Values

TYPE_AUTHREPLY

public static final int TYPE_AUTHREPLY
See Also:
Constant Field Values

TYPE_AUTHSTATUS

public static final int TYPE_AUTHSTATUS
See Also:
Constant Field Values

m_type

protected int m_type
Constructor Detail

VNSProtocolCommand

protected VNSProtocolCommand(int type)
Constructor for sending the command. A subsequent call to contructBytes is necessary to build a valid command in preparation for sending it to the server.


VNSProtocolCommand

protected VNSProtocolCommand(java.nio.ByteBuffer commandBuffer)
Constructor for receiving the command. A subsequent call to extractByteBuffer is necessary to allow the subclass to extract the specific information contained in the command.

Method Detail

constructByteBuffer

protected final void constructByteBuffer(java.nio.ByteBuffer commandBuffer)
Contruct the bytes that will be ready to be sent to the server by prepending length and type to the data passed in from the subclass.


constructByteBuffer

protected final void constructByteBuffer()
Contruct the bytes that will be ready to be sent to the server by prepending the length and the type. This methods should be called by a subclass that has no payload to send the the server.


extractByteBuffer

protected final java.nio.ByteBuffer extractByteBuffer()
Extract the bytes that are relevant to the subclass. This means that the returned byte buffer will not contain the length and type information.


getType

public int getType()
Return the type of the command.

See Also:
TYPE_OPEN, TYPE_CLOSE, TYPE_PACKET, TYPE_BANNER, TYPE_HWINFO

getLength

public int getLength()
Return the length of the command, in bytes, which is the length of the bytes sent by the subclass plus "length length" plus "type length".


getByteBuffer

public java.nio.ByteBuffer getByteBuffer()
Get all the bytes of this command. The returned bytes are ready to be transmitted to the server.


getData

public VNSData getData()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object