EMGJavaAPI
Public Member Functions | Private Attributes
com::nmt::mgp::Message Class Reference

A message with a list of options, to be sent via MGP to the EMG Server. More...

List of all members.

Public Member Functions

 Message ()
 Create a new message.
 Message (OptionHolder options)
 Create a new message.
 Message (BufferedReader in) throws IOException
 Create a new message.
 Message (String destaddr, String text)
 Create a basic text message.
 Message (String destaddr, char[] data)
 Create a basic text message with binary data.
 Message (String destaddr)
 Create a basic message with destaddr.
OptionHolder getOptions ()
 Returns the message options.
void addOption (MgpOption option)
 Add an option to this message.
void addText (String text)
 Adds message text to this message.
void addText (char[] data)
 Add binary message data to this message.
void addHex (String hex)
 Add message data which is already hex encoded.
void addUdh (char[] udh)
 Add a UDH (User Data Header) to message.
void deleteOption (MgpOption option)
 Delete a specific MGP option from message.
String getId ()
 Gets the message id.
boolean equals (Message msg)
 Compare this messge with another.
void load (BufferedReader in) throws IOException
 Loads the message options from an input stream.
void save (BufferedWriter out) throws IOException
 Saves the message options to an output stream.

Private Attributes

OptionHolder options = null
int charcode = Mgp.MGP_CHARCODE_DEFAULT

Detailed Description

A message with a list of options, to be sent via MGP to the EMG Server.

The message text is hex encoded for safe transportation.


Constructor & Destructor Documentation

com::nmt::mgp::Message::Message ( ) [inline]

Create a new message.

References options.

com::nmt::mgp::Message::Message ( OptionHolder  options) [inline]

Create a new message.

References options.

com::nmt::mgp::Message::Message ( BufferedReader  in) throws IOException [inline]

Create a new message.

References com::nmt::mgp::OptionHolder::load(), and options.

com::nmt::mgp::Message::Message ( String  destaddr,
String  text 
) [inline]

Create a basic text message.

Parameters:
destaddrthe destination address, stored as the option Mgp.MGP_OPTION_DESTADDR
textthe message text, stored as the option Mgp.MGP_OPTION_MESSAGE

References com::nmt::mgp::OptionHolder::add(), com::nmt::mgp::Mgp::MGP_OPTION_DESTADDR, com::nmt::mgp::Mgp::MGP_OPTION_MESSAGE, and options.

com::nmt::mgp::Message::Message ( String  destaddr,
char[]  data 
) [inline]

Create a basic text message with binary data.

Parameters:
destaddrthe destination address, stored as the option Mgp.MGP_OPTION_DESTADDR
datathe message text, stored as the option Mgp.MGP_OPTION_MESSAGE

References com::nmt::mgp::OptionHolder::add(), charcode, com::nmt::mgp::Mgp::MGP_CHARCODE_8BIT, com::nmt::mgp::Mgp::MGP_OPTION_DESTADDR, com::nmt::mgp::Mgp::MGP_OPTION_MESSAGE, and options.

com::nmt::mgp::Message::Message ( String  destaddr) [inline]

Create a basic message with destaddr.

Parameters:
destaddrthe destination address, stored as the option Mgp.MGP_OPTION_DESTADDR

References com::nmt::mgp::OptionHolder::add(), com::nmt::mgp::Mgp::MGP_OPTION_DESTADDR, and options.


Member Function Documentation

void com::nmt::mgp::Message::addHex ( String  hex) [inline]

Add message data which is already hex encoded.

Sets the character code for this message to MGP_CHARCODE_8BIT.

References com::nmt::mgp::OptionHolder::add(), charcode, com::nmt::mgp::Mgp::MGP_CHARCODE_8BIT, com::nmt::mgp::Mgp::MGP_OPTION_MESSAGE, and options.

void com::nmt::mgp::Message::addOption ( MgpOption  option) [inline]

Add an option to this message.

References com::nmt::mgp::OptionHolder::add(), and options.

void com::nmt::mgp::Message::addText ( char[]  data) [inline]

Add binary message data to this message.

Sets the character code for message to MGP_CHARCODE_8BIT.

References com::nmt::mgp::OptionHolder::add(), charcode, com::nmt::mgp::Mgp::MGP_CHARCODE_8BIT, com::nmt::mgp::Mgp::MGP_OPTION_MESSAGE, and options.

void com::nmt::mgp::Message::addText ( String  text) [inline]

Adds message text to this message.

Sets the character code for the message to MGP_CHARCODE_DEFAULT.

References com::nmt::mgp::OptionHolder::add(), charcode, com::nmt::mgp::Mgp::MGP_CHARCODE_DEFAULT, com::nmt::mgp::Mgp::MGP_OPTION_MESSAGE, and options.

void com::nmt::mgp::Message::addUdh ( char[]  udh) [inline]

Add a UDH (User Data Header) to message.

References com::nmt::mgp::OptionHolder::add(), com::nmt::mgp::Mgp::MGP_OPTION_UDH, and options.

void com::nmt::mgp::Message::deleteOption ( MgpOption  option) [inline]

Delete a specific MGP option from message.

References com::nmt::mgp::OptionHolder::delete(), and options.

boolean com::nmt::mgp::Message::equals ( Message  msg) [inline]

Compare this messge with another.

Only the message id's are compared.

Returns:
true if and only if the message id's are equal and not equal to -1.
See also:
getId()

References equals(), and getId().

Referenced by equals().

String com::nmt::mgp::Message::getId ( ) [inline]

Gets the message id.

The MGP option MGP_OPTION_ID is located and returned.

Returns:
The message id value, or null if the option isn't found.

References com::nmt::mgp::OptionHolder::getValue(), com::nmt::mgp::Mgp::MGP_OPTION_ID, and options.

Referenced by equals().

OptionHolder com::nmt::mgp::Message::getOptions ( ) [inline]

Returns the message options.

References options.

void com::nmt::mgp::Message::load ( BufferedReader  in) throws IOException [inline]

Loads the message options from an input stream.

Parameters:
inthe input stream, already opened
Exceptions:
IOExceptionif an error occurs while reading

References com::nmt::mgp::OptionHolder::load(), and options.

void com::nmt::mgp::Message::save ( BufferedWriter  out) throws IOException [inline]

Saves the message options to an output stream.

Parameters:
outthe output stream, already initiated
Exceptions:
IOExceptionif an error occurs while writing

References options, and com::nmt::mgp::OptionHolder::write().


Member Data Documentation

Referenced by addHex(), addText(), and Message().


The documentation for this class was generated from the following file: