|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectie.omk.smpp.message.tlv.TLVTable
public class TLVTable
Table of optional parameters (TLVs).
TLV stands for Tag/Length/Value and was a capability added to SMPP version 3.4. It is an extensible means of adding new parameter types to SMPP packets. Each optional parameter has a 2-byte tag, which is a unique identifier of that parameter, a 2-byte length, which is an integer value representing the length of the value of the parameter and a value. The value may be of various types including integers, C Strings, octet strings, bit masks etc. The tag defines the type of the value.
This class holds a mapping of tags to values. Each SMPP packet holds a TLV table which holds that packet's set of current optional parameters. Upon serializing the packet to an output stream or byte array, the format of the serialized packet is:
+-------------------------+ | SMPP Packet | | +----------------------+| | | SMPP Header || | +----------------------+| | | || | | || | | Mandatory parameters || | | || | | || | +----------------------+| | | Optional parameters || | | +------------------+ || | | | Tag/Length/Value | || | | +------------------+ || | | | ... | || | | +------------------+ || | +----------------------+| +-------------------------+
Constructor Summary | |
---|---|
TLVTable()
Create a new, empty, TLVTable. |
Method Summary | |
---|---|
void |
clear()
Clear all optional parameters out of this table. |
Object |
get(int tag)
Get the value for a tag. |
Object |
get(Tag tag)
Get the value for a tag. |
int |
getLength()
Get the length the parameters in the table would encode as. |
boolean |
isSet(Tag tag)
Check if an optional parameter currently has a value set. |
void |
parseAllOpts()
Force the TLVTable to parse all the optional parameters from the internal byte array and place them in the map. |
void |
readFrom(byte[] b,
int offset,
int len)
Decode a full set of optional parameters from a byte array. |
Object |
set(Tag tag,
Object value)
Set a value for an optional parameter. |
Set |
tagSet()
Get the set of tags in this TLVTable. |
Collection |
values()
Get a Collection view of the set of values in this TLVTable. |
void |
writeTo(OutputStream out)
Encode all the optional parameters in this table to an output stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TLVTable()
Method Detail |
---|
public void readFrom(byte[] b, int offset, int len)
b
- The byte array to decode from.offset
- The first byte of the tag of the first optional parameter.len
- The length in the byte array of all the optional parameters.public void writeTo(OutputStream out) throws IOException
out
- The output stream to encode the parameters to.
IOException
- If an error occurs writing to the output stream.public Object get(Tag tag)
isSet(ie.omk.smpp.message.tlv.Tag)
.
tag
- The tag to get the value for.
tag
, or null if it is
not set.public Object get(int tag)
get(ie.omk.smpp.message.tlv.Tag)
public boolean isSet(Tag tag)
tag
- The tag of the parameter to check is set.
public Object set(Tag tag, Object value) throws BadValueTypeException, InvalidSizeForValueException
tag
- The tag of the parameter to set.value
- The value of the parameter to set.
BadValueTypeException
- if an attempt is made to set a value using a Java type that
is not allowed for that parameter type.
InvalidSizeForValueException
- if the value's encoded length is outside the bounds allowed
for that parameter.public void clear()
public final void parseAllOpts()
get(ie.omk.smpp.message.tlv.Tag)
. Calling this
method causes all the parameters to be parsed and placed in the internal
map and the byte array containing the parameter's bytes to be released
for garbage collection.
It is not normally needed for an application to call this method.
TLVTable
uses it internally when necessary to ensure there
is no loss of synchronization between the internal map and the byte
array.
public int getLength()
sizeof (smpp_header) + sizeof (mandatory_parameters)
+ sizeof (optional_parameters).
public Set tagSet()
public Collection values()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |