org.walluck.oscar
Class TLV

java.lang.Object
  extended byorg.walluck.oscar.TLV

public class TLV
extends java.lang.Object

TLV - Type Length Value.

It is a tuple allowing typed opaque information to be passed through the OSCAR protocol. Typically, TLV's are intended for interpretation at the core layer. Since they are typed, new TLV elements can be added to the protocol without modifying the lower layers.

Since:
1.0
Version:
1.0
Author:
David Walluck
See Also:
TLVType

Constructor Summary
TLV()
          Creates a new (empty) TLV.
TLV(int type, int length, byte[] value)
          Creates a new TLV.
 
Method Summary
 int getLength()
          Get the value of length.
 int getType()
          Get the value of type.
 byte[] getValue()
          Get the value of value.
 byte getValueByte()
          Get the value of this TLV as a byte.
 int getValueInt()
          Get the value of this TLV as an integer.
 short getValueShort()
          Get the value of this TLV as a short.
 java.lang.String getValueString()
          Get the value of this TLV as a string.
 java.lang.String getValueString(java.lang.String enc)
          Get the value of this TLV as a string with the given encoding.
 void setLength(int length)
          Set the value of length.
 void setType(int type)
          Set the value of type.
 void setValue(byte[] value)
          Set the value of value.
 void setValueByte(int value)
          Set the value of this TLV as a byte
 void setValueInt(int value)
          Set the value of this TLV as an integer
 void setValueShort(int value)
          Set the value of this TLV as a short.
 void setValueString(java.lang.String value)
          Set the value of this TLV as a string
 java.lang.String toString()
          Return a string representation of this TLV.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TLV

public TLV()
Creates a new (empty) TLV.


TLV

public TLV(int type,
           int length,
           byte[] value)
    throws java.io.IOException
Creates a new TLV.

Parameters:
type - the type of TLV
length - the length of the TLV
value - the value of the TLV
Throws:
java.io.IOException - if an error occurs
Method Detail

getType

public int getType()
Get the value of type.

Returns:
value of type.

setType

public void setType(int type)
Set the value of type.

Parameters:
type - Value to assign to type.

getLength

public int getLength()
Get the value of length.

Returns:
value of length.

setLength

public void setLength(int length)
Set the value of length.

Parameters:
length - Value to assign to length.

getValue

public byte[] getValue()
Get the value of value.

Returns:
value of value.

setValue

public void setValue(byte[] value)
Set the value of value.

Parameters:
value - Value to assign to value.

getValueString

public java.lang.String getValueString(java.lang.String enc)
                                throws java.io.UnsupportedEncodingException
Get the value of this TLV as a string with the given encoding.

Parameters:
enc - the AOL encoding string
Returns:
the value of the TLV as a string
Throws:
java.io.UnsupportedEncodingException - if an error occurs

getValueString

public java.lang.String getValueString()
                                throws java.io.UnsupportedEncodingException
Get the value of this TLV as a string.

Returns:
the value of the TLV as a string
Throws:
java.io.UnsupportedEncodingException - if an error occurs

setValueString

public void setValueString(java.lang.String value)
                    throws java.io.IOException
Set the value of this TLV as a string

Parameters:
value - the string to assign to this TLV
Throws:
java.io.IOException - if an error occurs

getValueByte

public byte getValueByte()
                  throws java.io.IOException
Get the value of this TLV as a byte.

Returns:
the value of this tlv as a byte
Throws:
java.io.IOException - if an error occurs

setValueByte

public void setValueByte(int value)
                  throws java.io.IOException
Set the value of this TLV as a byte

Parameters:
value - the byte to assign to this TLV
Throws:
java.io.IOException - if an error occurs

getValueShort

public short getValueShort()
                    throws java.io.IOException
Get the value of this TLV as a short.

Returns:
the value of this TLV as a short
Throws:
java.io.IOException - if an error occurs

setValueShort

public void setValueShort(int value)
                   throws java.io.IOException
Set the value of this TLV as a short.

Parameters:
value - the short to assign to this TLV
Throws:
java.io.IOException - if an error occurs

getValueInt

public int getValueInt()
                throws java.io.IOException
Get the value of this TLV as an integer.

Returns:
the value of this TLV as an integer
Throws:
java.io.IOException - if an error occurs

setValueInt

public void setValueInt(int value)
                 throws java.io.IOException
Set the value of this TLV as an integer

Parameters:
value - the integer to assign to this TLV
Throws:
java.io.IOException - if an error occurs

toString

public java.lang.String toString()
Return a string representation of this TLV.

Returns:
the string representation of this TLV