org.PingOO.DLAI.lib.util
Class MessageHashtable

java.lang.Object
  |
  +--org.PingOO.DLAI.lib.util.MessageHashtable

public final class MessageHashtable
extends java.lang.Object

A derived hashtable to use in the protocol to send message to the server.
This hashtable delegates to basic Hashtable, so it can be used with only String keys and can only contain String, String[], BinaryData or ValueHashtable values.

This class is designed primary for network exchange not for data handling. You may use a real hashtable for this kind of operations.

Since:
PingOO 2.0
Version:
2.0
Author:
Fabrice Bouyé (bouye@cur-archamps.fr)
See Also:
Hashtable

Field Summary
static java.lang.String ACCEPTED_KEY
          Indicates an accepted line.
static java.lang.String COMMENT_KEY
          Indicates an comment line.
static java.lang.String FUNCTION_KEY
          This key is needed to get the name of the function which uses this Hashtable.
private  java.util.Hashtable hashtable
          A private inner Hashtable to which the job is delegated.
static java.lang.String MODULE_KEY
          This key is needed to get the name of the module which created this Hashtable.
private  java.util.Hashtable propertyTable
          Contains the properties of the current message.
private static int REQUEST_ID
          Generates the id number of the request corresponding to this MessageHashtable.
static java.lang.String REQUEST_ID_KEY
          This key is needed to get the id of this request.
 
Constructor Summary
MessageHashtable(java.lang.String module, java.lang.String function)
          Creates a new MessageHashtable for the given module and the given function.
 
Method Summary
 void clear()
          Clears this hashtable so that it contains no keys.
 boolean contains(java.lang.Object value)
          Tests if some key maps into the specified value in this hashtable.
 boolean containsKey(java.lang.String key)
          Tests if the specified object is a key in this hashtable.
 boolean containsValue(java.lang.Object value)
          Returns true if this Hashtable maps one or more keys to this value.
 java.util.Enumeration elements()
          Returns an enumeration of the values in this hashtable.
 java.lang.Object get(java.lang.String key)
          Returns the value to which the specified key is mapped in this hashtable.
 java.util.Hashtable getProperties()
          Returns the entire set of this message property.
 java.lang.String getProperty(java.lang.String propertyKey)
          Returns a property defined by the givent key.
 boolean isEmpty()
          Tests if this hashtable maps no keys to values.
 java.util.Enumeration keys()
          Returns an enumeration of the keys in this hashtable.
 java.lang.Object put(java.lang.String key, BinaryData value)
          Maps the specified key to the specified value in this hashtable.
 java.lang.Object put(java.lang.String key, java.lang.String value)
          Maps the specified key to the specified value in this hashtable.
 java.lang.Object put(java.lang.String key, java.lang.String[] value)
          Maps the specified key to the specified value in this hashtable.
 java.lang.Object put(java.lang.String key, ValueHashtable value)
          Maps the specified key to the specified value in this hashtable.
 java.lang.Object remove(java.lang.String key)
          Removes the key (and its corresponding value) from this hashtable.
 void setProperty(java.lang.String propertyKey, java.lang.String value)
          Sets a property
 int size()
          Returns the number of keys in this hashtable.
 java.util.Hashtable toHashtable()
          Return a hashtable representation of this object.
 java.lang.String toString()
          Returns a String representation of this MessageHashtable and of the included values.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

REQUEST_ID

private static int REQUEST_ID
Generates the id number of the request corresponding to this MessageHashtable.

MODULE_KEY

public static final java.lang.String MODULE_KEY
This key is needed to get the name of the module which created this Hashtable.

FUNCTION_KEY

public static final java.lang.String FUNCTION_KEY
This key is needed to get the name of the function which uses this Hashtable.

REQUEST_ID_KEY

public static final java.lang.String REQUEST_ID_KEY
This key is needed to get the id of this request.

ACCEPTED_KEY

public static final java.lang.String ACCEPTED_KEY
Indicates an accepted line.

COMMENT_KEY

public static final java.lang.String COMMENT_KEY
Indicates an comment line.

hashtable

private final java.util.Hashtable hashtable
A private inner Hashtable to which the job is delegated.

propertyTable

private final java.util.Hashtable propertyTable
Contains the properties of the current message.
Constructor Detail

MessageHashtable

public MessageHashtable(java.lang.String module,
                        java.lang.String function)
Creates a new MessageHashtable for the given module and the given function.
Parameters:
module - The module which creates this MessageHashtable.
function - The function which uses this MessageHashtable.
Method Detail

getProperties

public final java.util.Hashtable getProperties()
Returns the entire set of this message property.
Returns:
the copy of this message property.

