com.ibm.wbi.util
Class Database

java.lang.Object
  |
  +--com.ibm.wbi.util.Database
Direct Known Subclasses:
IniDatabase

public abstract class Database
extends java.lang.Object

Provides an abstract database to contain information about a Server, a Server Group, a User, or a User Group.

A Databased is organized into a set of DatabaseSections that can be loaded, saved, and accessed independently. DatabaseSection.

A Database can be implemented in a number of ways, including one that uses a set of local files for persistent storage.

An explicit save or saveSection operation must be invoked to cause the database to write updates to persistent store.


Field Summary
static java.lang.String COPYRIGHT
          IBM copyright information.
static int DEFAULT
           
protected  java.lang.String purpose
          purpose is a string that is used in the construction of directories or property names to distinguish information from one application from the information stored by another application using the Database classes.
protected static com.ibm.wbi.ras.RASDirector ras
          The RAS object to be used for conditionally logging and tracing information.
protected  java.util.Hashtable sections
           
static int SERVER
           
static int SERVER_GROUP
           
protected static java.lang.String[] typeNames
           
static int USER
           
static int USER_GROUP
           
 
Constructor Summary
protected Database(java.lang.String name)
          Opens the database without loading it.
protected Database(java.lang.String name, boolean readOnly, int type)
           
protected Database(java.lang.String name, int type)
           
 
Method Summary
 DatabaseSection createSection(java.lang.String sectionName)
          Create a new DatabaseSection in the database, after checking to make sure that there is not already a section with the same name.
abstract  DatabaseSection createSection(java.lang.String sectionName, java.lang.String subsetName)
          Create a new DatabaseSection in the database with a given section and subset name.
 boolean exists(java.lang.String sectionName)
          Determines if the named DatabaseSection exists in the Database.
abstract  java.lang.String getDecodedName(java.lang.String name)
          Get the decoded name of an encoded key.
abstract  java.lang.String getEncodedName(java.lang.String name)
          Get the encoded name of a key in the database.
protected  DatabaseSection getLoadedSection(java.lang.String sectionName)
          Get a section from the database.
 java.lang.String getName()
          Get the name of the database.
abstract  java.lang.Object getObjectValue(DatabaseSection section, java.lang.String key, java.lang.Object defaultValue)
          Get the value of an object in the database.
 DatabaseSection getSection(java.lang.String sectionName)
          Get a section from the database.
 java.util.Enumeration getSections()
          Get an enumeration of all of the DatabaseSections of the database, including those that have been newly created, those that have been loaded from persistent storage, and those that have been removed from the active database.
 int getType()
          Get the type of the database.
 java.lang.String getTypeName()
          Get the type name of the Database.
abstract  void loadDatabase()
          Loads the database.
abstract  void loadDatabase(java.lang.String subsetName)
          Loads the database from a subset.
abstract  DatabaseSection loadSection(java.lang.String propertyName)
          Loads the database section using the given property name.
abstract  void prepareForInitialLoad()
          Prepare for the initial load of a database, when it is first being loaded.
abstract  void removeIfObjectValue(DatabaseSection section, java.lang.String value)
          Removes an objct from the database section if the objects value equals the given value.
 void removeSection(java.lang.String name)
          Remove a section.
abstract  void saveDatabase()
          Saves the Database.
abstract  void saveDatabase(java.lang.String subsetName)
          Saves the given Database using the specified subset name.
abstract  void saveSection(DatabaseSection section)
          Saves the given Database section.
abstract  void setObjectValue(DatabaseSection section, java.lang.String key, java.lang.Object value)
          Set the value of an object in the database.
 void setPurpose(java.lang.String dbPurpose)
          Set the purpose of the database.
 java.lang.String toString()
          Returns a string that can be used in debugging to represent the current state of the Database.
 
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.

DEFAULT

public static final int DEFAULT

USER

public static final int USER

USER_GROUP

public static final int USER_GROUP

SERVER

public static final int SERVER

SERVER_GROUP

public static final int SERVER_GROUP

typeNames

protected static final java.lang.String[] typeNames

purpose

protected java.lang.String purpose
purpose is a string that is used in the construction of directories or property names to distinguish information from one application from the information stored by another application using the Database classes. Thus, the default purpose is "transform" for the TransProxy. The Pervader project can use this field to interject an alternative string into the property or directory names. See specific Database implementations for information about how this value is specifically used.

sections

protected java.util.Hashtable sections

ras

protected static com.ibm.wbi.ras.RASDirector ras
The RAS object to be used for conditionally logging and tracing information. The decision concerning whether to trace or log at this time is made within the RAS objects. Therefore a call to the ras object may or may not cause a trace or log message to be written to console, file, or network.
Constructor Detail

Database

