ie.omk.smpp.message.tlv
Class OctetEncoder

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

public class OctetEncoder
extends Object
implements Encoder

Encode an octet string to a byte array. This class is encoding byte arrays to byte arrays! Therefore it's just copying bytes around. Not much more to it.

Version:
$Id: OctetEncoder.java 255 2006-03-09 09:34:37Z orank $
Author:
Oran Kelly

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

OctetEncoder

public OctetEncoder()
Create a new OctetEncoder.

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.