com.ibm.wbi.util
Class DatabaseSection

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--java.util.Properties
                    |
                    +--com.ibm.wbi.util.DatabaseSection

public final class DatabaseSection
extends java.util.Properties

A DatabaseSection is a major group within a Database. Each DatabaseSection is a Properties object, with the methods of that class along with some utility methods to make using it easier for different kinds of data. These convenience methods include "get" methods that take a default value, so that the get is ensured to return a usable value. This avoids the need to check for null values after get calls.

See Also:
Serialized Form

Field Summary
static java.lang.String COPYRIGHT
          IBM copyright information.
protected static java.lang.String NEWVALUE
           
protected static java.lang.String REMOVED
           
protected static java.lang.String STATUS
           
protected static java.lang.String STORED
           
 
Fields inherited from class java.util.Properties
defaults
 
Method Summary
 boolean exists(java.lang.String key)
          Queries database to see if key exists under the passed major group.
 java.lang.Object get(java.lang.Object key)
          Returns the value object associated with the key object.
 boolean getBooleanValue(java.lang.String key)
          Get the value associated with the specified key (within the major key grouping).
 boolean getBooleanValue(java.lang.String key, boolean defaultValue)
          Get the value associated with the specified key (within the major key grouping).
 double getDoubleValue(java.lang.String key)
          Get the value associated with the specified key (within the major key grouping).
 double getDoubleValue(java.lang.String key, double defaultValue)
          Get the value associated with the specified key (within the major key grouping).
 int getIntegerValue(java.lang.String key)
          Get the value associated with the specified key (within the major key grouping).
 int getIntegerValue(java.lang.String key, int defaultValue)
          Get the value associated with the specified key (within the major key grouping).
protected  java.lang.String getInvisibleValue(java.lang.String thisKey)
          Get/set/remove the value of one of the attributes of this section that is used to control database updates, and is not supposed to be visible in the persistently stored version of the DatabaseSection.
 java.lang.String getName()
          Get the name of this major section.
 java.lang.Object getObjectValue(java.lang.String key)
          Get the value associated with the specified key (within the major key grouping).
 java.lang.Object getObjectValue(java.lang.String key, java.lang.Object defaultValue)
          Get the value associated with the specified key (within the major key grouping).
 java.lang.String getValue(java.lang.String key)
          Get the String value associated with the specified key within the DatabaseSection.
 java.lang.String getValue(java.lang.String key, java.lang.String defaultValue)
          Get the value associated with the specified key (within the major key grouping).
 java.util.Enumeration keys()
          Answers the set of keys.
protected  void removeInvisibleValue(java.lang.String thisKey)
           
 void removeValue(java.lang.String key)
          Removes the value with the specified key.
 void setBooleanValue(java.lang.String key, boolean value)
          Sets the specified key equal to the passed value.
 void setDoubleValue(java.lang.String key, double value)
          Sets the specified key equal to the passed value.
 void setIntegerValue(java.lang.String key, int value)
          Sets the specified key equal to the passed value.
protected  void setInvisibleValue(java.lang.String thisKey, java.lang.String thisValue)
           
 void setObjectValue(java.lang.String key, java.lang.Object value)
          Sets the specified key equal to the passed value.
 void setValue(java.lang.String key, boolean value)
          Sets the specified key equal to the passed value.
 void setValue(java.lang.String key, double value)
          Sets the specified key equal to the passed value.
 void setValue(java.lang.String key, int value)
          Sets the specified key equal to the passed value.
 void setValue(java.lang.String key, java.lang.Object value)
          Sets the specified key equal to the passed value.
 void setValue(java.lang.String key, java.lang.String newValue)
          Sets the specified key equal to the passed value.
 java.lang.String toString()
          Used for debugging, when it is needed to print the DatabaseSection current state.
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, load, propertyNames, save, setProperty, store
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, rehash, remove, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
IBM copyright information.

STATUS

protected static final java.lang.String STATUS

NEWVALUE

protected static final java.lang.String NEWVALUE

REMOVED

protected static final java.lang.String REMOVED

STORED

protected static final java.lang.String STORED
Method Detail

getName

public java.lang.String getName()
Get the name of this major section.
Returns:
The name of this section.

exists

public boolean exists(java.lang.String key)
Queries database to see if key exists under the passed major group.
Parameters:
key - The minor key.
Returns:
true if key exists in this section; else false if does not exist in this section. This is a convenience method, since the Properties method could be used as well.

getInvisibleValue

protected java.lang.String getInvisibleValue(java.lang.String thisKey)
Get/set/remove the value of one of the attributes of this section that is used to control database updates, and is not supposed to be visible in the persistently stored version of the DatabaseSection.

setInvisibleValue

protected void setInvisibleValue(java.lang.String thisKey,
                                 java.lang.String thisValue)

removeInvisibleValue

protected void removeInvisibleValue(java.lang.String thisKey)

get

