net.spy.memcached.tapmessage
Class BaseMessage

java.lang.Object
  extended by net.spy.memcached.compat.SpyObject
      extended by net.spy.memcached.tapmessage.BaseMessage
Direct Known Subclasses:
RequestMessage, ResponseMessage

public class BaseMessage
extends SpyObject

The HeaderMessage implements the header of a tap message. This class cannot be instantiated. Tap stream messages are created with the RequestMessage and ResponseMessage classes. Users who want to take advantage of customizing their own tap messages should use the CustomTapStream class since it provides flexibility to create all valid tap messages.


Field Summary
static int CAS_FIELD_LENGTH
          The length of the cas field in the tap header.
static int CAS_INDEX
          The index of the cas field in the tap header.
static int DATA_TYPE_FIELD_LENGTH
          The length of the data type field in a tap header.
static int DATA_TYPE_INDEX
          The index of the data type field in the tap header.
static int EXTRA_LENGTH_FIELD_LENGTH
          The length of the extra length field in a tap header.
static int EXTRA_LENGTH_INDEX
          The index of the extra length field in the tap header.
static int HEADER_LENGTH
          The header length
static int KEY_LENGTH_FIELD_LENGTH
          The length of the key length field in a tap header.
static int KEY_LENGTH_INDEX
          The index of the key length field in a tap header.
static int MAGIC_FIELD_LENGTH
          The length of the magic field in a tap header.
static int MAGIC_INDEX
          The index of the magic field in a tap header.
protected  byte[] mbytes
          Holds the binary data for the header field.
static int OPAQUE_FIELD_LENGTH
          The length of the opaque field in the tap header.
static int OPAQUE_INDEX
          The index of the opaque field in the tap header.
static int OPCODE_FIELD_LENGTH
          The length of the opcode field in a tap header.
static int OPCODE_INDEX
          The index of the opcode field in a tap header.
static int TOTAL_BODY_FIELD_LENGTH
          The length of the total body field in the tap header.
static int TOTAL_BODY_INDEX
          The index of the total body field in the tap header.
static int VBUCKET_FIELD_LENGTH
          The length of the vbucket field in a tap header.
static int VBUCKET_INDEX
          The index of the vbucket field in the tap header.
 
Constructor Summary
protected BaseMessage()
          Instantiates a tap header.
 
Method Summary
 ByteBuffer getBytes()
          Creates a ByteBuffer representation of the message.
 long getCas()
          Gets the value of the tap messages cas field.
 byte getDatatype()
          Gets the value of the tap messages data type field.
 int getExtralength()
          Gets the value of the tap messages extra length field.
 int getKeylength()
          Gets the value of the tap messages key length field.
 int getMagic()
          Gets the value of the tap messages magic field.
 int getMessageLength()
          Gets the length of the entire message.
 int getOpaque()
          Gets the value of the tap messages opaque field.
 TapOpcode getOpcode()
          Gets the value of the tap messages opaque field.
 int getTotalbody()
          Gets the value of the tap messages total body field.
 int getVbucket()
          Gets the value of the tap messages vbucket field.
 void setCas(long cas)
          Sets the value of the tap messages cas field.
 void setDatatype(byte b)
          Sets the value of the tap messages data type field.
 void setExtralength(int i)
          Sets the value of the tap messages extra length field.
protected  void setKeylength(long l)
          Sets the key length for this message.
 void setMagic(TapMagic m)
          Sets the value of the tap messages magic field.
 void setOpaque(int op)
          Sets the value of the tap messages opaque field.
 void setOpcode(TapOpcode o)
          Sets the value of the tap messages opcode field
 void setTotalbody(long l)
          Sets the value of the tap messages total body field.
 void setVbucket(int vb)
          Sets the value of the tap messages vbucket field.
 
Methods inherited from class net.spy.memcached.compat.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAGIC_INDEX

public static final int MAGIC_INDEX
The index of the magic field in a tap header.

See Also:
Constant Field Values

MAGIC_FIELD_LENGTH

public static final int MAGIC_FIELD_LENGTH
The length of the magic field in a tap header.

See Also:
Constant Field Values

OPCODE_INDEX

public static final int OPCODE_INDEX
The index of the opcode field in a tap header.

See Also:
Constant Field Values

OPCODE_FIELD_LENGTH

public static final int OPCODE_FIELD_LENGTH
The length of the opcode field in a tap header.

See Also:
Constant Field Values

KEY_LENGTH_INDEX

public static final int KEY_LENGTH_INDEX
The index of the key length field in a tap header.

See Also:
Constant Field Values

KEY_LENGTH_FIELD_LENGTH

public static final int KEY_LENGTH_FIELD_LENGTH
The length of the key length field in a tap header.

See Also:
Constant Field Values

EXTRA_LENGTH_INDEX

