com.objectxp.msg
Class GsmHelper

java.lang.Object
  extended by com.objectxp.msg.GsmHelper

public class GsmHelper
extends java.lang.Object

This class contains various static helper methods used for GSM communication.


Method Summary
static byte[] decodeIA5(java.lang.String hexstring)
          Convert a String containing hex-codes into the corresponding bytes.
static SmsMessage decodePDU(java.lang.String pdu, boolean incoming, boolean header)
          Decode a GSM PDU String.
static java.lang.String encodeIA5(byte[] bytes)
          Encode a byte array into a String containing hex codes.
static java.lang.String gsm2iso(java.lang.String str)
          Convert a given string from GSM default alphabet to the ISO-8859-1 charset.
static java.lang.String iso2gsm(java.lang.String str)
          Convert a given string from ISO-8859-1 to GSM default alphabet as specified in GSM 03.38.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

iso2gsm

public static java.lang.String iso2gsm(java.lang.String str)
Convert a given string from ISO-8859-1 to GSM default alphabet as specified in GSM 03.38. For more information about the GSM alphabet visit ETSI. Characters that are not available in the GSM default alphabet will be treated like this:

The GSM alphabet contains various characters that are not part of the ISO-8859-1 charset. Those characters must specified using their unicode-value. The following table contains a list of those characters with their unicode representation.

CharUnicode
Δ (Greek Alphabet Delta)\u0394
Φ (Greek Alphabet Phi)\u03A6
Γ (Greek Alphabet Gamma)\u0393
Λ (Greek Alphabet Lambda)\u039B
Ω (Greek Alphabet Omega)\u03A9
Π (Greek Alphabet Pi)\u03A0
Ψ (Greek Alphabet Psi)\u03A8
Σ (Greek Alphabet Sigma)\u03A3
Θ (Greek Alphabet Theta)\u0398
Ξ (Greek Alphabet Xi)\u039E
€ (Euro)\u20AC

Example:
 String gsm = GsmHelper.iso2gsm("The price is 49 \u20AC"); // The price is 49 €
 

Parameters:
str - the string to convert.
Returns:
the string converted to the GSM default alphabet.
See Also:
gsm2iso(String)

gsm2iso

public static java.lang.String gsm2iso(java.lang.String str)
Convert a given string from GSM default alphabet to the ISO-8859-1 charset. Characters that are not part of ISO-8859-1 will be converted to their unicode value as described in iso2gsm(String).

Parameters:
str - GSM string to convert.
Returns:
the string converted to the ISO-8859-1 charset.

decodePDU

public static SmsMessage decodePDU(java.lang.String pdu,
                                   boolean incoming,
                                   boolean header)
                            throws ParseException
Decode a GSM PDU String.

Parameters:
pdu - the PDU String
incoming - true if the PDU is incoming (received by SMSC), false if the PDU is outgoing (sent to SMSC).
header - true if the PDU string contains a SMSC header (GSM 07.05), false otherwise.
Returns:
the decoded Message or null if the PDU parameter is null
Throws:
ParseException - if parsing of the PDU string fails
Since:
jSMS 2.0.2

decodeIA5

public static byte[] decodeIA5(java.lang.String hexstring)
Convert a String containing hex-codes into the corresponding bytes. Passing e.g. the String "FF00" to this method will return a byte array containing two bytes, the first byte having the value 255 (0xff), the second having the value 0.

Parameters:
hexstring - a string containing a hexadecimal representation of n bytes.
See Also:
encodeIA5(byte[])

encodeIA5

public static java.lang.String encodeIA5(byte[] bytes)
Encode a byte array into a String containing hex codes. For each byte in the array, the string will contain two characters ranging from '0' to 'F'.

See Also:
decodeIA5(String)


object XP, Inc. © 2000-2008. All rights reserved object XP