org.hackystat.sensor.xmldata.util
Class SensorDataPropertyMap

java.lang.Object
  extended by org.hackystat.sensor.xmldata.util.SensorDataPropertyMap

public class SensorDataPropertyMap
extends java.lang.Object

Provides a thread-safe property map implementation for use as the value of the default 'pMap' field in all Sensor Data. Features of this abstract data type include:

Version:
$Id: SensorDataPropertyMap.java,v 1.1.1.1 2005/10/20 23:56:44 johnson Exp $
Author:
Philip M. Johnson

Constructor Summary
SensorDataPropertyMap()
          The default public constructor for the SensorDataPropertyMap.
SensorDataPropertyMap(java.lang.String encodedMap)
          Creates a thread-safe plist, initializing it with the contents of encodedMap.
 
Method Summary
 java.lang.String encode()
          Encodes the contents of this PropertyMap into a String that can be persisted or transmitted using Soap.
 java.lang.String formattedString()
          Returns the contents of the property map in human readable form.
 java.lang.String get(java.lang.String name)
          Gets the property value associated with name, or returns null if not found.
 java.lang.String get(java.lang.String name, java.lang.String defaultValue)
          Returns the property value associated with name, or defaultValue if not found.
static java.lang.String getDefaultMapString()
          Returns a new String representation of an empty SensorDataPropertyMap instance.
 java.lang.String getIgnoreCase(java.lang.String name)
          Returns the property value associated with name, where name is not case-sensitive.
static SensorDataPropertyMap getMap(java.lang.String encodedMap)
          Returns a new SensorDataPropertyMap instance generated from the encoded String.
 java.lang.String getRunTime()
          Returns a string containing the "runTime" attribute, or null if not found.
 java.util.Set<java.lang.String> keySet()
          Returns a set containing the keys associated with this property map.
 void put(java.lang.String name, java.lang.String value)
          Puts the (name, value) pair into the SensorDataPropertyMap.
 java.lang.String toString()
          Returns the contents of the property map in its encoded form.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SensorDataPropertyMap

public SensorDataPropertyMap()
The default public constructor for the SensorDataPropertyMap.


SensorDataPropertyMap

public SensorDataPropertyMap(java.lang.String encodedMap)
                      throws java.lang.Exception
Creates a thread-safe plist, initializing it with the contents of encodedMap.

Parameters:
encodedMap - A string produced from the encode() method.
Throws:
java.lang.Exception - If encodedMap is not a legal encoded SensorDataPropertyMap.
Method Detail

put

public void put(java.lang.String name,
                java.lang.String value)
Puts the (name, value) pair into the SensorDataPropertyMap.

Parameters:
name - The property name string.
value - The property value string.

get

public java.lang.String get(java.lang.String name)
Gets the property value associated with name, or returns null if not found.

Parameters:
name - The property name whose value is to be retrieved (if available).
Returns:
The property value associated with name, or null if not found.

getIgnoreCase

public java.lang.String getIgnoreCase(java.lang.String name)
Returns the property value associated with name, where name is not case-sensitive.

Parameters:
name - The case-insensitive property name whose value is to be retrieved.
Returns:
The property value, or null if no case-insensitive key (name) is found.

getRunTime

public java.lang.String getRunTime()
Returns a string containing the "runTime" attribute, or null if not found. Since there has been confusion involving the spelling of this attribute, this method tries both "runTime" and "runtime". If both attributes are present (almost surely an error), the value of the runTime version is returned.

Returns:
A string containing the runTime (or runtime) attribute.

get

public java.lang.String get(java.lang.String name,
                            java.lang.String defaultValue)
Returns the property value associated with name, or defaultValue if not found.

Parameters:
name - The property name whose value is to be retrieved.
defaultValue - The defaultValue to be returned if not present.
Returns:
The property value associated with name, or defaultValue if not found.

encode

public java.lang.String encode()
Encodes the contents of this PropertyMap into a String that can be persisted or transmitted using Soap. Throws a RuntimeException if an error occurs during encoding, which should be extremely rare.

Returns:
An encoded string.

toString

public java.lang.String toString()
Returns the contents of the property map in its encoded form. This is required for sensor data transmission to occur correctly.

Overrides:
toString in class java.lang.Object
Returns:
The contents of the property map in its encoded form.

formattedString

public java.lang.String formattedString()
Returns the contents of the property map in human readable form.

Returns:
The property map in human readable form.

keySet

public java.util.Set<java.lang.String> keySet()
Returns a set containing the keys associated with this property map.

Returns:
The keyset.

getMap

public static SensorDataPropertyMap getMap(java.lang.String encodedMap)
                                    throws java.lang.Exception
Returns a new SensorDataPropertyMap instance generated from the encoded String. This method supplied for use as the Converter method in the SDT definition.

Parameters:
encodedMap - The encoded version of a SensorDataPropertyMap.
Returns:
A new SensorDataPropertyMap instance.
Throws:
java.lang.Exception - If problems occur decoding the encoded string.

getDefaultMapString

public static java.lang.String getDefaultMapString()
Returns a new String representation of an empty SensorDataPropertyMap instance. This method supplied for use as the Defaulter method in the SDT definition.

Returns:
A new String encoding of an empty SensorDataPropertyMap instance.