org.mobicents.protocols.smpp.message.param
Class BitmaskParamDescriptor

java.lang.Object
  extended by org.mobicents.protocols.smpp.message.param.AbstractDescriptor
      extended by org.mobicents.protocols.smpp.message.param.BitmaskParamDescriptor
All Implemented Interfaces:
Serializable, ParamDescriptor

public class BitmaskParamDescriptor
extends AbstractDescriptor

Encode and decode bit masks. While this descriptor type supports bit masks that are longer than a single octet, the SMPP specification does not define how a multi-byte bit mask should be encoded on the wire. Since the rest of SMPP is big-endian, this implementation assumes big-endian for bit masks too.

Version:
$Id: BitmaskParamDescriptor.java 457 2009-01-15 17:37:42Z orank $
See Also:
Serialized Form

Constructor Summary
BitmaskParamDescriptor()
           
 
Method Summary
 int getLengthSpecifier()
          Get the index of another numerical mandatory parameter which specifies the length of the parameter this descriptor represents.
 Object readObject(PacketDecoder decoder, int length)
          Read an object from a byte array.
 int sizeOf(Object obj)
          Get the encoded byte-size of obj.
 void writeObject(Object obj, PacketEncoder encoder)
          Write the specified object to an output stream.
 
Methods inherited from class org.mobicents.protocols.smpp.message.param.AbstractDescriptor
equals, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitmaskParamDescriptor

public BitmaskParamDescriptor()
Method Detail

getLengthSpecifier

public int getLengthSpecifier()
Description copied from interface: ParamDescriptor
Get the index of another numerical mandatory parameter which specifies the length of the parameter this descriptor represents. For example, in a submit_sm packet, the length of the short_message parameter is specified by the sm_length parameter, a 1-byte integer immediately preceding short_message in the mandatory parameter section of the packet. Therefore, the parameter descriptor that will be used to decode the short_message would return the index of the sm_length parameter in the body. This specified length can then be used to decode the correct number of bytes for the short message.

As another example, take the submit_multi packet. It has a mandatory parameter called dest_address(es) which specify all the destinations the message should be submitted to. The number of destinations in the destination table is specified by the number_of_dests mandatory parameter. In this case, the descriptor used to read the dest_addresses would return the index of number_of_dests from this method.

Returns:
The index in the mandatory parameters of where to find the length specifier for this descriptor. If this descriptor does not need or support a length specifier, -1 must be returned.

sizeOf

public int sizeOf(Object obj)
Description copied from interface: ParamDescriptor
Get the encoded byte-size of obj.

Parameters:
obj - The object to calculate the encoded size for.
Returns:
The number of bytes the specified object would be encoded to via the #writeObject(Object, OutputStream) method.

writeObject

public void writeObject(Object obj,
                        PacketEncoder encoder)
                 throws IOException
Description copied from interface: ParamDescriptor
Write the specified object to an output stream.

Parameters:
obj - The object to encode.
Throws:
IOException - If there was an error writing to the stream.

readObject

public Object readObject(PacketDecoder decoder,
                         int length)
Description copied from interface: ParamDescriptor
Read an object from a byte array.

length - The number of bytes to use in reading the object. If the length is unknown and intrinsic to the type being decoded (such as a C-String, which is terminated by a nul-byte), then -1 may be supplied.
Returns:
The decoded object.


Copyright © 2011 Mobicents. All Rights Reserved.