Package adams.db.wrapper
Class WrapperManager<T extends AbstractWrapper>
- java.lang.Object
-
- adams.db.wrapper.WrapperManager<T>
-
- Type Parameters:
T- the type of wrapper this manager is for
- All Implemented Interfaces:
Serializable
public class WrapperManager<T extends AbstractWrapper> extends Object implements Serializable
Manages the database URL/wrapper relations.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected DatabaseManagerm_DatabaseManagerthe database manager to use for default connection.protected Stringm_TableNamethe table this manager is for.protected HashMap<String,T>m_Tablesfor storing the table objects.
-
Constructor Summary
Constructors Constructor Description WrapperManager(String tableName, DatabaseManager manager)Initializes the manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tadd(AbstractDatabaseConnection dbcon, T table)Adds the table object for the specified database connection.protected StringcreateURL(AbstractDatabaseConnection dbcon)Generates a URL that includes the user name.Tget(AbstractDatabaseConnection dbcon)Gets the table object for the specified database connection.DatabaseManagergetDatabaseManager()Returns the database manager in use.StringgetTableName()Returns the name of the table this manager is handling.booleanhas(AbstractDatabaseConnection dbcon)Checks whether a table object for the specified database connection is available.booleanhasDatabaseManager()Checks whether a database manager is available.Iterator<T>iterator()Returns an iterator over all tables.StringtoString()Returns a short string representation of the manager.
-
-
-
Field Detail
-
m_TableName
protected String m_TableName
the table this manager is for.
-
m_Tables
protected HashMap<String,T extends AbstractWrapper> m_Tables
for storing the table objects.
-
m_DatabaseManager
protected DatabaseManager m_DatabaseManager
the database manager to use for default connection.
-
-
Constructor Detail
-
WrapperManager
public WrapperManager(String tableName, DatabaseManager manager)
Initializes the manager.- Parameters:
tableName- the name of the table this manager is formanager- the database manager to obtain the default database connection from
-
-
Method Detail
-
getTableName
public String getTableName()
Returns the name of the table this manager is handling.- Returns:
- the table 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 table object for the specified database connection is available.- Parameters:
dbcon- the connection to check- Returns:
- true if a table object is available
-
get
public T get(AbstractDatabaseConnection dbcon)
Gets the table object for the specified database connection.- Parameters:
dbcon- the connection to get the table for- Returns:
- the table object if available, otherwise null
-
add
public T add(AbstractDatabaseConnection dbcon, T table)
Adds the table object for the specified database connection.- Parameters:
dbcon- the connection to add the table fortable- the table object to add- Returns:
- the previous table, null if no previous one stored
-
-