protected Database(java.lang.String name)
Opens the database without loading it. Various different constructors have different numbers of parameters, with some allowing the values to default.
Parameters:
name - Descriptiove name to be associated with the database.
readonly - true if read-only access (any updates are transient). false for read-write access.
type - An identifier of the Database context

Database

protected Database(java.lang.String name,
                   int type)

Database

protected Database(java.lang.String name,
                   boolean readOnly,
                   int type)
Method Detail

exists

public boolean exists(java.lang.String sectionName)
Determines if the named DatabaseSection exists in the Database.
Parameters:
sectionName - The DatabaseSection namae
Returns:
true if section exists in the database; false if doesn't exist in the database.

setPurpose

public void setPurpose(java.lang.String dbPurpose)
Set the purpose of the database.
Parameters:
The - purpose as a string.

getSections

public java.util.Enumeration getSections()
Get an enumeration of all of the DatabaseSections of the database, including those that have been newly created, those that have been loaded from persistent storage, and those that have been removed from the active database.
Returns:
The enumeration of the DatabaseSections

getSection

public DatabaseSection getSection(java.lang.String sectionName)
Get a section from the database. Only DatabaseSections that have not been removed in previous actions can be returned. Loads section from persistent storage if not already loaded
Parameters:
sectionName - The name of the section.
Returns:
The section or null if doesn't exist.

getLoadedSection

protected DatabaseSection getLoadedSection(java.lang.String sectionName)
Get a section from the database. Does not load from persistent storage
Parameters:
sectionName - The name of the section.
Returns:
The section or null if doesn't exist.

createSection

public DatabaseSection createSection(java.lang.String sectionName)
Create a new DatabaseSection in the database, after checking to make sure that there is not already a section with the same name.
Parameters:
sectionName - The name of the section.

createSection

public abstract DatabaseSection createSection(java.lang.String sectionName,
                                              java.lang.String subsetName)
Create a new DatabaseSection in the database with a given section and subset name.
Parameters:
sectionName - The name of the section.
subsetName - The name of the subset.

removeSection

public void removeSection(java.lang.String name)
Remove a section.
Parameters:
The - name of the major section.

loadDatabase

public abstract void loadDatabase()
Loads the database.

loadDatabase

public abstract void loadDatabase(java.lang.String subsetName)
Loads the database from a subset.

loadSection

public abstract DatabaseSection loadSection(java.lang.String propertyName)
Loads the database section using the given property name.
Parameters:
propertyName - Name of the property to load.
Returns:
The database section.

saveSection

public abstract void saveSection(DatabaseSection section)
Saves the given Database section.
Parameters:
section - Section of database to be saved.

saveDatabase

public abstract void saveDatabase()
Saves the Database.

saveDatabase

public abstract void saveDatabase(java.lang.String subsetName)
Saves the given Database using the specified subset name.
Parameters:
subsetName - Name of subset.

getObjectValue

public abstract java.lang.Object getObjectValue(DatabaseSection section,
                                                java.lang.String key,
                                                java.lang.Object defaultValue)
Get the value of an object in the database.
Parameters:
section - Database section to look in.
key - Key of the object to look for.
defaultValue - Value to return if nothing was found in database.
Returns:
The object.

setObjectValue

public abstract void setObjectValue(DatabaseSection section,
                                    java.lang.String key,
                                    java.lang.Object value)
Set the value of an object in the database.
Parameters:
section - Database section to use.
key - Key of the object.
value - Value of the object.

getEncodedName

public abstract java.lang.String getEncodedName(java.lang.String name)
Get the encoded name of a key in the database.
Parameters:
name - Key to be encoded.
Returns:
Encoded key.

getDecodedName

public abstract java.lang.String getDecodedName(java.lang.String name)
Get the decoded name of an encoded key.
Parameters:
name - encoded key.
Returns:
Decoded key.

removeIfObjectValue

public abstract void removeIfObjectValue(DatabaseSection section,
                                         java.lang.String value)
Removes an objct from the database section if the objects value equals the given value.
Parameters:
section - Database section to look in.
value - If an object in the database matches this value, remove the object.

prepareForInitialLoad

public abstract void prepareForInitialLoad()
Prepare for the initial load of a database, when it is first being loaded. Subsequent loads of the database may not invoke this method, if the database user wants the effects of loadDatabase() operations to be cumulative.

toString

public java.lang.String toString()
Returns a string that can be used in debugging to represent the current state of the Database.
Overrides:
toString in class java.lang.Object

getName

public java.lang.String getName()
Get the name of the database.
Returns:
Name of database.

getType

public int getType()
Get the type of the database.
Returns:
Type of database.

getTypeName

public java.lang.String getTypeName()
Get the type name of the Database.
Returns:
Type name of database.