ie.omk.smpp.message.tlv
Class StringEncoder

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

public class StringEncoder
extends Object
implements Encoder

Value encoder for string types. Operates on the java.lang.String type.

Version:
$Id: StringEncoder.java 490 2010-10-15 21:35:52Z orank $
Author:
Oran Kelly

Constructor Summary
StringEncoder()
          Create a new StringEncoder.
 
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

StringEncoder

public StringEncoder()
Create a new StringEncoder.

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.