com.rubecula.util
Class AttrMap

java.lang.Object
  |
  +--java.util.AbstractMap
        |
        +--java.util.HashMap
              |
              +--com.rubecula.util.AlphabeticalMap
                    |
                    +--com.rubecula.util.AttrMap
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class AttrMap
extends AlphabeticalMap

Class to define an Attribute Map for customizing the presentation of objects, particularly objects of the JQuantity package.

Version:
$Revision: 1.6 $
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
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
static java.lang.String $AttrBoolNormalize
          String: Normalize.
static java.lang.String $AttrBoolRound
          String: Round
static java.lang.String $AttrBoolSymbolic
          String: ForceReal
static java.lang.String $AttrBoolZero
          String: Zero
static java.lang.String $AttrDoubleTolerance
          String: Tolerance
static java.lang.String $AttrIntPlaces
          String: Places
static java.lang.String $AttrIntRadix
          String: Radix
static java.lang.String $AttrStrDecimal
          String: Decimal
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()
           
 
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 java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, 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

$AttrBoolNormalize

public static final java.lang.String $AttrBoolNormalize
String: Normalize. Currently this is somewhat ambiguous - different classes use it to mean different things.

See Also:
Constant Field Values

$AttrBoolRound

public static final java.lang.String $AttrBoolRound
String: Round

See Also:
Constant Field Values

$AttrBoolZero

public static final java.lang.String $AttrBoolZero
String: Zero

See Also:
Constant Field Values

$AttrIntPlaces

public static final java.lang.String $AttrIntPlaces
String: Places

See Also:
Constant Field Values

$AttrIntRadix

public static final java.lang.String $AttrIntRadix
String: Radix

See Also:
Constant Field Values

$AttrDoubleTolerance

public static final java.lang.String $AttrDoubleTolerance
String: Tolerance

See Also:
Constant Field Values

$AttrStrDecimal

public static final java.lang.String $AttrStrDecimal
String: Decimal

See Also:
Constant Field Values

$AttrBoolSymbolic

public static final java.lang.String $AttrBoolSymbolic
String: ForceReal

See Also:
Constant Field Values
Constructor Detail

AttrMap

public AttrMap()
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, if key is $AttrNormalize return false; else if key is $AttrRound or $AttrZeroreturn true; failing that, 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: if key is $AttrPlaces, then -1 (show all places); else if key is $AttrRadix, then 10; otherwise, 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: if key is $AttrDecimal, then "."; otherwise, 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.