public java.lang.Object get(java.lang.Object key)
Returns the value object associated with the key object. If key is an instance of class string this method is the same as getValue(), otherwise it uses the get()-method of its superclass (Properties). This method needed to be added because of possible NullPointer exceptions when saving the database section. This is caused by using the save()-method of the superclass Properties. That save()-method uses the keys()-method of this class which means that it returns an enumeration of decoded keys but in order to get the associated values, Properties' save()-method uses the get()-method of its superclass Hashtable. However, decoded keys can be different from the encoded keys which are stored in the actual hashtable, which can cause NullPointer exceptions. Introducing a DatabaseSection.save()-method does not solve the problem unless we create a new Properties instance and copy all the key value pairs.
Parameters:
key - The minor key
Returns:
Object associated with the key, return an empty string object if no key was found.
Overrides:
get in class java.util.Hashtable

getValue

public java.lang.String getValue(java.lang.String key)
Get the String value associated with the specified key within the DatabaseSection.
Parameters:
key - The minor key.
Returns:
Empty string if key not available; otherwise the value is returned.

getValue

public java.lang.String getValue(java.lang.String key,
                                 java.lang.String defaultValue)
Get the value associated with the specified key (within the major key grouping).
Parameters:
key - The minor key.
Returns:
defaultValue if key not available or the value is returned.

getIntegerValue

public int getIntegerValue(java.lang.String key)
Get the value associated with the specified key (within the major key grouping).
Parameters:
key - The minor key.
Returns:
0 if key not available or the value is returned.

getIntegerValue

public int getIntegerValue(java.lang.String key,
                           int defaultValue)
Get the value associated with the specified key (within the major key grouping).
Parameters:
key - The minor key.
Returns:
defaultValue if key not available or the value is returned.

getDoubleValue

public double getDoubleValue(java.lang.String key)
Get the value associated with the specified key (within the major key grouping).
Parameters:
key - The minor key.
Returns:
0 if key not available or the value is returned.

getDoubleValue

public double getDoubleValue(java.lang.String key,
                             double defaultValue)
Get the value associated with the specified key (within the major key grouping).
Parameters:
key - The minor key.
Returns:
defaultValue if key not available or the value is returned.

getBooleanValue

public boolean getBooleanValue(java.lang.String key)
Get the value associated with the specified key (within the major key grouping).
Parameters:
key - The minor key.
Returns:
false if key not available or the value is returned.

getBooleanValue

public boolean getBooleanValue(java.lang.String key,
                               boolean defaultValue)
Get the value associated with the specified key (within the major key grouping).
Parameters:
key - The minor key.
Returns:
defaultValue if key not available or the value is returned.

getObjectValue

public java.lang.Object getObjectValue(java.lang.String key)
Get the value associated with the specified key (within the major key grouping).
Parameters:
key - The minor key.
Returns:
null if key not available or the value is returned.

getObjectValue

public java.lang.Object getObjectValue(java.lang.String key,
                                       java.lang.Object defaultValue)
Get the value associated with the specified key (within the major key grouping).
Parameters:
key - The minor key.
Returns:
defaultValue if key not available or the value is returned.

setValue

public void setValue(java.lang.String key,
                     java.lang.String newValue)
Sets the specified key equal to the passed value.
Parameters:
key - The minor key.
value - The new value.

setIntegerValue

public void setIntegerValue(java.lang.String key,
                            int value)
Sets the specified key equal to the passed value.
Parameters:
key - The minor key.
value - The new value.

setValue

public void setValue(java.lang.String key,
                     int value)
Sets the specified key equal to the passed value.
Parameters:
key - The minor key.
value - The new value.

setBooleanValue

public void setBooleanValue(java.lang.String key,
                            boolean value)
Sets the specified key equal to the passed value.

setValue

public void setValue(java.lang.String key,
                     boolean value)
Sets the specified key equal to the passed value.

setDoubleValue

public void setDoubleValue(java.lang.String key,
                           double value)
Sets the specified key equal to the passed value. By default, changes are saved to persistent storage after this function call.
Parameters:
key - The minor key.
value - The new value.

setValue

public void setValue(java.lang.String key,
                     double value)
Sets the specified key equal to the passed value. By default, changes are saved to persistent storage after this function call.
Parameters:
key - The minor key.
value - The new value.

setObjectValue

public void setObjectValue(java.lang.String key,
                           java.lang.Object value)
Sets the specified key equal to the passed value. By default, changes are saved to persistent storage after this function call.
Parameters:
key - The minor key.
value - The new value.

setValue

public void setValue(java.lang.String key,
                     java.lang.Object value)
Sets the specified key equal to the passed value. By default, changes are saved to persistent storage after this function call.
Parameters:
key - The minor key.
value - The new value.

removeValue

public void removeValue(java.lang.String key)
Removes the value with the specified key. By default, changes are saved to persistent storage after this function call.
Parameters:
key - The minor key.

keys

public java.util.Enumeration keys()
Answers the set of keys.
Returns:
Enumeration the keys
Overrides:
keys in class java.util.Hashtable

toString

public java.lang.String toString()
Used for debugging, when it is needed to print the DatabaseSection current state.
Overrides:
toString in class java.util.Hashtable