planetj.database
Class Library

java.lang.Object
  extended byplanetj.database.Library
All Implemented Interfaces:
java.util.EventListener, IDBObject, ITaskListener, IXMLObject, java.io.Serializable

public class Library
extends java.lang.Object
implements IDBObject, java.io.Serializable, IXMLObject, ITaskListener

Represents a group of tables in a relational database. A library is called a catalog on some system, or a schema on others.

See Also:
Serialized Form

Field Summary
static java.lang.String className
           
static java.lang.String KEY_SEPARATOR
           
 
Constructor Summary
protected Library(java.lang.String pName, DBSystem pSystem)
          Library constructor comment.
 
Method Summary
static Library createLibrary(java.lang.String pSystemAlias, java.lang.String pLibraryName)
          Creates and returns a new Library using the given system url, library name, (a Library is only created if it doesn't already exist).
 Table createTable(java.lang.String pTableName)
          Returns the Table in this Library with the given name.
 Table createTable(java.lang.String pTableName, java.lang.Class pTableClass)
          Returns the Table in this Library with the given name.
 java.util.Map getAllTables()
          Returns a Map of all the Tables in this Library.
 java.lang.String getDBLibraryName()
          Returns the name of this library in the database.
static Library getDefaultLibrary(java.lang.String pSystemAlias)
          Returns the default Library for the given library name and system alias.
static java.util.Map getLibraries(java.lang.String pSystemAlias)
          Returns a Map of Libraries for the specified system alias.
static Library getLibrary(java.lang.String pSystemAlias, java.lang.String pLibraryName)
          Gets the Library with the given name for the DBSystem with the specified alias.
static Library getLibrary(java.lang.String pSystemAlias, java.lang.String pLibraryName, boolean pCreate)
          Returns the Library for the given library name and system alias.
 java.lang.String getMetaDataSystemAlias()
          Gets the alias of the system this Library's DBSystem uses for retrieving its meta data.
 java.lang.String getName()
          Returns the name of this library.
 DBSystem getSystem()
          Returns the DBSystem to which this Library belongs.
 java.lang.String getSystemAlias()
          Returns the url of this Library's DBSystem.
 java.lang.String getSystemURL()
          Returns the url of this Library's DBSystem.
 Table getTable(java.lang.String pTableName)
          Returns the Table in this Library with the given name.
 Table getTable(java.lang.String pTableName, boolean pCreate)
          Returns the Table in this Library with the given name.
 java.util.List getTableNames()
          Gets a list of table names currently in the library instance.
 java.util.Map getTables()
          Returns a Map of Table objects existing in this Library (May not be all of the tables in the database).
protected  java.util.Map getTablesInternal()
          Returns a Map of Table objects existing in this Library (May not be all of the tables in the database).
 java.lang.StringBuffer getXMLData(java.lang.StringBuffer pXMLData)
          This returns a StringBuffer containing all necessary XML data for this object.
static boolean isCompatible(java.lang.String lib1, java.lang.String lib2)
          Tests if the two library names are compatible (i.e.
 boolean isDefault()
          Tests if this library is the default library
 boolean isExistenceConfirmed()
          Return whether or not this Table's existence in the database has been confirmed.
 boolean isHasAllTables()
           
 boolean isShared()
          Tests if this Library is the logical "shared" library
 Table removeTable(java.lang.String pTableName)
          Removes the Table with the given name.
protected  void setName(java.lang.String pName)
          Sets the name of this library.
 void startRetrieveAllTablesTask()
           
 void taskCompleted(TaskEvent pTaskEvent)
          Invoked when a task completes its execution.
 void taskFailed(TaskEvent pTaskEvent)
          Invoked when a task fails while executing.
 void taskStarted(TaskEvent pTaskEvent)
          Invoked when a task starts executing.
 java.lang.String toString()
          Returns the String representation of this Library.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

KEY_SEPARATOR

public static final java.lang.String KEY_SEPARATOR
See Also:
Constant Field Values

className

public static final java.lang.String className
Constructor Detail

Library

protected Library(java.lang.String pName,
                  DBSystem pSystem)
Library constructor comment.

Method Detail

createLibrary

public static Library createLibrary(java.lang.String pSystemAlias,
                                    java.lang.String pLibraryName)
Creates and returns a new Library using the given system url, library name, (a Library is only created if it doesn't already exist).

Parameters:
pSystemAlias -
pLibraryName -
Returns:
Library

isCompatible

public static boolean isCompatible(java.lang.String lib1,
                                   java.lang.String lib2)
Tests if the two library names are compatible (i.e. if they could represent the same library)


createTable

public Table createTable(java.lang.String pTableName)
Returns the Table in this Library with the given name. A Table is created if it does not exist.

Parameters:
pTableName - String
Returns:
Table

createTable

public Table createTable(java.lang.String pTableName,
                         java.lang.Class pTableClass)
Returns the Table in this Library with the given name. If no such table exists a new Table of the specified class is created and returned.


getAllTables

public java.util.Map getAllTables()
                           throws DataEngineException
Returns a Map of all the Tables in this Library. The Map contains Table objects keyed by their names.

Returns:
Map
Throws:
DataEngineException

getDBLibraryName

public java.lang.String getDBLibraryName()
Returns the name of this library in the database. For default libraries, this is probably null. For other libraries, this is probably the name of the library


getDefaultLibrary

public static Library getDefaultLibrary(java.lang.String pSystemAlias)
Returns the default Library for the given library name and system alias. If the default Library does not exist, it is created. If no DBSystem exists for the system alias, null is returned. Returns null if pLibName is null


getLibraries

public static java.util.Map getLibraries(java.lang.String pSystemAlias)
Returns a Map of Libraries for the specified system alias. If no such system exists, null is returned


getLibrary

public static Library getLibrary(java.lang.String pSystemAlias,
                                 java.lang.String pLibraryName)
Gets the Library with the given name for the DBSystem with the specified alias.

Returns:
Library in the specified system (if DBSystem does not exist or the Library in the system does not exist, null is returned)

getLibrary

public static Library getLibrary(java.lang.String pSystemAlias,
                                 java.lang.String pLibraryName,
                                 boolean pCreate)
Returns the Library for the given library name and system alias. If the Library does not exist, it is created. If no DBSystem exists for the system alias, null is returned. Returns null if pLibName is null


getMetaDataSystemAlias

public java.lang.String getMetaDataSystemAlias()
Gets the alias of the system this Library's DBSystem uses for retrieving its meta data.

Returns:
String

getName

public java.lang.String getName()
Returns the name of this library.

Specified by:
getName in interface IDBObject
Returns:
String

getSystem

public DBSystem getSystem()
Returns the DBSystem to which this Library belongs.

Returns:
DBSystem

getSystemAlias

public java.lang.String getSystemAlias()
Returns the url of this Library's DBSystem.

Returns:
String

getSystemURL

public java.lang.String getSystemURL()
Returns the url of this Library's DBSystem.

Returns:
String

getTable

public Table getTable(java.lang.String pTableName)
Returns the Table in this Library with the given name. If it does not exists, null is returned.


getTable

public Table getTable(java.lang.String pTableName,
                      boolean pCreate)
Returns the Table in this Library with the given name. If it does not exists and pCreate is true, a new Table is created and returned. If it does not exist and pCreate is false, null is returned.


getTableNames

public java.util.List getTableNames()
Gets a list of table names currently in the library instance.


getTables

public java.util.Map getTables()
Returns a Map of Table objects existing in this Library (May not be all of the tables in the database).

Returns:
Map

getTablesInternal

protected java.util.Map getTablesInternal()
Returns a Map of Table objects existing in this Library (May not be all of the tables in the database).

Returns:
Map

getXMLData

public java.lang.StringBuffer getXMLData(java.lang.StringBuffer pXMLData)
This returns a StringBuffer containing all necessary XML data for this object. Creation date: (1/21/2002 7:03:38 PM)

Specified by:
getXMLData in interface IXMLObject

isDefault

public boolean isDefault()
Tests if this library is the default library


isExistenceConfirmed

public boolean isExistenceConfirmed()
Return whether or not this Table's existence in the database has been confirmed.

Returns:
boolean

isHasAllTables

public boolean isHasAllTables()

removeTable

public Table removeTable(java.lang.String pTableName)
Removes the Table with the given name.

Parameters:
pTableName - name of Table to remove
Returns:
Table being removed

setName

protected void setName(java.lang.String pName)
Sets the name of this library.

Returns:
String

startRetrieveAllTablesTask

public void startRetrieveAllTablesTask()

taskCompleted

public void taskCompleted(TaskEvent pTaskEvent)
Invoked when a task completes its execution.

Specified by:
taskCompleted in interface ITaskListener

taskFailed

public void taskFailed(TaskEvent pTaskEvent)
Invoked when a task fails while executing.

Specified by:
taskFailed in interface ITaskListener

taskStarted

public void taskStarted(TaskEvent pTaskEvent)
Invoked when a task starts executing.

Specified by:
taskStarted in interface ITaskListener

toString

public java.lang.String toString()
Returns the String representation of this Library.

Returns:
String

isShared

public boolean isShared()
Tests if this Library is the logical "shared" library