org.mobicents.protocols.smpp.message.tlv
Interface TLVTable

All Superinterfaces:
Map<Tag,Object>
All Known Implementing Classes:
TLVTableImpl

public interface TLVTable
extends Map<Tag,Object>

Map of tag/length/value (TLV) parameters.

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.

TLVs were originally called "optional parameters". SMPP v5 altered this since it introduced the concept of required TLV parameters.

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 | ||
    | | +------------------+ ||
    | | |     ...          | ||
    | | +------------------+ ||
    | +----------------------+|
    +-------------------------+
  
 

Version:
$Id: TLVTable.java 457 2009-01-15 17:37:42Z orank $

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Method Summary
 Object get(int tag)
          Get the value for a tag.
 BitSet getBitmask(Tag tag)
          Get the tag's value as a bit set.
 byte[] getBytes(Tag tag)
          Get the tag's value as a byte array.
 int getInt(Tag tag)
          Get the tag's value as an int.
 int getLength()
          Get the length the parameters in the table would encode as.
 long getLong(Tag tag)
          Get the tag's value as a long.
 String getString(Tag tag)
          Get the tag's value as a string.
 Object put(Tag tag, char value)
           
 Object put(Tag tag, int value)
           
 Object put(Tag tag, long value)
           
 Object put(Tag tag, short value)
           
 void readFrom(PacketDecoder decoder, int length)
           
 void remove(int tag)
          Remove (or un-set) a tag/value from this table.
 void writeTo(PacketEncoder encoder)
           
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Method Detail

readFrom

void readFrom(PacketDecoder decoder,
              int length)

writeTo

void writeTo(PacketEncoder encoder)
             throws IOException
Throws:
IOException

get

Object get(int tag)
Get the value for a tag. This is a convenience method to convert the tag integer to its appropriate Tag object and then look that tag up in the map.

Parameters:
tag - The tag's integer value.

getString

String getString(Tag tag)
Get the tag's value as a string.

Parameters:
tag - The tag to retrieve the value for.
Returns:
The value as a string, or null if the specified tag is not set in this table.

getInt

int getInt(Tag tag)
Get the tag's value as an int.

Parameters:
tag - The tag to retrieve the value for.
Returns:
The value as an integer, or -1 if the specified tag is not set in this table.
Throws:
ClassCastException - If the value for the specified tag is not a number (castable as a java.lang.Number).

getLong

long getLong(Tag tag)
Get the tag's value as a long.

Parameters:
tag - The tag to retrieve the value for.
Returns:
The value as a long, or -1 if the specified tag is not set in this table.
Throws:
ClassCastException - If the value for the specified tag is not a number (castable as a java.lang.Number).

getBitmask

BitSet getBitmask(Tag tag)
Get the tag's value as a bit set.

Parameters:
tag - The tag to retrieve the value for.
Returns:
The value, cast as a java.util.BitSet, or null if the specified tag is not set in this table.
Throws:
ClassCastException - If the value for the specified tag is not a bit mask.

getBytes

byte[] getBytes(Tag tag)
Get the tag's value as a byte array.

Parameters:
tag - The tag to retrieve the value for.
Returns:
The value, cast as a byte[], or null if the specified tag is not set in this table.
Throws:
ClassCastException - If the value for the specified tag is not a byte array.

put

Object put(Tag tag,
           char value)

put

Object put(Tag tag,
           short value)

put

Object put(Tag tag,
           int value)

put

Object put(Tag tag,
           long value)

remove

void remove(int tag)
Remove (or un-set) a tag/value from this table.

Parameters:
tag - The tag to remove from the table.

getLength

int getLength()
Get the length the parameters in the table would encode as. The length of an SMPP packet is determined by:
sizeof (smpp_header) + sizeof (mandatory_parameters) + sizeof (optional_parameters).
The value returned for this method is the last clause in this equation.

Returns:
The full length that the optional parameters would encode as.


Copyright © 2011 Mobicents. All Rights Reserved.