Package adams.db
Class FacadeManager<T extends AbstractTableFacade>
- java.lang.Object
-
- adams.db.FacadeManager<T>
-
- Type Parameters:
T
- the type of facade this manager is for
- All Implemented Interfaces:
Serializable
public class FacadeManager<T extends AbstractTableFacade> extends Object implements Serializable
Manages the database URL/facade relations.- Version:
- $Revision: 5952 $
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected DatabaseManager
m_DatabaseManager
the database manager to use for default connection.protected String
m_FacadeName
the facade this manager is for.protected HashMap<String,T>
m_Facades
for storing the facade objects.
-
Constructor Summary
Constructors Constructor Description FacadeManager(String facadeName, DatabaseManager manager)
Initializes the manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
add(AbstractDatabaseConnection dbcon, T facade)
Adds the facade object for the specified database connection.protected String
createURL(AbstractDatabaseConnection dbcon)
Generates a URL that includes the user name.T
get(AbstractDatabaseConnection dbcon)
Gets the facade object for the specified database connection.DatabaseManager
getDatabaseManager()
Returns the database manager in use.String
getFacadeName()
Returns the name of the facade this manager is handling.boolean
has(AbstractDatabaseConnection dbcon)
Checks whether a facade object for the specified database connection is available.boolean
hasDatabaseManager()
Checks whether a database manager is available.Iterator<T>
iterator()
Returns an iterator over all facades.String
toString()
Returns a short string representation of the manager.
-
-
-
Field Detail
-
m_FacadeName
protected String m_FacadeName
the facade this manager is for.
-
m_Facades
protected HashMap<String,T extends AbstractTableFacade> m_Facades
for storing the facade objects.
-
m_DatabaseManager
protected DatabaseManager m_DatabaseManager
the database manager to use for default connection.
-
-
Constructor Detail
-
FacadeManager
public FacadeManager(String facadeName, DatabaseManager manager)
Initializes the manager.- Parameters:
facadeName
- the name of the facade this manager is formanager
- the database manager to obtain the default database connection from
-
-
Method Detail
-
getFacadeName
public String getFacadeName()
Returns the name of the facade this manager is handling.- Returns:
- the facade name
-
hasDatabaseManager
public boolean hasDatabaseManager()
Checks whether a database manager is available.- Returns:
- true if a database manager is available
-
getDatabaseManager
public DatabaseManager getDatabaseManager()
Returns the database manager in use.- Returns:
- the database manager
-
createURL
protected String createURL(AbstractDatabaseConnection dbcon)
Generates a URL that includes the user name.- Parameters:
dbcon
- the database connection- Returns:
- the complete URL
-
has
public boolean has(AbstractDatabaseConnection dbcon)
Checks whether a facade object for the specified database connection is available.- Parameters:
dbcon
- the connection to check- Returns:
- true if a facade object is available
-
get
public T get(AbstractDatabaseConnection dbcon)
Gets the facade object for the specified database connection.- Parameters:
dbcon
- the connection to get the facade for- Returns:
- the facade object if available, otherwise null
-
add
public T add(AbstractDatabaseConnection dbcon, T facade)
Adds the facade object for the specified database connection.- Parameters:
dbcon
- the connection to add the facade forfacade
- the facade object to add- Returns:
- the previous facade, null if no previous one stored
-
-