org.marre.sms
Class SmsUdhUtil

java.lang.Object
  extended byorg.marre.sms.SmsUdhUtil

public final class SmsUdhUtil
extends java.lang.Object

Toolkit class for SmsUdhElement objects.

Version:
$Id: SmsUdhUtil.java,v 1.5 2005/05/06 13:55:11 c95men Exp $
Author:
Markus Eriksson

Method Summary
static SmsUdhElement get16BitApplicationPortUdh(int theDestPort, int theOrigPort)
          Creates a "16 bit Application Port Adressing" UDH element using UDH_IEI_APP_PORT_16BIT Note!
static SmsUdhElement get16BitConcatUdh(int theRefNr, int theTotSms, int theSeqNr)
          Creates a "16Bit concatenated" UDH element using UDH_IEI_CONCATENATED_16BIT This can be used to create a concatenated SMS.
static SmsUdhElement get8BitApplicationPortUdh(int theDestPort, int theOrigPort)
          Creates a "8 bit Application Port Adressing" UDH element using UDH_IEI_APP_PORT_8BIT Note!
static SmsUdhElement get8BitConcatUdh(int theRefNr, int theTotSms, int theSeqNr)
          Creates a "8Bit concatenated" UDH element using UDH_IEI_CONCATENATED_8BIT.
static SmsUdhElement getEmsTextFormattingUdh(int theStartPos, int theFormatLen, byte theAlignment, byte theFontSize, byte theStyle, byte theForegroundColor, byte theBackgroundColor)
          Creates a "EMS Text Formatting" UDH element.
static SmsUdhElement getEmsUserDefinedSoundUdh(byte[] theIMelody, int position)
          Creates an ems user defined sound udh.
static SmsUdhElement getEmsUserPromptIndicatorUdh(int numFragments)
          Creates an ems user prompt indicator udh.
static SmsUdhElement getEmsVariablePictureUdh(byte[] bitmap, int width, int height, int position)
          Creates an ems variable picture udh.
static SmsUdhElement getMessageWaitingUdh(boolean storeMsg, int theMsgType, int theMsgCount)
          Creates a "Message waiting" UDH element using UDH_IEI_SPECIAL_MESSAGE.
static int getTotalSize(SmsUdhElement[] theUdhElements)
          Calculates the number of bytes needed for the supplied udh elements.
static boolean isConcat(SmsUserData ud, byte[] udh)
          Calculates if the given data needs a concatenated SMS.
static byte[] toByteArray(SmsUdhElement[] theUdhElements)
          Returns the whole udh as a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTotalSize

public static int getTotalSize(SmsUdhElement[] theUdhElements)
Calculates the number of bytes needed for the supplied udh elements.

Parameters:
theUdhElements - The udh elements
Returns:
The size (in bytes)

toByteArray

public static byte[] toByteArray(SmsUdhElement[] theUdhElements)
Returns the whole udh as a byte array.

The returned UDH is the same as specified when the message was created. No concat headers are added. TODO: Rename this function. The name is totally wrong.

Returns:
the UDH elements as a byte array.

isConcat

public static boolean isConcat(SmsUserData ud,
                               byte[] udh)
Calculates if the given data needs a concatenated SMS.

Parameters:
ud - User data
udh - UDH elements
Returns:
true if the message must be concatentated.

get8BitConcatUdh

public static SmsUdhElement get8BitConcatUdh(int theRefNr,
                                             int theTotSms,
                                             int theSeqNr)
Creates a "8Bit concatenated" UDH element using UDH_IEI_CONCATENATED_8BIT. This can be used to create a concatenated SMS.

Parameters:
theRefNr - The reference number of this SMS, must be the same in all SMS. Max 255.
theTotSms - Total number of SMS. Max 255.
theSeqNr - Sequence number. Max 255.
Returns:
A SmsUdhElement

getMessageWaitingUdh

public static SmsUdhElement getMessageWaitingUdh(boolean storeMsg,
                                                 int theMsgType,
                                                 int theMsgCount)
Creates a "Message waiting" UDH element using UDH_IEI_SPECIAL_MESSAGE.

If more than one type of message is required to be indicated within one SMS message, then multiple "Message waiting" UDH elements must be used.

Special handling in concatenated messages:
"In the case where this IEI is to be used in a concatenated SM then the IEI, its associated IEI length and IEI data shall be contained in the first segment of the concatenated SM. The IEI, its associated IEI length and IEI data should also be contained in every subsequent segment of the concatenated SM although this is not mandatory. However, in the case where these elements are not contained in every subsequent segment of the concatenated SM and where an out of sequence segment delivery occurs or where the first segment is not delivered then processing difficulties may arise at the receiving entity which may result in the concatenated SM being totally or partially discarded."

