com.objectxp.msg.util
Class SmsHeader

java.lang.Object
  extended by com.objectxp.msg.util.SmsHeader

public class SmsHeader
extends java.lang.Object

This class represents a GSM User Data Header (UDH). It can be used to construct custom UDH elements.

The example below demonstrates how to add a "Application Port Addressing" header to a SMS.

  import com.objectxp.msg.SmsMessage;
  import com.objectxp.msg.util.*;
 
  SmsMessage msg = new SmsMessage();
  SmsHeader hdr = new SmsHeader();
  hdr.add(new PortAddressingHeaderElement(true, 5512, 4711));
  msg.setUserDataHeader(hdr.getBytes());
  msg.setMessage("Hello World");
 

See the GSM 03.40 specification for more information about the User Data Header.

Since:
jSMS 1.8
See Also:
SmsHeaderElement

Constructor Summary
SmsHeader()
          Construct a new, empty SmsHeader.
 
Method Summary
 void add(SmsHeaderElement e)
          Add a SMS Header Element.
 java.util.Enumeration elements()
          Get all Header elements belonging to this SMS Header.
 byte[] getBytes()
          Get the binary representation of the SMS Header.
 int getLength()
          Returns the number of elements contained within the SMS Header.
static SmsHeader parseHeader(byte[] data)
          Construct a SmsHeader object by parsing UDH data.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SmsHeader

public SmsHeader()
Construct a new, empty SmsHeader.

Method Detail

parseHeader

public static SmsHeader parseHeader(byte[] data)
                             throws HeaderParseException
Construct a SmsHeader object by parsing UDH data.

Parameters:
data - the user data header
Returns:
a SmsHeader object representing the UDH.
Throws:
HeaderParseException - if parsing the data fails

add

public void add(SmsHeaderElement e)
Add a SMS Header Element.

Parameters:
e - a SMS Header element

elements

public java.util.Enumeration elements()
Get all Header elements belonging to this SMS Header.

Returns:
an enumeration of SmsHeaderElements.

getLength

public int getLength()
Returns the number of elements contained within the SMS Header.

Returns:
the number of elements.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getBytes

public byte[] getBytes()
Get the binary representation of the SMS Header. The byte array returned may be passed to SmsMessage.setUserDataHeader(byte[]).

Returns:
the UDH as byte array.


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