com.wm.data
Class ValuesEmulator

java.lang.Object
  extended by com.wm.data.ValuesEmulator

public class ValuesEmulator
extends java.lang.Object

This class allows you to use the syntax like that of webMethods deprecated Values object to manipulate data in the pipeline using the IData structure. (Internally, this class manipulates data using IData methods.) This class is provided as a convenience for quick conversion of old code to the new data structure and for the development of small, noncomplex services in cases where you do not have time to learn and implement the new IData structure. It not meant to be used in place of IData and its cursor classes. It should not be used to build complex, mission-critical solutions.

See Also:
IData

Constructor Summary
ValuesEmulator()
           
 
Method Summary
static java.util.Enumeration elements(IData data)
          Enumerates the values in the specified IData object.
static java.lang.Object get(IData pipeline, java.lang.String key)
          Gets the value from the specified key.
static boolean getBoolean(IData pipeline, java.lang.String key)
          Returns a boolean value indicating the value of a specified key.
static int getInt(IData pipeline, java.lang.String key)
          Returns the value of the specified key as an int.
static int getInt(IData pipeline, java.lang.String key, int def)
          Returns the value of the specified key as a int or returns a default value if that element is not an int or cannot be converted to an int.
static java.lang.String[] getKeys(IData data)
          Returns a string array containing the names of keys in the specified IData object.
static java.lang.String getNonEmptyString(IData pipeline, java.lang.String key)
          Returns a String representation of the value at the specified key only if that key contains a non-whitespace value.
static java.lang.String getString(IData pipeline, java.lang.String key)
          Returns a String representation of the value at the specified key.
static java.lang.String[] getStringArray(IData pipeline, java.lang.String key)
          Returns the value of the specified key as a String [].
static Values getValues(IData pipeline, java.lang.String key)
          Returns the value of the specified key as a Values object.
static java.util.Enumeration keys(IData data)
          Enumerates the keys in the specified IData object.
static java.lang.Object put(IData pipeline, java.lang.String key, int value)
          Adds the specified int to an IData object at the specified key.
static java.lang.Object put(IData pipeline, java.lang.String key, java.lang.Object value)
          Adds the specified Object to an IData object at the specified key.
static java.lang.Object remove(IData pipeline, java.lang.String key)
          Removes the specified element from the IData object.
static int size(IData data)
          Returns the size of the IData object (that is, the number of key/value pairs in the IData structure).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValuesEmulator

public ValuesEmulator()
Method Detail

get

public static java.lang.Object get(IData pipeline,
                                   java.lang.String key)
Gets the value from the specified key.

Parameters:
pipeline - The IData object that contains the value you want to retrieve.
key - A String specifying the key whose value you want to retrieve.
Returns:
An Object containing the value of the specified key.

getString

public static java.lang.String getString(IData pipeline,
                                         java.lang.String key)
Returns a String representation of the value at the specified key. If the key is null, then null is returned. If the key contains only whitespace characters, getString returns an object containing those characters. If you want a null returned if the key contains only whitespace characters, use getNonEmptyString instead.

Parameters:
pipeline - The IData object that contains the value you want to retrieve.
key - A String specifying the key whose value you want to retrieve.
Returns:
A String containing a string representation of the value at the specified key or null if the element is null.
See Also:
getNonEmptyString(com.wm.data.IData, java.lang.String)

getNonEmptyString

public static java.lang.String getNonEmptyString(IData pipeline,
                                                 java.lang.String key)
Returns a String representation of the value at the specified key only if that key contains a non-whitespace value. If the key is null or contains only whitespace characters, then getNonEmptyString returns null. If you want to receive values that contain only whitespace characters, use getString instead.

Parameters:
pipeline - The IData object that contains the value you want to retrieve.
key - A String specifying the key whose value you want to retrieve.
Returns:
A String containing the value of the specified key or null if the key is null or contains only whitespace characters.
See Also:
getString(com.wm.data.IData, java.lang.String)

getStringArray

public static java.lang.String[] getStringArray(IData pipeline,
                                                java.lang.String key)
Returns the value of the specified key as a String []. If the key does not contain a string array, getStringArray returns null.

Parameters:
pipeline - The IData object containing the value you want to retrieve.
key - A String specifying the key whose value you want to retrieve.
Returns:
A String [] containing the value of the specified key or null if that key does not contain a string array.

getValues

public static Values getValues(IData pipeline,
                               java.lang.String key)
Returns the value of the specified key as a Values object. If the key does not contain a Values object, getValues returns null.

Parameters:
pipeline - The IData object containing the value you want to retrieve.
key - A String specifying the key whose value you want to retrieve.
Returns:
A Values object containing the value of the specified key or null if that key does not contain a Values object.

getBoolean

public static boolean getBoolean(IData pipeline,
                                 java.lang.String key)
Returns a boolean value indicating the value of a specified key.

Parameters:
pipeline - The IData object containing the value you want to retrieve.
key - A String specifying the key whose value you want to retrieve.
Returns:
A boolean indicating the value of the specified key as follows:

Returns…
If…
true Key contains a Boolean object that is "true"
-OR-
Key contains a String that has the value "true" (any case)
false Key contains a Boolean object that is "false"
-OR-
Key contains a object with any value other than "true"
-OR-
Key does not contain a String or a Boolean object

getInt

public static int getInt(IData pipeline,
                         java.lang.String key)
Returns the value of the specified key as an int. If the key does not contain an int or does not contain a value that can be parsed into an int, getInt returns -1 (negative one).

Parameters:
pipeline - The IData object containing the value you want to retrieve.
key - A String specifying the key whose value you want to retrieve.
Returns:
An int containing the value of the specified key or null if that key does not contain an int or cannot be converted to an int.
See Also:
getInt(IData, String, int)

getInt

public static int getInt(IData pipeline,
                         java.lang.String key,
                         int def)
Returns the value of the specified key as a int or returns a default value if that element is not an int or cannot be converted to an int.

Parameters:
pipeline - The IData object containing the value you want to retrieve.
key - A String specifying the key whose value you want to retrieve.
def - The int value that getInt will return if the specified key is null or cannot be converted to an int.
Returns:
An int containing the value of the specified key or -1 if that key is null, does not contain an int, or cannot be converted to an int.
See Also:
getInt(IData, String)

remove

public static java.lang.Object remove(IData pipeline,
                                      java.lang.String key)
Removes the specified element from the IData object. Returns the removed element as an object.

Parameters:
pipeline - The IData object containing the value that you want to delete.
key - A String specifying the key of the element that you want to delete.
Returns:
An Object containing the value of the element that was removed from the pipeline.

put

public static java.lang.Object put(IData pipeline,
                                   java.lang.String key,
                                   java.lang.Object value)
Adds the specified Object to an IData object at the specified key. If the specified key does not exist in the IData object, the Object is appended to the end of the IData object. If the key exists, the new Object replaces the existing element and put returns the original value as an Object.

Parameters:
pipeline - The IData object into which you want to add an element.
key - A String specifying the new element's key.
value - The Object that is to be added at the specified key.
Returns:
null if value is added as a new element. An Object containing the key's original value if value replaced an existing element.

put

public static java.lang.Object put(IData pipeline,
                                   java.lang.String key,
                                   int value)
Adds the specified int to an IData object at the specified key. If the specified key does not exist in the IData object, the int is appended as a new element at the end of the IData object. If the key exists, the int replaces the existing element and put returns that element's original value as an Object. param pipeline The IData object into which you want to add an element.

Parameters:
key - A String specifying the new element's key.
value - The int that is to be added as the value of the specified key.
Returns:
null if value was added as a new element; or an Object containing the key's original value if value replaced an existing element.

size

public static int size(IData data)
Returns the size of the IData object (that is, the number of key/value pairs in the IData structure). param data The IData object whose size you want to obtain.

Returns:
An int that indicates the number elements in the specified IData object.

keys

public static java.util.Enumeration keys(IData data)
Enumerates the keys in the specified IData object.

param data The IData object whose keys you want enumerated.

Returns:
An Enumeration containing the names of the keys in the specified IData object.

elements

public static java.util.Enumeration elements(IData data)
Enumerates the values in the specified IData object. param data The IData object whose values you want enumerated.

Returns:
An Enumeration containing the values of key in the specified IData object.

getKeys

public static java.lang.String[] getKeys(IData data)
Returns a string array containing the names of keys in the specified IData object.

Parameters:
data - the IData object whose keys you want to obtain.
Returns:
a String[] containing the names of the keys in the specified IData object.