Parameters:
storeMsg - Set to true if the message should be stored
theMsgType - Message type, may be one of MESSAGE_WAITING_VOICE, MESSAGE_WAITING_FAX, MESSAGE_WAITING_EMAIL or MESSAGE_WAITING_OTHER.
theMsgCount - Number of messages waiting for retrieval. Max 255 messages. The value 255 shall be taken to mean 255 or greater.
Returns:
A SmsUdhElement

get8BitApplicationPortUdh

public static SmsUdhElement get8BitApplicationPortUdh(int theDestPort,
                                                      int theOrigPort)
Creates a "8 bit Application Port Adressing" UDH element using UDH_IEI_APP_PORT_8BIT

Note! Only values between 240 and 255 are usable, the rest of the port numbers are marked as reserved.

Special handling in concatenated messages:
In the case where this IE is to be used in a concatenated SM then the IEI, its associated IEI length and IEI data shall be contained in the first segment of the concatenated SM. The IEI, its associated IEI length and IEI data shall also be contained in every subsequent segment of the concatenated SM.

Parameters:
theDestPort - Destination port
theOrigPort - Source port
Returns:
A SmsUdhElement

get16BitApplicationPortUdh

public static SmsUdhElement get16BitApplicationPortUdh(int theDestPort,
                                                       int theOrigPort)
Creates a "16 bit Application Port Adressing" UDH element using UDH_IEI_APP_PORT_16BIT

Note! Only values between 0 and 16999 are usable, the rest of the port numbers are marked as reserved.

Special handling in concatenated messages:
In the case where this IE is to be used in a concatenated SM then the IEI, its associated IEI length and IEI data shall be contained in the first segment of the concatenated SM. The IEI, its associated IEI length and IEI data shall also be contained in every subsequent segment of the concatenated SM.

Parameters:
theDestPort - Destination port
theOrigPort - Source port
Returns:
A SmsUdhElement

get16BitConcatUdh

public static SmsUdhElement get16BitConcatUdh(int theRefNr,
                                              int theTotSms,
                                              int theSeqNr)
Creates a "16Bit concatenated" UDH element using UDH_IEI_CONCATENATED_16BIT

This can be used to create a concatenated SMS.

Parameters:
theRefNr - The reference number of this SMS, must be the same in all SMS. Max 65536
theTotSms - Total number of SMS. Max 255
theSeqNr - Sequence number. Max 255
Returns:
A SmsUdhElement

getEmsTextFormattingUdh

public static SmsUdhElement getEmsTextFormattingUdh(int theStartPos,
                                                    int theFormatLen,
                                                    byte theAlignment,
                                                    byte theFontSize,
                                                    byte theStyle,
                                                    byte theForegroundColor,
                                                    byte theBackgroundColor)
Creates a "EMS Text Formatting" UDH element.

Parameters:
theStartPos - Start position of the text formatting. This position is relative to the start of the UD field of the PDU.
theFormatLen - The number of character to format. If 0 it sets the default text formatting.
theAlignment - Can be any of EMS_TEXT_ALIGN_*
theFontSize - Can be any of EMS_TEXT_SIZE_*
theStyle - Can be any of EMS_TEXT_STYLE_*
theForegroundColor - Can be any of EMS_TEXT_COLOR_*
theBackgroundColor - Can be any of EMS_TEXT_COLOR_*
Returns:
A SmsUdhElement

getEmsUserDefinedSoundUdh

public static SmsUdhElement getEmsUserDefinedSoundUdh(byte[] theIMelody,
                                                      int position)
Creates an ems user defined sound udh.

Parameters:
theIMelody - The imelody data
position - The position
Returns:
An SmsUdhElement with a user defined sound

getEmsUserPromptIndicatorUdh

public static SmsUdhElement getEmsUserPromptIndicatorUdh(int numFragments)
Creates an ems user prompt indicator udh.

Parameters:
numFragments - Number of fragments
Returns:
An SmsUdhElement with an user prompt indicator

getEmsVariablePictureUdh

public static SmsUdhElement getEmsVariablePictureUdh(byte[] bitmap,
                                                     int width,
                                                     int height,
                                                     int position)
Creates an ems variable picture udh.

Parameters:
bitmap - The bitmap data
width - The width of the bitmap (in pixels)
height - The height of the bitmap (in pixels)
position - The position of the bitmap
Returns:
An SmsUdhElement with the bitmap


Copyright © 2002-2005 Markus Eriksson. All Rights Reserved.