public static final int EXTRA_LENGTH_INDEX
The index of the extra length field in the tap header.

See Also:
Constant Field Values

EXTRA_LENGTH_FIELD_LENGTH

public static final int EXTRA_LENGTH_FIELD_LENGTH
The length of the extra length field in a tap header.

See Also:
Constant Field Values

DATA_TYPE_INDEX

public static final int DATA_TYPE_INDEX
The index of the data type field in the tap header.

See Also:
Constant Field Values

DATA_TYPE_FIELD_LENGTH

public static final int DATA_TYPE_FIELD_LENGTH
The length of the data type field in a tap header.

See Also:
Constant Field Values

VBUCKET_INDEX

public static final int VBUCKET_INDEX
The index of the vbucket field in the tap header.

See Also:
Constant Field Values

VBUCKET_FIELD_LENGTH

public static final int VBUCKET_FIELD_LENGTH
The length of the vbucket field in a tap header.

See Also:
Constant Field Values

TOTAL_BODY_INDEX

public static final int TOTAL_BODY_INDEX
The index of the total body field in the tap header.

See Also:
Constant Field Values

TOTAL_BODY_FIELD_LENGTH

public static final int TOTAL_BODY_FIELD_LENGTH
The length of the total body field in the tap header.

See Also:
Constant Field Values

OPAQUE_INDEX

public static final int OPAQUE_INDEX
The index of the opaque field in the tap header.

See Also:
Constant Field Values

OPAQUE_FIELD_LENGTH

public static final int OPAQUE_FIELD_LENGTH
The length of the opaque field in the tap header.

See Also:
Constant Field Values

CAS_INDEX

public static final int CAS_INDEX
The index of the cas field in the tap header.

See Also:
Constant Field Values

CAS_FIELD_LENGTH

public static final int CAS_FIELD_LENGTH
The length of the cas field in the tap header.

See Also:
Constant Field Values

HEADER_LENGTH

public static final int HEADER_LENGTH
The header length

See Also:
Constant Field Values

mbytes

protected byte[] mbytes
Holds the binary data for the header field.

Constructor Detail

BaseMessage

protected BaseMessage()
Instantiates a tap header.

Method Detail

setMagic

public final void setMagic(TapMagic m)
Sets the value of the tap messages magic field.

Parameters:
m - The new value for the magic field.

getMagic

public final int getMagic()
Gets the value of the tap messages magic field.

Returns:
The value of the magic field.

setOpcode

public final void setOpcode(TapOpcode o)
Sets the value of the tap messages opcode field

Parameters:
o - The new value of the opcode field.

getOpcode

public final TapOpcode getOpcode()
Gets the value of the tap messages opaque field.

Returns:
The value of the opaque field.

setKeylength

protected final void setKeylength(long l)
Sets the key length for this message. This function should never be called by the user since changes to fields that affect key length call this function automatically.

Parameters:
l - The new value for the key length field.

getKeylength

public final int getKeylength()
Gets the value of the tap messages key length field.

Returns:
The value of the key length field.

setDatatype

public final void setDatatype(byte b)
Sets the value of the tap messages data type field.

Parameters:
b - The new value for the data type field.

getDatatype

public final byte getDatatype()
Gets the value of the tap messages data type field.

Returns:
The value of the data type field.

setExtralength

public final void setExtralength(int i)
Sets the value of the tap messages extra length field.

Parameters:
i - The new value for the extra length field.

getExtralength

public final int getExtralength()
Gets the value of the tap messages extra length field.

Returns:
The value of the extra length field.

setVbucket

public final void setVbucket(int vb)
Sets the value of the tap messages vbucket field.

Parameters:
vb - The new value for the vbucket field.

getVbucket

public final int getVbucket()
Gets the value of the tap messages vbucket field.

Returns:
The value of the vbucket field.

setTotalbody

public final void setTotalbody(long l)
Sets the value of the tap messages total body field.

Parameters:
l - The new value for the total body field.

getTotalbody

public final int getTotalbody()
Gets the value of the tap messages total body field.

Returns:
The value of the total body field.

setOpaque

public final void setOpaque(int op)
Sets the value of the tap messages opaque field.

Parameters:
op - The new value for the opaque field.

getOpaque

public final int getOpaque()
Gets the value of the tap messages opaque field.

Returns:
The value of the opaque field.

setCas

public final void setCas(long cas)
Sets the value of the tap messages cas field.

Parameters:
cas - The new value for the cas field.

getCas

public final long getCas()
Gets the value of the tap messages cas field.

Returns:
The value of the cas field.

getMessageLength

public final int getMessageLength()
Gets the length of the entire message.

Returns:
The length of the message.

getBytes

public final ByteBuffer getBytes()
Creates a ByteBuffer representation of the message.

Returns:
The ByteBuffer representation of the message.