com.wm.util
Class Values

java.lang.Object
  extended by com.wm.util.Values
All Implemented Interfaces:
IData, Codable, java.io.Serializable
Direct Known Subclasses:
Session

public class Values
extends java.lang.Object
implements IData, Codable, java.io.Serializable

The Values class has been replaced by the com.wm.data.IData interface and other classes in the com.wm.data package.

Important! Do not use java.io.Serializable from this class, because it is not compatible across versions of the webMethods Integration Server. You can serialize Values objects and maintain compatibility across versions by using com.wm.util.coder.XMLCoder or, for webMethods Integration Server 3.5 and above, com.wm.util.coder.IDataXMLCoder.

Values is a subclass that emulates a Hashtable but has four key differentiators:

Note: equals() will fail for Vectors passed via RPC

See Also:
IData, Coder, Serialized Form

Constructor Summary
Values()
           
Values(java.util.Hashtable h)
          Create a Values object by copying elements and keys from a given Hashtable.
Values(int size)
          Create a Values Object with the specified size.
Values(java.lang.Object[][] values)
          Create a Values Object and pre-fills it with the designated array of Objects.
 
Method Summary
 java.lang.Object clone()
          Performs a shallow clone of a Values object.
 Values copyFrom(java.util.Hashtable v)
          Copies the elements from the given Hashtable object into the current Values object.
 Values copyFrom(Values v)
          Copies the elements from the given Values object into the current Values object.
 boolean equals(java.lang.Object in)
          Tests two Values objects for equality.
 java.lang.Object get(int index)
          Returns an object given its position in the Values object.
 java.lang.Object get(java.lang.String key)
          Deprecated.  
 boolean getBoolean(java.lang.String key)
          Helper function that returns the value as a 'boolean' if its String value is parsable as a boolean.
 int getInt(java.lang.String key)
          Helper function that returns the value as an 'int' if its String value is parsable as an int.
 int getInt(java.lang.String key, int def)
          Helper function that returns the value as an 'int' if its String value is parsable as an int.
 long getLong(java.lang.String key)
          Helper function that returns the value as a 'long' if its String value is parsable as a long.
 long getLong(java.lang.String key, long def)
          Helper function that returns the value as a 'long' if its String value is parsable as a long.
 java.lang.String getNonEmptyString(java.lang.String key)
          Helper function that returns the value as a non-empty String (i.e., not all whitespace).
 java.lang.String getString(java.lang.String key)
          Helper function that returns the value as a String if it is a String.
 java.lang.String[] getStringArray(java.lang.String key)
          Helper function that returns the value as a String[] if it is a String[].
 java.lang.String[][] getStringTable(java.lang.String key)
          Helper function that returns the value as a String[][] if it is a String[][].
 java.lang.String getTrimmedString(java.lang.String key)
          Helper function that returns the value as a trimmed String (i.e., no leading or trailing whitespace).
 Values getValues(java.lang.String key)
          Helper function that returns the value as a Values object if it is a Values.
 Values[] getValuesArray(java.lang.String key)
          Helper function that returns the value as a Values[] object if it is a Values[] or Table.
 int hashCode()
          Calculates a hash value for this Values object.
 boolean isEmpty()
          Returns true if there are no elements in this Values object.
 java.lang.Object put(java.lang.Object value)
          Adds an "unnamed" object which can be retrieved by a positional get(int).
 java.lang.Object put(java.lang.String key, int value)
          put() which converts int value to a String object.
 java.lang.Object put(java.lang.String key, long value)
          put() which converts long value to a String object.
 java.lang.Object put(java.lang.String key, java.lang.Object value)
          Deprecated.  
 java.lang.Object remove(java.lang.String key)
          Deprecated.  
 java.util.Enumeration sortedKeys()
          Returns an Enumeration of the sorted keys (names) in this Values object.
 java.lang.String toString()
          Display the contents of this Values object.
static Values use(IData data)
          Deprecated.  
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.wm.data.IData
getCursor, getHashCursor, getIndexCursor, getSharedCursor, getTreeCursor
 
Methods inherited from interface com.wm.util.coder.Codable
getValue, getValueKeys, setValue
 

Constructor Detail

Values

public Values()

Values

public Values(java.util.Hashtable h)
Create a Values object by copying elements and keys from a given Hashtable.


Values

