ie.omk.smpp.util
Class EncodingFactory

java.lang.Object
  extended by ie.omk.smpp.util.EncodingFactory

public class EncodingFactory
extends Object

Factory class for obtaining message encoding instances. By default, instances of this class are aware of the following encoding types:

Other encoding types may be added to an instance of the factory but it should be noted that there can only be one encoding mapping for any particular data coding value. If a second encoding is added which has the same data coding value as another encoding, the existing encoding will be overwritten in the factory.

The rest of the SMPPAPI uses the singleton instance of this factory as returned by the static getInstance() method of this class.


Constructor Summary
EncodingFactory()
           
 
Method Summary
 void addEncoding(Class encodingClass)
          Add a message encoding to this factory.
 void addEncoding(MessageEncoding encoding)
          Add a message encoding to this factory.
 Iterator getAllEncodings()
          Get an iterator over all known encodings by this factory.
 AlphabetEncoding getAlphabet(String lang)
          Get the SMSAlphabet needed for encoding messages in a particular language.
 AlphabetEncoding getDefaultAlphabet()
          Return the default alphabet for this runtime environment.
 MessageEncoding getEncoding(int dataCoding)
          Get the message encoding represented by the specified data coding value.
static EncodingFactory getInstance()
          Get a static instance of this factory class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncodingFactory

public EncodingFactory()
Method Detail

getInstance

public static final EncodingFactory getInstance()
Get a static instance of this factory class.

Returns:
A static instance of EncodingFactory.

getEncoding

public MessageEncoding getEncoding(int dataCoding)
Get the message encoding represented by the specified data coding value.

Parameters:
dataCoding - The data coding to retrieve a message encoding instance for.
Returns:
The message encoding instance representing data coding value dataCoding or null if there is no encoding registered for that value.

addEncoding

public void addEncoding(MessageEncoding encoding)
Add a message encoding to this factory.

Parameters:
encoding - The encoding to add to the factory.

addEncoding

public void addEncoding(Class encodingClass)
Add a message encoding to this factory. The supplied class must be a sub-class of MessageEncoding and must have a no-argument constructor.

Parameters:
encodingClass - The class of the MessageEncoding to add.

getAllEncodings

public Iterator getAllEncodings()
Get an iterator over all known encodings by this factory.

Returns:
An iterator over all the encodings known by this factory.

getDefaultAlphabet

public AlphabetEncoding getDefaultAlphabet()
Return the default alphabet for this runtime environment. The default alphabet is usually DefaultAlphabetEncoding. This can be altered by setting the smpp.default_alphabet system property to the name of an implementation of AlphabetEncoding.

For example:
java -cp .:smppapi.jar -Dsmpp.default_alphabet=myPackage.MyAlphabet ...

Returns:
The default alphabet encoding.

getAlphabet

public AlphabetEncoding getAlphabet(String lang)
Get the SMSAlphabet needed for encoding messages in a particular language.

Parameters:
lang - The ISO code for the language the message is in.


Copyright © 2011 smppapi at Sourceforge. All Rights Reserved.