getProperty

public final java.lang.String getProperty(java.lang.String propertyKey)
Returns a property defined by the givent key.
Parameters:
propertyKey - The key need to retreive the desired property.
Returns:
A property.

setProperty

public final void setProperty(java.lang.String propertyKey,
                              java.lang.String value)
Sets a property
Parameters:
propertyKey - The property key.
value - The new property, can be null

clear

public final void clear()
Clears this hashtable so that it contains no keys.

contains

public final boolean contains(java.lang.Object value)
                       throws java.lang.NullPointerException
Tests if some key maps into the specified value in this hashtable.
Returns:
true if and only if some key maps to the value argument in this hashtable as determined by the equals method; false otherwise.
Throws:
java.lang.NullPointerException - If the value is null.

containsKey

public final boolean containsKey(java.lang.String key)
Tests if the specified object is a key in this hashtable.
Returns:
true if and only if the specified object is a key in this hashtable, as determined by the equals method; false otherwise.

containsValue

public final boolean containsValue(java.lang.Object value)
Returns true if this Hashtable maps one or more keys to this value.
Returns:
true if and only if some key maps to the value argument in this hashtable as determined by the equals method; false otherwise.

elements

public final java.util.Enumeration elements()
Returns an enumeration of the values in this hashtable.
Returns:
An enumeration of the values in this hashtable.

get

public final java.lang.Object get(java.lang.String key)
Returns the value to which the specified key is mapped in this hashtable.
Returns:
The value to which the key is mapped in this hashtable; null if the key is not mapped to any value in this hashtable.

isEmpty

public final boolean isEmpty()
Tests if this hashtable maps no keys to values.
Returns:
true if this hashtable maps no keys to values; false otherwise.

keys

public final java.util.Enumeration keys()
Returns an enumeration of the keys in this hashtable.
Returns:
An enumeration of the keys in this hashtable.

put

public final java.lang.Object put(java.lang.String key,
                                  java.lang.String value)
                           throws java.lang.NullPointerException
Maps the specified key to the specified value in this hashtable.
Neither the key nor the value can be null.

The value can be retrieved by calling the get method with a key that is equal to the original key.

Parameters:
key - The hashtable key.
value - The String value.
Returns:
The previous value of the specified key in this hashtable, or null if it did not have one.
Throws:
java.lang.NullPointerException - If the key or value is null.

put

public final java.lang.Object put(java.lang.String key,
                                  java.lang.String[] value)
                           throws java.lang.NullPointerException
Maps the specified key to the specified value in this hashtable.
Neither the key nor the value can be null.

The value can be retrieved by calling the get method with a key that is equal to the original key.

Parameters:
key - The hashtable key.
value - The String[] value.
Returns:
The previous value of the specified key in this hashtable, or null if it did not have one.
Throws:
java.lang.NullPointerException - If the key or value is null.

put

public final java.lang.Object put(java.lang.String key,
                                  BinaryData value)
                           throws java.lang.NullPointerException
Maps the specified key to the specified value in this hashtable.
Neither the key nor the value can be null.

The value can be retrieved by calling the get method with a key that is equal to the original key.

Parameters:
key - The hashtable key.
value - The BinaryData value.
Returns:
The previous value of the specified key in this hashtable, or null if it did not have one.
Throws:
java.lang.NullPointerException - If the key or value is null.

put

public final java.lang.Object put(java.lang.String key,
                                  ValueHashtable value)
                           throws java.lang.NullPointerException
Maps the specified key to the specified value in this hashtable.
Neither the key nor the value can be null.

The value can be retrieved by calling the get method with a key that is equal to the original key.

Parameters:
key - The hashtable key.
value - The ValueHashtable value.
Returns:
The previous value of the specified key in this hashtable, or null if it did not have one.
Throws:
java.lang.NullPointerException - If the key or value is null.

remove

public final java.lang.Object remove(java.lang.String key)
Removes the key (and its corresponding value) from this hashtable.
This method does nothing if the key is not in the hashtable.
Parameters:
key - the key that needs to be removed.
Returns:
The value to which the key had been mapped in this hashtable, or null if the key did not have a mapping.

size

public final int size()
Returns the number of keys in this hashtable.
Returns:
The number of keys in this hashtable.

toHashtable

public final java.util.Hashtable toHashtable()
Return a hashtable representation of this object.
Returns:
A new hashtable.

toString

public final java.lang.String toString()
Returns a String representation of this MessageHashtable and of the included values.
Returns:
A String representation of this MessageHashtable and of the included values.
Overrides:
toString in class java.lang.Object