public Values(int size)
Create a Values Object with the specified size.


Values

public Values(java.lang.Object[][] values)
Create a Values Object and pre-fills it with the designated array of Objects. A typical use goes something like this:
   Object o[][] = {
     { "key1", new Integer(123) } ,
     { "key2", "This is a string" },
     { "key3", new Object() }
   }

   Values v = new Values(o);
 
Note that the Object array is a two dimensional array where the first column is constrained to String values. Using anything other than Strings in the first column will result in a ClassCastException being thrown.

Method Detail

put

public java.lang.Object put(java.lang.Object value)
Adds an "unnamed" object which can be retrieved by a positional get(int).


put

public java.lang.Object put(java.lang.String key,
                            int value)
put() which converts int value to a String object.


put

public java.lang.Object put(java.lang.String key,
                            long value)
put() which converts long value to a String object.


getValues

public Values getValues(java.lang.String key)
Helper function that returns the value as a Values object if it is a Values. Returns null otherwise.


getValuesArray

public Values[] getValuesArray(java.lang.String key)
Helper function that returns the value as a Values[] object if it is a Values[] or Table. Returns null otherwise.


getString

public java.lang.String getString(java.lang.String key)
Helper function that returns the value as a String if it is a String. Returns null if null and the Objects toString() method if it is not a String.


getNonEmptyString

public java.lang.String getNonEmptyString(java.lang.String key)
Helper function that returns the value as a non-empty String (i.e., not all whitespace).


getTrimmedString

public java.lang.String getTrimmedString(java.lang.String key)
Helper function that returns the value as a trimmed String (i.e., no leading or trailing whitespace).


getStringArray

public java.lang.String[] getStringArray(java.lang.String key)
Helper function that returns the value as a String[] if it is a String[]. Returns null otherwise.


getStringTable

public java.lang.String[][] getStringTable(java.lang.String key)
Helper function that returns the value as a String[][] if it is a String[][]. Returns null otherwise.


getInt

public int getInt(java.lang.String key)
Helper function that returns the value as an 'int' if its String value is parsable as an int. Returns -1 if null or not parsable.


getInt

public int getInt(java.lang.String key,
                  int def)
Helper function that returns the value as an 'int' if its String value is parsable as an int. Returns default value (def) if null or not parsable.


getLong

public long getLong(java.lang.String key)
Helper function that returns the value as a 'long' if its String value is parsable as a long. Returns -1 if null or not parsable.


getLong

public long getLong(java.lang.String key,
                    long def)
Helper function that returns the value as a 'long' if its String value is parsable as a long. Returns default value (def) if null or not parsable.


getBoolean

public boolean getBoolean(java.lang.String key)
Helper function that returns the value as a 'boolean' if its String value is parsable as a boolean. Returns false if null or not parsable.


get

public java.lang.Object get(int index)
Returns an object given its position in the Values object.

Parameters:
index - Index of element (from its put order)

isEmpty

public boolean isEmpty()
Returns true if there are no elements in this Values object.

See Also:
Hashtable.isEmpty()

sortedKeys

public java.util.Enumeration sortedKeys()
Returns an Enumeration of the sorted keys (names) in this Values object. Keys added after calling this method will not be enumerated.

Returns:
an Enumeration of String keys

hashCode

public int hashCode()
Calculates a hash value for this Values object.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object in)
Tests two Values objects for equality. The Values are equal if they pass the following tests:

Overrides:
equals in class java.lang.Object

clone

public java.lang.Object clone()
Performs a shallow clone of a Values object.

Duplicates all key and element references, but not the actual data elements (nor the private data).

Overrides:
clone in class java.lang.Object
See Also:
Hashtable.clone()

copyFrom

public Values copyFrom(Values v)
Copies the elements from the given Values object into the current Values object.


copyFrom

public Values copyFrom(java.util.Hashtable v)
Copies the elements from the given Hashtable object into the current Values object.


get

public java.lang.Object get(java.lang.String key)
Deprecated. 


put

public java.lang.Object put(java.lang.String key,
                            java.lang.Object value)
Deprecated. 


remove

public java.lang.Object remove(java.lang.String key)
Deprecated. 


use

public static Values use(IData data)
Deprecated. 


toString

public java.lang.String toString()
Display the contents of this Values object. Synchronized to be thread-safe.

Overrides:
toString in class java.lang.Object