ariba.util.core
Class PropertyTable

java.lang.Object
  extended by ariba.util.core.PropertyTable
All Implemented Interfaces:
DebugState

public class PropertyTable
extends java.lang.Object
implements DebugState

PropertyTable is an extension of a Map which provides additional convenience methods and some minor semantic changes. For example, calling the setPropertyForKey method with a null value removes the value for the given key from the PropertyTable. There are also convenience methods for returning a property as a particular type; if the value stored in the PropertyTable is of a different type, a reasonable conversion is done. Finally, it is possible to store a null in a property table using a special object to represent that.


Field Summary
static java.lang.String NullValueMarker
          A special object that represent a null value stored in a PropertyTable.
 
Constructor Summary
PropertyTable()
          Creates a new empty PropertyTable.
PropertyTable(java.util.Map properties)
          Creates a new PropertyTable from the given Map of properties.
 
Method Summary
 boolean booleanPropertyForKey(java.lang.String key)
          Return the property for the given key as a boolean.
 boolean containsKey(java.lang.String key)
          Returns whether the table contains a value for the given key.
 java.lang.Object debugState()
          Returns an object that will be toStringed when the debug information needs to be printed.
 double doublePropertyForKey(java.lang.String key)
          Return the property for the given key as a double.
 java.util.Iterator getAllProperties()
          Return an Iterator of all the properties stored in this table.
 int getCount()
          Return the number of properties in the table.
 java.util.Map getProperties()
          Returns the properties stored in this table as a Map.
 java.lang.Object getPropertyForKey(java.lang.String key)
          Return the property for the given key.
 int integerPropertyForKey(java.lang.String key)
          Return the property for the given key as an int.
 void setPropertyForKey(java.lang.String key, java.lang.Object value)
          Sets a property value for the given key.
 java.lang.String stringPropertyForKey(java.lang.String key)
          Return the property for the given key as a string.
 java.lang.String toString()
          Returns a string reprsentation of this table of properties.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NullValueMarker

public static final java.lang.String NullValueMarker
A special object that represent a null value stored in a PropertyTable.

See Also:
Constant Field Values
Constructor Detail

PropertyTable

public PropertyTable()
Creates a new empty PropertyTable.


PropertyTable

public PropertyTable(java.util.Map properties)
Creates a new PropertyTable from the given Map of properties.

Parameters:
properties - the properties to store in this table
Method Detail

getProperties

public java.util.Map getProperties()
Returns the properties stored in this table as a Map.

Returns:
the Map of properties

getAllProperties

public java.util.Iterator getAllProperties()
Return an Iterator of all the properties stored in this table.

Returns:
an Iterator of the properties in this table

getPropertyForKey

public java.lang.Object getPropertyForKey(java.lang.String key)
Return the property for the given key. Returns null if the given key is null, or if a null was specially inserted into the table using the NullValueMarker.

Parameters:
key - the key for the property to retrieve
Returns:
the property associated with the given key

setPropertyForKey

public void setPropertyForKey(java.lang.String key,
                              java.lang.Object value)
Sets a property value for the given key. If the value is null, the current property for the key is removed.

Parameters:
key - the key under which to store the value
value - the new value, or null to remove the current value

stringPropertyForKey

public java.lang.String stringPropertyForKey(java.lang.String key)
Return the property for the given key as a string. If the current value for the property is not a string, the toString method is called on the value. Returns null if the given key is null.

Parameters:
key - the key for the property to retrieve
Returns:
the string property associated with the given key

booleanPropertyForKey

public boolean booleanPropertyForKey(java.lang.String key)
Return the property for the given key as a boolean. If the current value for the property is not a boolean, the value is converted using the booleanValue method from the Util class. Returns null if the given key is null.

Parameters:
key - the key for the property to retrieve
Returns:
the boolean property associated with the given key

integerPropertyForKey

public int integerPropertyForKey(java.lang.String key)
Return the property for the given key as an int. If the current value for the property is not an integer, the value is converted using the intValue method from the Util class. Returns null if the given key is null.

Parameters:
key - the key for the property to retrieve
Returns:
the integer property associated with the given key

doublePropertyForKey

public double doublePropertyForKey(java.lang.String key)
Return the property for the given key as a double. If the current value for the property is not a double, the value is converted using the doubleValue method from the Util class. Returns null if the given key is null.

Parameters:
key - the key for the property to retrieve
Returns:
the double property associated with the given key

getCount

public int getCount()
Return the number of properties in the table.

Returns:
the number of properties

containsKey

public boolean containsKey(java.lang.String key)
Returns whether the table contains a value for the given key. If a null was inserted as the value using NullValueMarker, this method will return true.

Parameters:
key - the key for the property to test
Returns:
whether the table contains a value for the given key

toString

public java.lang.String toString()
Returns a string reprsentation of this table of properties.

Overrides:
toString in class java.lang.Object

debugState

public java.lang.Object debugState()
Returns an object that will be toStringed when the debug information needs to be printed.

Specified by:
debugState in interface DebugState
Returns:
an object that encapsulates the state of the current application
See Also:
ThreadDebugState.set(ariba.util.core.ThreadDebugKey, java.lang.Object)


AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.