com.nmt.mgp
Class OptionHolder

java.lang.Object
  extended by com.nmt.mgp.OptionHolder

public class OptionHolder
extends java.lang.Object

Container for message options.


Constructor Summary
OptionHolder()
          Public constructor.
 
Method Summary
 void add(MgpOption option)
          Adds an MgpOption.
 void delete(int key)
          Deletes all options with a key that is equal to the specified key.
 void delete(MgpOption option)
          Deletes specified option.
 int getIntValue(int key)
          Gets the value of the option specified by key.
 int getIntValue(int key, int defaultValue)
          Gets the value of the option specified by key.
 MgpOption getOption(int key)
          Gets the option specified by key.
 java.util.Vector getOptions()
          Returns a vector containing all options in sequential order.
 java.lang.String getValue(int key)
          Gets the value of the option specified by key.
 java.util.Vector getValues(int key)
          Gets all the values of the option specified by key, as a Vector of Strings.
static OptionHolder load(java.io.BufferedReader in)
          Read all options from the supplied stream on the format specified by the Messaging Gateway Protocol (MGP).
 void write(java.io.Writer out)
          Writes all options to the supplied stream on the format specified by the Messaging Gateway Protocol (MGP).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OptionHolder

public OptionHolder()
Public constructor.

Method Detail

add

public void add(MgpOption option)
Adds an MgpOption.

Parameters:
option - the option to add

getOption

public MgpOption getOption(int key)
Gets the option specified by key.

Returns:
the first matching option, or null if none is found

getValue

public java.lang.String getValue(int key)
Gets the value of the option specified by key. If there are multiple occurances the first one will be used.
If no option with the key exists, null is returned.


delete

public void delete(MgpOption option)
Deletes specified option.


delete

public void delete(int key)
Deletes all options with a key that is equal to the specified key.


getValues

public java.util.Vector getValues(int key)
Gets all the values of the option specified by key, as a Vector of Strings. If no option with the key exists, an empty Vector is returned.


getIntValue

public int getIntValue(int key,
                       int defaultValue)
Gets the value of the option specified by key.

If no option with the key exists, the default value is returned.


getIntValue

public int getIntValue(int key)
                throws java.lang.NumberFormatException
Gets the value of the option specified by key.

If there are multiple occurances the first one will be used.

Throws:
java.lang.NumberFormatException - if no option with the key exists.

write

public void write(java.io.Writer out)
           throws java.io.IOException
Writes all options to the supplied stream on the format specified by the Messaging Gateway Protocol (MGP).

Throws:
java.io.IOException

getOptions

public java.util.Vector getOptions()
Returns a vector containing all options in sequential order.


load

public static OptionHolder load(java.io.BufferedReader in)
                         throws java.io.IOException
Read all options from the supplied stream on the format specified by the Messaging Gateway Protocol (MGP).

Throws:
java.io.IOException