com.rubecula.util
Class AttrMap

java.lang.Object
  extended byjava.util.AbstractMap
      extended byjava.util.HashMap
          extended bycom.rubecula.util.StringMap
              extended bycom.rubecula.util.AlphabeticalMap
                  extended bycom.rubecula.util.AttrMap
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable
Direct Known Subclasses:
Attributes

public class AttrMap
extends AlphabeticalMap

Class to define an Attribute Map an application.

Since:
V_0_2
Version:
$Revision: 1.10 $
Author:
Robin Hillyard
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.util.HashMap
 
Nested classes inherited from class java.util.AbstractMap
 
Field Summary
static java.lang.String $ValueOff
          String: Off
static java.lang.String $ValueOn
          String: On
 
Fields inherited from class java.util.HashMap
 
Fields inherited from class java.util.AbstractMap
 
Constructor Summary
AttrMap()
          Construct an empty AttrMap.
 
Method Summary
 double getDouble(java.lang.String key)
          Method to determine for this map the double value of the attribute defined by key, or if the attribute is not present, a default value, determined according to the value of key.
 double getDouble(java.lang.String key, double defaultValue)
          Method to determine for this map the double value of the attribute defined by key, or if the key is not present, the default value.
 int getInt(java.lang.String key)
          Method to determine for this map the integer value of the attribute defined by key, or if the attribute is not present, a default value, determined according to the value of key.
 int getInt(java.lang.String key, int defaultValue)
          Method to determine for this map the integer value of the attribute defined by key, or if the key is not present, the default value.
 java.lang.String getString(java.lang.String key)
          Method to determine for this map the string value of the attribute defined by key, or if the attribute is not present, a default value, determined according to the value of key.
 java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
          Method to determine for this map the string value of the attribute defined by key, or if the key is not present, the default value.
 boolean isOn(java.lang.String key)
          Method to determine if this map has the attribute defined by key turned on, or if the key is not present, return a default value based on the key.
 boolean isOn(java.lang.String key, boolean defaultValue)
          Method to determine if this map has the attribute defined by key turned on, or if the key is not present, return the default value.
 void setBoolean(java.lang.String key, boolean value)
          Method to set int attribute defined by key.
 void setDouble(java.lang.String key, double value)
          Method to set int attribute defined by key.
 void setInt(java.lang.String key, int value)
          Method to set int attribute defined by key.
 
Methods inherited from class com.rubecula.util.AlphabeticalMap
contains, get, merge, put, toString
 
Methods inherited from class com.rubecula.util.StringMap
get, put, put
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, isEmpty, keySet, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

$ValueOn

public static final java.lang.String $ValueOn
String: On

See Also:
Constant Field Values

$ValueOff

public static final java.lang.String $ValueOff
String: Off

See Also:
Constant Field Values
Constructor Detail

AttrMap

public AttrMap()
Construct an empty AttrMap.

See Also:
AlphabeticalMap.AlphabeticalMap()
Method Detail

isOn

public boolean isOn(java.lang.String key,
                    boolean defaultValue)
Method to determine if this map has the attribute defined by key turned on, or if the key is not present, return the default value.

Parameters:
key - the attribute being sought.
defaultValue - the value to return if this map does not contain key, or if the stored value is null.
Returns:
true if the attribute defined by key is turned on or, if the attribute is not present in the map (or has a null value), then return the default value.

isOn

public boolean isOn(java.lang.String key)
Method to determine if this map has the attribute defined by key turned on, or if the key is not present, return a default value based on the key.

Parameters:
key - the attribute being sought.
Returns:
if this map contains key, then its "on" state is returned, defaulting to true; otherwise, return false.

getInt

public int getInt(java.lang.String key,
                  int defaultValue)
Method to determine for this map the integer value of the attribute defined by key, or if the key is not present, the default value. This method is parallel to isOn(String,boolean).

Parameters:
key - the attribute being sought.
defaultValue - the value to return if this map does not contain key.
Returns:
the integer value of the attribute defined by key or, if the attribute is not present in the map, then return the default value.

getInt

public int getInt(java.lang.String key)
Method to determine for this map the integer value of the attribute defined by key, or if the attribute is not present, a default value, determined according to the value of key. This method is parallel to isOn(String).

Parameters:
key - the attribute being sought.
Returns:
the integer value of the attribute defined by key or, if the attribute is not present in the map, then: return 0.

getDouble

public double getDouble(java.lang.String key,
                        double defaultValue)
Method to determine for this map the double value of the attribute defined by key, or if the key is not present, the default value. This method is parallel to isOn(String,boolean).

Parameters:
key - the attribute being sought.
defaultValue - the value to return if this map does not contain key.
Returns:
the double value of the attribute defined by key or, if the attribute is not present in the map, then return the default value.

getDouble

public double getDouble(java.lang.String key)
Method to determine for this map the double value of the attribute defined by key, or if the attribute is not present, a default value, determined according to the value of key. This method is parallel to isOn(String).

Parameters:
key - the attribute being sought.
Returns:
the double value of the attribute defined by key or, if the attribute is not present in the map, then: return 0.

getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.String defaultValue)
Method to determine for this map the string value of the attribute defined by key, or if the key is not present, the default value. This method is parallel to isOn(String,boolean).

Parameters:
key - the attribute being sought.
defaultValue - the value to return if this map does not contain key.
Returns:
the string value of the attribute defined by key or, if the attribute is not present in the map, then return the default value.

getString

public java.lang.String getString(java.lang.String key)
Method to determine for this map the string value of the attribute defined by key, or if the attribute is not present, a default value, determined according to the value of key. This method is parallel to isOn(String).

Parameters:
key - the attribute being sought.
Returns:
the string value of the attribute defined by key or, if the attribute is not present in the map, then: return null.

setBoolean

public void setBoolean(java.lang.String key,
                       boolean value)
Method to set int attribute defined by key.

Parameters:
key - the attribute being set.
value - the value to set.

setInt

public void setInt(java.lang.String key,
                   int value)
Method to set int attribute defined by key.

Parameters:
key - the attribute being set.
value - the value to set.

setDouble

public void setDouble(java.lang.String key,
                      double value)
Method to set int attribute defined by key.

Parameters:
key - the attribute being set.
value - the value to set.