org.xlattice.protocol
Class TLV
java.lang.Object
org.xlattice.protocol.TLV
- Direct Known Subclasses:
- TLV16
public abstract class TLV
- extends java.lang.Object
Represents the classic Type-Length-Value field found in many
network protocols.
This is an experiment; the implementation may change drastically
at a later date.
- Author:
- Jim Dixon
Constructor Summary |
protected |
TLV(int fieldSize,
int type,
byte[] value)
|
protected |
TLV(int fieldSize,
int type,
int length,
byte[] value)
|
Method Summary |
protected static TLV |
decode(int fieldSize,
byte[] message,
int offset)
|
int |
encode(byte[] message,
int offset)
Write this TLV onto the message buffer at the offset indicated. |
int |
length()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
fieldSize
public final int fieldSize
type
public final int type
value
public final byte[] value
TLV
protected TLV(int fieldSize,
int type,
int length,
byte[] value)
TLV
protected TLV(int fieldSize,
int type,
byte[] value)
length
public int length()
decode
protected static TLV decode(int fieldSize,
byte[] message,
int offset)
throws java.io.IOException
- Throws:
java.io.IOException
encode
public int encode(byte[] message,
int offset)
- Write this TLV onto the message buffer at the offset indicated.
XXX Assumes value.length == length
- Parameters:
message
- buffer to write TLV onoffset
- byte offset where we start writing
- Returns:
- offset after writing the values
- Throws:
IndexOutOfBoundsException,
- NullPointerException