com.ibm.pvccommon.util
Class DatabaseSection

java.lang.Object
  |
  +--com.ibm.pvccommon.util.DatabaseSection

public final class DatabaseSection
extends java.lang.Object

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.


Field Summary
protected static java.lang.String CHANGED_SINCE_STARTUP
           
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
           
 
Method Summary
 void clear()
          Clear the attributes
 boolean exists(java.lang.String key)
          Queries database to see if key exists under the passed major group.
 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 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 getStatus()
          Print out a string form of section.
 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).
 boolean isCoalesced(java.lang.String key)
          Answer whether the value for the given key is coalesced (i.e.
 java.util.Enumeration keys()
          Answers the set of keys.
 void list(java.io.PrintWriter writer)
          List (print) out the attributes.
 void load(java.io.InputStream inbuf)
          Load the section from the given input stream.
 java.util.Enumeration propertyNames()
          Answer the property names in this section.
protected  void removeInvisibleValue(java.lang.String thisKey)
          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.
 void removeValue(java.lang.String key)
          Removes the value with the specified key.
 void save(java.io.OutputStream outbuf, java.lang.String sectionName)
          Save the section with the given name to the given output stream.
 void setBooleanValue(java.lang.String key, boolean value)
          Sets the specified key equal to the passed boolean value.
 void setDoubleValue(java.lang.String key, double value)
          Sets the specified key equal to the passed double 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)
          Set 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.
 void setObjectValue(java.lang.String key, java.lang.Object value)
          Sets the specified key equal to the passed object 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.String newValue)
          Sets the specified key equal to the passed value.
 int size()
          Answers the number of elements
 java.lang.String toString()
          Print out a string form of section including all of the keys and values included in the section.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, 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

CHANGED_SINCE_STARTUP

protected static final java.lang.String CHANGED_SINCE_STARTUP

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 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 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.
Parameters:
thisKey - name of the invisible attribute
Returns:
the vlaue

setInvisibleValue

protected void setInvisibleValue(java.lang.String thisKey,
                                 java.lang.String thisValue)
Set 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.
Parameters:
thisKey - name of the invisible attribute
thisValue - value to set

removeInvisibleValue

protected void removeInvisibleValue(java.lang.String thisKey)
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.
Parameters:
thisKey - name of the invisible attribute

clear

public void clear()
Clear the attributes

load

public void load(java.io.InputStream inbuf)
          throws java.io.IOException
Load the section from the given input stream.
Parameters:
inbuf - the input stream to load from
Throws:
java.io.IOException -  

save

public void save(java.io.OutputStream outbuf,
                 java.lang.String sectionName)
Save the section with the given name to the given output stream.
Parameters:
outbuf - the output stream
sectionName - the name of the section

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 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 key.
defaultValue - Value to return if no value found
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 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 key.
defaultValue - Value to return if no value found
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 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 key.
defaultValue - Value to return if no value found
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). The value is known to be boolean.
Parameters:
key - The 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). The value is known to be boolean.
Parameters:
key - The key
defaultValue - Value to return if no value found
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). The value is known to be an object value
Parameters:
key - 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). The value is known to be an object value
Parameters:
key - The key
defaultValue - The value to return if no value found
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 key.
newValue - 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 key.
value - The new value.

setValue

public void setValue(java.lang.String key,
                     int value)
Sets the specified key equal to the passed value. This is an overloaded setValue method for integer values.
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 boolean value.
Parameters:
key - The key.
value - The new value.

setValue

public void setValue(java.lang.String key,
                     boolean value)
Sets the specified key equal to the passed value. This is an overloaded method for boolean values.
Parameters:
key - The key.
value - The new value.

setDoubleValue

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

setValue

public void setValue(java.lang.String key,
                     double value)
Sets the specified key equal to the passed value. This is an overload of the setValue() method for double values.
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 object value. By default, changes are saved to persistent storage after this function call.
Parameters:
key - The 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 key.

propertyNames

public java.util.Enumeration propertyNames()
Answer the property names in this section.
Returns:
the enumeration of property names

isCoalesced

public boolean isCoalesced(java.lang.String key)
Answer whether the value for the given key is coalesced (i.e. is inherited from a higher level)
Parameters:
key - preference name
Returns:
true if coalesced, false otherwise

keys

public java.util.Enumeration keys()
Answers the set of keys.
Returns:
Enumeration the keys

size

public int size()
Answers the number of elements
Returns:
int the number of keys

list

public void list(java.io.PrintWriter writer)
List (print) out the attributes.
Parameters:
writer - the PrintWriter to write the attributes to

getStatus

public java.lang.String getStatus()
Print out a string form of section. Used for debugging, when it is needed to print the DatabaseSection current state.
Returns:
String form giving name, status, and subset association of the section.
See Also:
for a method to print the names and values of the elements of the section.

toString

public java.lang.String toString()
Print out a string form of section including all of the keys and values included in the section. Used for debugging when it is needed to print the DatabaseSection contents.
Overrides:
toString in class java.lang.Object
Returns:
String form giving name and members