ie.omk.smpp.message.tlv
Class NullEncoder

java.lang.Object
  extended by ie.omk.smpp.message.tlv.NullEncoder
All Implemented Interfaces:
Encoder

public class NullEncoder
extends Object
implements Encoder

"No value" encoder. This encoder type was necessary as there are some optional parameters that have no value. Therefore, it was possible for the tag/value map in TLVTable to have null values in it. As null is also returned from a map when there is no value for a particular key, some way was needed to distinguish between a parameter not set and a parameter having a null value. Hence the encoder.

Version:
$Id: NullEncoder.java 244 2006-01-22 21:56:28Z orank $
Author:
Oran Kelly

Constructor Summary
NullEncoder()
          Create a new NullEncoder.
 
Method Summary
 int getValueLength(Tag tag, Object value)
          Calculate the length, in bytes, that the value will encode as.
 Object readFrom(Tag tag, byte[] b, int offset, int length)
          Decode a value from a byte array.
 void writeTo(Tag tag, Object value, byte[] b, int offset)
          Encode a value to a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NullEncoder

public NullEncoder()
Create a new NullEncoder.

Method Detail

writeTo

public void writeTo(Tag tag,
                    Object value,
                    byte[] b,
                    int offset)
Description copied from interface: Encoder
Encode a value to a byte array.

Specified by:
writeTo in interface Encoder
Parameters:
tag - The tag of the value to encode.
value - The value to encode.
b - The byte array to encode the value to.
offset - The offset within b to begin encoding from.

readFrom

public Object readFrom(Tag tag,
                       byte[] b,
                       int offset,
                       int length)
Description copied from interface: Encoder
Decode a value from a byte array.

Specified by:
readFrom in interface Encoder
Parameters:
tag - The tag of the value to decode.
b - The byte array to decode the value from.
offset - The offset in b to begin decoding from.
length - The length of the value to decode.
Returns:
The value object.

getValueLength

public int getValueLength(Tag tag,
                          Object value)
Description copied from interface: Encoder
Calculate the length, in bytes, that the value will encode as. The value returned from this method must exactly match the number of bytes that writeTo will attempt to encode to a byte array.

Specified by:
getValueLength in interface Encoder
Parameters:
tag - The tag of the value to get the length for.
value - The value to get the length for.
Returns:
The length value will encode to in bytes.


Copyright © 2011 smppapi at Sourceforge. All Rights Reserved.