planetj.database
Class Library

java.lang.Object
  |
  +--planetj.database.Library
All Implemented Interfaces:
EventListener, IDBObject, ITaskListener, IXMLObject, Serializable

public class Library
extends Object
implements IDBObject, 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.

Author:
PlanetJ Corporation
See Also:
Serialized Form

Field Summary
static String className
           
static String KEY_SEPARATOR
           
 
Method Summary
static Library createLibrary(String pSystemAlias, 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(String pTableName)
          Returns the Table in this Library with the given name.
 Table createTable(String pTableName, Class pTableClass)
          Returns the Table in this Library with the given name.
 Map getAllTables()
          Returns a Map of all the Tables in this Library.
 String getDBLibraryName()
          Returns the name of this library in the database.
static Library getDefaultLibrary(String pSystemAlias)
          Returns the default Library for the given library name and system alias.
static Map getLibraries(String pSystemAlias)
          Returns a Map of Libraries for the specified system alias.
static Library getLibrary(String pSystemAlias, String pLibraryName)
          Gets the Library with the given name for the DBSystem with the specified alias.
static Library getLibrary(String pSystemAlias, String pLibraryName, boolean pCreate)
          Returns the Library for the given library name and system alias.
 String getMetaDataSystemAlias()
          Gets the alias of the system this Library's DBSystem uses for retrieving its meta data.
 String getName()
          Returns the name of this library.
 DBSystem getSystem()
          Returns the DBSystem to which this Library belongs.
 String getSystemAlias()
          Returns the url of this Library's DBSystem.
 String getSystemURL()
          Returns the url of this Library's DBSystem.
 Table getTable(String pTableName)
          Returns the Table in this Library with the given name.
 Table getTable(String pTableName, boolean pCreate)
          Returns the Table in this Library with the given name.
 List getTableNames()
          Gets a list of table names currently in the library instance.
 Map getTables()
          Returns a Map of Table objects existing in this Library (May not be all of the tables in the database).
 StringBuffer getXMLData(StringBuffer pXMLData)
          This returns a StringBuffer containing all necessary XML data for this object.
 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(String pTableName)
          Removes the Table with the given name.
 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.
 String toString()
          Returns the String representation of this Library.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

KEY_SEPARATOR

public static final String KEY_SEPARATOR
See Also:
Constant Field Values

className

public static final String className
Method Detail

createLibrary

public static Library createLibrary(String pSystemAlias,
                                    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

createTable

public Table createTable(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(String pTableName,
                         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 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
DataEngineException

getDBLibraryName

public 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(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 Map getLibraries(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(String pSystemAlias,
                                 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(String pSystemAlias,
                                 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 String getMetaDataSystemAlias()
Gets the alias of the system this Library's DBSystem uses for retrieving its meta data.

Returns:
String

getName

public 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 String getSystemAlias()
Returns the url of this Library's DBSystem.

Returns:
String

getSystemURL

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

Returns:
String

getTable

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


getTable

public Table getTable(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 List getTableNames()
Gets a list of table names currently in the library instance.


getTables

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

Returns:
Map

getXMLData

public StringBuffer getXMLData(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(String pTableName)
Removes the Table with the given name.

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

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 String toString()
Returns the String representation of this Library.

Overrides:
toString in class Object
Returns:
String

isShared

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