org.mobicents.protocols.smpp.encoding
Class AlphabetEncoding

java.lang.Object
  extended by org.mobicents.protocols.smpp.encoding.AbstractMessageEncoding<String>
      extended by org.mobicents.protocols.smpp.encoding.AlphabetEncoding
All Implemented Interfaces:
MessageEncoding<String>
Direct Known Subclasses:
ASCIIEncoding, DefaultAlphabetEncoding, HPRoman8Encoding, Latin1Encoding, UCS2Encoding, UTF16Encoding

public class AlphabetEncoding
extends AbstractMessageEncoding<String>

SMS Alphabet to Java String mapping interface. Implementations of this interface convert Java Unicode strings into a series of bytes representing the String in a particular SMS alphabet.


Constructor Summary
protected AlphabetEncoding(int dcs)
          Create a new alphabet encoding.
 
Method Summary
 String decode(byte[] data)
          Convert SMS message text into a Java String.
 String decode(byte[] data, int offset, int length)
          Convert SMS message text into a Java String.
 byte[] encode(String string)
          Convert a Java String into SMS message text.
 String getCharset()
          Get the character set in use by this alpabet encoding (if any).
 int getEncodedSize(String string)
          Get the number of bytes a particular string would encode as on the wire.
protected  void setCharset(String charset)
          Set the charset of this alphabet encoding.
 
Methods inherited from class org.mobicents.protocols.smpp.encoding.AbstractMessageEncoding
getDataCoding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AlphabetEncoding

protected AlphabetEncoding(int dcs)
Create a new alphabet encoding.

Parameters:
dcs - The data coding value to be used for this encoding.
Method Detail

getCharset

public String getCharset()
Get the character set in use by this alpabet encoding (if any).

Returns:
The character set in use by this alphabet encoding. This method may return null if the implementation is not using a JVM- supported character set.

decode

public String decode(byte[] data)
Convert SMS message text into a Java String. Implementations of this method must support decoding null. In such cases, the String "" will be returned.


decode

public String decode(byte[] data,
                     int offset,
                     int length)
Convert SMS message text into a Java String.

Parameters:
data - The bytes to decode.
offset - The offset within the data to begin decoding characters.
length - The number of bytes to decode to characters.
Throws:
NullPointerException - If data is null.

encode

public byte[] encode(String string)
Convert a Java String into SMS message text. Implementations of this method must support encoding a null string. In such cases, a byte array of length 0 will be returned.


getEncodedSize

public int getEncodedSize(String string)
Get the number of bytes a particular string would encode as on the wire.

Returns:
The number of bytes string would encode to.

setCharset

protected void setCharset(String charset)
                   throws UnsupportedEncodingException
Set the charset of this alphabet encoding. Sub-classes can use this to create new instances of alphabet encoding for character sets that are supported by the JVM. This method can only be called once. Subsequent calls will throw a RuntimeException.

Parameters:
charset - The character set to use for encoding and decoding.
Throws:
UnsupportedEncodingException - If the JVM does not support the specified character set.


Copyright © 2011 Mobicents. All Rights Reserved.