|
J2ME Wireless Toolkit WMA Bridge API | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.kvem.midp.io.j2se.wma.Message
A WMA Message. Represents a SMS or CBS message, or a fragment of one.
This message is sent and received via a
WMAClient
.
Message supports two kinds of text encodings: gsm-7bit and ucs-2.
You can construct a message with more data than will fit into one message
fragment. When you send such a message (using
WMAClient.send
),
the message will be broken up into the proper number of fragments.
You can also construct a message and specify its segments and which fragment number this message is. When you send such a message, the message will be sent as-is, without attempting to fragment it.
Messages have two addresses associated with them: the "from" address and the "to" address. The from address is the address from which the message originally was sent, and the to address is the address to which the message is destined. Each address obeys the form "protocol://[+]phoneNum[:port]", where protocol is either "sms" or "cbs". The addresses may or may not contain the port components. CBS messages do not contain from address information at all, and their to address contains no phone number - only a port.
In other words, here are examples of valid SMS "to" and "from" addresses:
- sms://+12345678
- sms://+12345678:910
and this is a valid CBS "to" address:
- cbs://:456
Field Summary | |
static java.lang.String |
GSM7BIT_ENCODING
This text message has GSM-7bit encoding. |
static java.lang.String |
UCS2_ENCODING
This text message has UCS-2 encoding. |
Constructor Summary | |
Message(byte[] data)
Make a binary message or a text message with a text encoding that you performed already. |
|
Message(com.sun.kvem.midp.io.j2se.wma.common.DatagramRecord rec)
|
|
Message(java.lang.String text)
Make a text message. |
Method Summary | |
boolean |
addPreviousFragment(com.sun.kvem.midp.io.j2se.wma.Message previousFragment)
Add a previous fragment to the beginning of this fragment. |
int |
getContentLength()
Returns the content length in bytes of this message. |
byte[] |
getData()
Returns the raw data of the message content. |
int |
getFragmentNum()
Returns the fragment number of this message, -1 if it is not part of a segmented message. |
int |
getFragmentOffset()
Returns the offset in bytes of this message fragment, or 0 if this is not part of a segmented message. |
int |
getFragmentSize()
Returns the size in bytes of this message fragment, or 0 if this is not part of a segmented message. |
java.lang.String |
getFromAddress()
Returns the from address of this message, which will be in the format "protocol://[+]phoneNum[:port]", or null if none was set. |
int |
getFromPort()
Returns the from port of this message, or -1 if none was set. |
int |
getNumSegments()
Returns the number of segments in this message. |
byte[] |
getRawData()
Returns the raw data that would be sent to the WMA Server. |
long |
getSendTime()
Returns the send time of the message, or 0 if none exists (as in CBS messages). |
java.lang.String |
getTextEncoding()
Returns the text encoding of this message, null if it is a binary message. |
java.lang.String |
getToAddress()
Returns the to address of this message, which will be in the format "protocol://[+][phoneNum][:port]" |
int |
getToPort()
Returns the to port of this message, or -1 if none was set. |
boolean |
isFragmented()
Returns true if this message has more than one fragment. |
boolean |
isSMS()
Returns true if this is an SMS message, false otherwise. |
boolean |
isText()
Returns true if this message contains text data. |
void |
setContentLength(int len)
Set the content length of this message. |
void |
setFragmentNum(int num)
Set the fragment number of this message. |
void |
setFragmentOffset(int offset)
Set the fragment offset of this message. |
void |
setFragmentSize(int size)
Set the fragment size of this message. |
void |
setFromAddress(java.lang.String url)
Set the from address of the message. |
void |
setFromPort(int port)
Set the from port of this message. |
void |
setNumSegments(int num)
Set the number of segments in this message. |
void |
setSendTime(long time)
Set the send time of the message. |
void |
setTextEncoding(java.lang.String encoding)
Set the text encoding for this message. |
void |
setToAddress(java.lang.String url)
Set the to address of the message. |
void |
setToPort(int port)
Set the to port of this message. |
java.lang.String |
toString()
Returns the text of this message if it is text, or a String representation of the payload if it is binary. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String GSM7BIT_ENCODING
public static final java.lang.String UCS2_ENCODING
Constructor Detail |
public Message(byte[] data)
If it is text content, report the encoding via
setTextEncoding
.
Note that for GSM7BIT_ENCODING
text data each GSM septet should be padded to occupy a full byte.
data
- the raw content.
java.lang.NullPointerException
- the data was null.public Message(com.sun.kvem.midp.io.j2se.wma.common.DatagramRecord rec)
public Message(java.lang.String text)
text
- the text content.
java.lang.NullPointerException
- the text was null.Method Detail |
public boolean addPreviousFragment(com.sun.kvem.midp.io.j2se.wma.Message previousFragment) throws java.io.IOException
previousFragment
- the previous message fragment. Can be null.
java.io.IOException
- the message has arrived out of sequence.public int getContentLength()
public byte[] getData()
getTextEncoding
.
getTextEncoding
.public int getFragmentNum()
public int getFragmentOffset()
public int getFragmentSize()
public java.lang.String getFromAddress()
public int getFromPort()
public int getNumSegments()
public byte[] getRawData()
public long getSendTime()
public java.lang.String getTextEncoding()
public java.lang.String getToAddress()
public int getToPort()
public boolean isFragmented()
public boolean isSMS()
public boolean isText()
public void setContentLength(int len)
len
- the content length in bytes.public void setFragmentNum(int num)
num
- the fragment number of this message.public void setFragmentOffset(int offset)
offset
- the offset in bytes of this message fragment.public void setFragmentSize(int size)
size
- the size in bytes of this message fragment.public void setFromAddress(java.lang.String url)
url
- the to address. This must follow the format
"protocol://[+]phoneNum[:port]".public void setFromPort(int port)
port
- the from port.public void setNumSegments(int num)
num
- the number of segments in this message.public void setSendTime(long time)
time
- the send timepublic void setTextEncoding(java.lang.String encoding)
encoding
- the encoding. This must be either
Message.GSM7BIT_ENCODING
or
Message.UCS2_ENCODING
.
java.lang.IllegalArgumentException
- the requested encoding is not supported.
java.lang.NullPointerException
- the encoding was null.public void setToAddress(java.lang.String url)
url
- the to address. This must follow the format
"protocol://[+][phoneNum][:port]".
CBS messages have no phoneNum component.public void setToPort(int port)
port
- the to port.public java.lang.String toString()
toString
in class java.lang.Object
|
J2ME Wireless Toolkit WMA Bridge API | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |