com.ibm.commerce.datatype
Class TypedProperty

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--com.ibm.commerce.datatype.TypedProperty
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class TypedProperty
extends java.util.Hashtable
implements java.io.Serializable

TypedProperties extends java.util.Hashtable. It provides additional methods for retrieving properties such as java.lang.Integer, java.lang.Double, java.lang.Float, java.lang.String instead of java.lang.Object.

See Also:
Serialized Form

Field Summary
static java.lang.String COPYRIGHT
          The IBM Copyright notice field.
protected static UrlParamMapperFile urlMapperFile
          The URL parameter mapping file for converting ECML parameters to a WebSphere Commerce parameter name.
protected  java.util.Hashtable urlNameMapper
          The mapping between ECML URL parameter names and WebSphere Commerce URL parameter names.
 
Constructor Summary
TypedProperty()
          Creates the typed property object.
TypedProperty(java.util.Hashtable hTP)
          Creates a typed property object from the given hashtable.
TypedProperty(int initialCapacity)
          Creates the typed property object.
TypedProperty(int initialCapacity, float loadFactor)
          Creates the typed property object.
 
Method Summary
static  TypedProperty createTextResponse(java.lang.String textResponse)
          Deprecated. Use the static method of same name defined in AbtractDirectViewCommand.
 java.lang.Object get(java.lang.String key)
          Returns the value associated with the key specified.
 java.lang.Object get(java.lang.String key, java.lang.Object def)
          Returns the value associated with the specified key.
 java.lang.String[] getArray(java.lang.String key)
          Returns the value associated with the key as a String array object.
 java.lang.String[] getArray(java.lang.String key, java.lang.String[] def)
          Returns the value associated with the key as a String array.
 java.math.BigDecimal getBigDecimal(java.lang.String key)
          Returns the value associated with the key as a BigDecimal object.
 java.math.BigDecimal getBigDecimal(java.lang.String key, java.math.BigDecimal def)
          Returns the value associated with the key as a BigDecimal object.
 boolean getBoolean(java.lang.String key)
          Returns the value associated with the key as a boolean value.
 boolean getBoolean(java.lang.String key, boolean def)
          Returns the value associated with the key as a boolean value.
 java.lang.Double getDouble(java.lang.String key)
          Returns the value associated with the key as a Double object.
 java.lang.Double getDouble(java.lang.String key, double def)
          Returns the value associated with the key as a Double object.
 java.lang.Double getDouble(java.lang.String key, java.lang.Double def)
          Returns the value associated with the key as a Double object.
 double getDoubleValue(java.lang.String key)
          Returns the value associated with the key as a double.
 double getDoubleValue(java.lang.String key, double def)
          Returns the value associated with the key as a double.
 java.lang.Float getFloat(java.lang.String key)
          Returns the value associated with the key as a Float object.
 java.lang.Float getFloat(java.lang.String key, float def)
          Returns the value associated with the key as a Float object.
 java.lang.Float getFloat(java.lang.String key, java.lang.Float def)
          Returns the value associated with the key as a Float object.
 float getFloatValue(java.lang.String key)
          Returns the value associated with the key as a type of float.
 float getFloatValue(java.lang.String key, float def)
          Returns the value associated with the key as a type of float.
 java.lang.Integer getInteger(java.lang.String key)
          Returns the value associated with the key as an Integer object.
 java.lang.Integer getInteger(java.lang.String key, int def)
          Returns the value associated with the key as an Integer object.
 java.lang.Integer getInteger(java.lang.String key, java.lang.Integer def)
          Returns the value associated with the key as an Integer object.
 java.lang.String getIntParamName(java.lang.String key)
          Returns the corresponding Electronic Commerce Modeling Language (ECML) version of the parameter name.
 int getIntValue(java.lang.String key)
          Returns the value associated with the key as an integer.
 int getIntValue(java.lang.String key, int def)
          Returns the value associated with the key as an integer.
 java.lang.Long getLong(java.lang.String key)
          Returns the value associated with the key as a Long object.
 java.lang.Long getLong(java.lang.String key, long def)
          Returns the value associated with the key as a Long object.
 java.lang.Long getLong(java.lang.String key, java.lang.Long def)
          Returns the value associated with the key as a Long object.
 java.lang.Long[] getLongArray(java.lang.String key)
          Returns the value associated with the key as a Long object array.
 java.lang.Long[] getLongArray(java.lang.String key, java.lang.Long[] def)
          Returns the value associated with the key as a Long object array.
 long getLongValue(java.lang.String key)
          Returns the value associated with the key as type long.
 long getLongValue(java.lang.String key, long def)
          Returns the value associated with the key as type long.
 java.lang.String getQueryString()
          Returns the query string representation of the parameters stored in the typed property object.
 java.lang.Short getShort(java.lang.String key)
          Returns the value associated with the key as a Short object.
 java.lang.Short getShort(java.lang.String key, short def)
          Returns the value associated with the key as a Short object.
 java.lang.Short getShort(java.lang.String key, java.lang.Short def)
          Returns the value associated with the key as a Short object.
 short getShortValue(java.lang.String key)
          Returns the value associated with the key as a short primitive.
 short getShortValue(java.lang.String key, short def)
          Returns the value associated with the key as a short primitive.
 java.lang.String getString(java.lang.String key)
          Returns the value associated with the key as a String object.
 java.lang.String getString(java.lang.String key, java.lang.String def)
          Returns the value associated with the key as a String object.
 java.lang.Object getUrlParam(java.lang.String key)
          Returns the value associated with the URL parameter name.
 java.lang.String getUrlParamName(java.lang.String key)
          Returns the parameter name of the parameter.
static void initUrlParamNameMapper(UrlParamMapperFile mapper)
          Initializes the URL mapping file which maps the WebSphere Commerce server parameter names to the Electronic Commerce Modeling Language (ECML) version of the parameter names.
 void putUrlParam(java.lang.String key, java.lang.Object obj)
          Add a new property using the URL parameter name as a key.
 java.lang.String toProtectedString()
          Returns a string that represents that context of the current object.
 java.lang.String toString()
          Return a string that represents that information stored in the current object.
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail
public static final java.lang.String COPYRIGHT
The IBM Copyright notice field.
See Also:
Constant Field Values

urlMapperFile

protected static UrlParamMapperFile urlMapperFile
The URL parameter mapping file for converting ECML parameters to a WebSphere Commerce parameter name.

urlNameMapper

protected java.util.Hashtable urlNameMapper
The mapping between ECML URL parameter names and WebSphere Commerce URL parameter names.
Constructor Detail

TypedProperty

public TypedProperty()
Creates the typed property object.

TypedProperty

public TypedProperty(int initialCapacity)
Creates the typed property object.
Parameters:
initialCapacity - The number of objects that are stored in the typed property.

TypedProperty

public TypedProperty(int initialCapacity,
                     float loadFactor)
Creates the typed property object.
Parameters:
initialCapacity - The number of objects that are stored in the typed property.
loadFactor - The load factor to increase the size of the number of elements to store.

TypedProperty

public TypedProperty(java.util.Hashtable hTP)
Creates a typed property object from the given hashtable.
Method Detail

createTextResponse

public static TypedProperty createTextResponse(java.lang.String textResponse)
Deprecated. Use the static method of same name defined in AbtractDirectViewCommand.
Prepares a TypedProperty object for sending a text response. This is done by adding the additional values to the typed property object for calling the DirectView.
Parameters:
textResponse - The text to be returned.
Returns:
A TypedProperty representation of the given text.

get

public java.lang.Object get(java.lang.String key)
                     throws ParameterNotFoundException
Returns the value associated with the key specified.
Parameters:
key - The key of the parameter to find.
Returns:
the value of the specified key.
Throws:
ParameterNotFoundException - if the parameter does not exist in the typed property object.

get

public java.lang.Object get(java.lang.String key,
                            java.lang.Object def)
Returns the value associated with the specified key. If the value does not exist, the default value is returned.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the key specified or the defect value if the key cannot be found.

getArray

public java.lang.String[] getArray(java.lang.String key)
                            throws ParameterNotFoundException,
InvalidParameterValueException
Returns the value associated with the key as a String array object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter of the type String array.
Throws:
InvalidParameterValueException - if the parameter is not an Array object.
ParameterNotFoundException - if the parameter is not found in the typed property object.

getArray

public java.lang.String[] getArray(java.lang.String key,
                                   java.lang.String[] def)
Returns the value associated with the key as a String array. If the value cannot be found, the default value specified is returned.
Parameters:
key - The key of the parameter to find.
Returns:
A String array of the specified parameter. If the parameter does not exist or cannot be converted to a String array, the default value specified is returned.

getBigDecimal

public java.math.BigDecimal getBigDecimal(java.lang.String key)
                                   throws ParameterNotFoundException,
InvalidParameterValueException
Returns the value associated with the key as a BigDecimal object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the specified parameter of type BigDecimal.
Throws:
InvalidParameterValueException - the value cannot be converted to a BigDecimal.
ParameterNotFoundException - the specified parameter does not exist.

getBigDecimal

public java.math.BigDecimal getBigDecimal(java.lang.String key,
                                          java.math.BigDecimal def)
Returns the value associated with the key as a BigDecimal object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the specified parameter of type BigDecimal. If the value cannot be found or converted into a BigDecimal object, the the default value specified is returned.

getBoolean

public boolean getBoolean(java.lang.String key)
                   throws ParameterNotFoundException
Returns the value associated with the key as a boolean value.
Parameters:
key - The key of the parameter to find.
Returns:
The boolean value of the specified parameter.
Throws:
ParameterNotFoundException - if the parameter specified cannot be found.

getBoolean

public boolean getBoolean(java.lang.String key,
                          boolean def)
Returns the value associated with the key as a boolean value.
Parameters:
key - The key of the parameter to find.
Returns:
The boolean value of the specified parameter. If the parameter cannot be found, the default value specified is returned.

getDouble

public java.lang.Double getDouble(java.lang.String key)
                           throws ParameterNotFoundException,
InvalidParameterValueException
Returns the value associated with the key as a Double object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the specified parameter as a Double object.
Throws:
InvalidParameterValueException - if the value cannot be converted to a Double object.
ParameterNotFoundException - if the parameter cannot be found.

getDouble

public java.lang.Double getDouble(java.lang.String key,
                                  double def)
Returns the value associated with the key as a Double object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a Double object. If the parameter cannot be found or converted to a Double object, the default value is returned.

getDouble

public java.lang.Double getDouble(java.lang.String key,
                                  java.lang.Double def)
Returns the value associated with the key as a Double object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a Double object. If the parameter cannot be found or converted to a Double object, the default value is returned.

getDoubleValue

public double getDoubleValue(java.lang.String key)
                      throws ParameterNotFoundException
Returns the value associated with the key as a double.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a double.
Throws:
java.lang.NumberFormatException - if the value cannot be converted to a double.
ParameterNotFoundException - if the parameter cannot be found.

getDoubleValue

public double getDoubleValue(java.lang.String key,
                             double def)
Returns the value associated with the key as a double.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a double. If the value cannot be found or converted, the default value specified is returned.

getFloat

public java.lang.Float getFloat(java.lang.String key)
                         throws ParameterNotFoundException,
InvalidParameterValueException
Returns the value associated with the key as a Float object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a Float object.
Throws:
InvalidParameterValueException - if the value cannot be converted to a Float object.
ParameterNotFoundException - if the parameter cannot be found.

getFloat

public java.lang.Float getFloat(java.lang.String key,
                                float def)
Returns the value associated with the key as a Float object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a Float object. If the value cannot be found or converted to a Float, the default value specified is returned.

getFloat

public java.lang.Float getFloat(java.lang.String key,
                                java.lang.Float def)
Returns the value associated with the key as a Float object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a Float object. If the value cannot be found or converted to a Float, the default value specified is returned.

getFloatValue

public float getFloatValue(java.lang.String key)
                    throws ParameterNotFoundException,
InvalidParameterValueException
Returns the value associated with the key as a type of float.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a type of float.
Throws:
InvalidParameterValueException - if the value cannot be converted in to float
ParameterNotFoundException - if the parameter cannot be found.

getFloatValue

public float getFloatValue(java.lang.String key,
                           float def)
Returns the value associated with the key as a type of float.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a float. If the value cannot be found or converted to a float, the default value specified is returned.

getInteger

public java.lang.Integer getInteger(java.lang.String key)
                             throws ParameterNotFoundException,
InvalidParameterValueException
Returns the value associated with the key as an Integer object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as an Integer object.
Throws:
InvalidParameterValueException - if the value cannot be converted to an Integer object.
ParameterNotFoundException - if the parameter cannot be found.

getInteger

public java.lang.Integer getInteger(java.lang.String key,
                                    int def)
Returns the value associated with the key as an Integer object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as an Integer object. If the value cannot be found or converted to an Integer, the default value specified is returned.

getInteger

public java.lang.Integer getInteger(java.lang.String key,
                                    java.lang.Integer def)
Returns the value associated with the key as an Integer object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as an Integer object. If the value cannot be found or converted to an Integer, the default value specified is returned.

getIntParamName

public java.lang.String getIntParamName(java.lang.String key)
Returns the corresponding Electronic Commerce Modeling Language (ECML) version of the parameter name.
Parameters:
key - The parameter name.
Returns:
The ECML version of the parameter name.

getIntValue

public int getIntValue(java.lang.String key)
                throws ParameterNotFoundException,
InvalidParameterValueException
Returns the value associated with the key as an integer.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as an integer
Throws:
InvalidParameterValueException - if the value cannot be converted to an integer.
ParameterNotFoundException - if the parameter cannot be found.

getIntValue

public int getIntValue(java.lang.String key,
                       int def)
Returns the value associated with the key as an integer.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as an integer. If the value cannot be found or converted to an integer, the default is returned.

getLong

public java.lang.Long getLong(java.lang.String key)
                       throws ParameterNotFoundException,
InvalidParameterValueException
Returns the value associated with the key as a Long object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a Long object.
Throws:
InvalidParameterValueException - if the value cannot be converted in to a Long object.
ParameterNotFoundException - if the parameter cannot be found.

getLong

public java.lang.Long getLong(java.lang.String key,
                              long def)
Returns the value associated with the key as a Long object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a Long object. If the value cannot be found or converted to Long, the default is returned.

getLong

public java.lang.Long getLong(java.lang.String key,
                              java.lang.Long def)
Returns the value associated with the key as a Long object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a Long object. If the value cannot be found or converted to a Long, the default is returned.

getLongArray

public java.lang.Long[] getLongArray(java.lang.String key)
                              throws ParameterNotFoundException,
InvalidParameterValueException
Returns the value associated with the key as a Long object array.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a Long object array.
Throws:
InvalidParameterValueException - if the value cannot be converted in to a Long object array.
ParameterNotFoundException - if the parameter cannot be found.

getLongArray

public java.lang.Long[] getLongArray(java.lang.String key,
                                     java.lang.Long[] def)
Returns the value associated with the key as a Long object array.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a Long object array. If the value cannot be found or converted to a Long array, the default is returned.

getLongValue

public long getLongValue(java.lang.String key)
                  throws ParameterNotFoundException,
InvalidParameterValueException
Returns the value associated with the key as type long.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as type long.
Throws:
InvalidParameterValueException - if the value cannot be converted in to long primitive.
ParameterNotFoundException - if the parameter cannot be found.

getLongValue

public long getLongValue(java.lang.String key,
                         long def)
Returns the value associated with the key as type long.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a long. If the value cannot be found or converted to long primative, the default is returned.

getQueryString

public java.lang.String getQueryString()
Returns the query string representation of the parameters stored in the typed property object.
Returns:
The query string representation of the parameters stored in the typed property object.

getShort

public java.lang.Short getShort(java.lang.String key)
                         throws InvalidParameterValueException,
ParameterNotFoundException
Returns the value associated with the key as a Short object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a Short object.
Throws:
InvalidParameterValueException - if the value cannot be converted in to a Short object.
ParameterNotFoundException - if the parameter cannot be found.

getShort

public java.lang.Short getShort(java.lang.String key,
                                java.lang.Short def)
Returns the value associated with the key as a Short object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a Short object. If the value cannot be found or converted to a Short object, the default is returned.

getShort

public java.lang.Short getShort(java.lang.String key,
                                short def)
Returns the value associated with the key as a Short object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a Short object. If the value cannot be found or converted to a Short object, the default is returned.

getShortValue

public short getShortValue(java.lang.String key)
                    throws ParameterNotFoundException,
InvalidParameterValueException
Returns the value associated with the key as a short primitive.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a short primitive.
Throws:
InvalidParameterValueException - if the value cannot be converted in to a short primitive.
ParameterNotFoundException - if the parameter cannot be found.

getShortValue

public short getShortValue(java.lang.String key,
                           short def)
Returns the value associated with the key as a short primitive.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a short. If the value cannot be found or converted to a short primative, the default is returned.

getString

public java.lang.String getString(java.lang.String key)
                           throws ParameterNotFoundException
Returns the value associated with the key as a String object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a String object.
Throws:
ParameterNotFoundException - if the parameter cannot be found.

getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.String def)
Returns the value associated with the key as a String object.
Parameters:
key - The key of the parameter to find.
Returns:
The value of the parameter as a String object. If the value cannot be found or converted to a String, the default is returned.

getUrlParam

public java.lang.Object getUrlParam(java.lang.String key)
Returns the value associated with the URL parameter name. The parameter name has a Electronic Commerce Modeling Language (ECML) version that is used to to retrieve the parameter value.
Parameters:
key - The URL parameter name
Returns:
The value of the parameter. If no value is found, then null is returned.

getUrlParamName

public java.lang.String getUrlParamName(java.lang.String key)
Returns the parameter name of the parameter. If the parameter name has a corresponding Electronic Commerce Modeling Language (ECML) version, that parameter name will be returned. If the parameter does not have a corresponding ECML version, then the given parameter name will be returned.
Parameters:
key - The parameter name.
Returns:
The ECML version of the parameter name. If no ECML version exists, the given key is returned.

initUrlParamNameMapper

public static void initUrlParamNameMapper(UrlParamMapperFile mapper)
Initializes the URL mapping file which maps the WebSphere Commerce server parameter names to the Electronic Commerce Modeling Language (ECML) version of the parameter names.

putUrlParam

public void putUrlParam(java.lang.String key,
                        java.lang.Object obj)
Add a new property using the URL parameter name as a key. If the parameter name is the Electronic Commerce Modeling Language (ECML) version, it will be converted to the WebSphere Commerce server version of the name before it is stored.
Parameters:
key - The URL parameter name.
obj - the parameter value.

toProtectedString

public java.lang.String toProtectedString()
Returns a string that represents that context of the current object.
Returns:
The protected string version of the current values in the object.

toString

public java.lang.String toString()
Return a string that represents that information stored in the current object.
Overrides:
toString in class java.util.Hashtable
Returns:
A string representation of the current object.