Package adams.db
Class AbstractTable
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.db.generic.SQL
-
- adams.db.AbstractTable
-
- All Implemented Interfaces:
LoggingSupporter,SizeOfHandler,DatabaseConnectionProvider,DatabaseConnectionUser,SQLIntf,TableInterface,DatabaseConnectionChangeListener,Serializable
- Direct Known Subclasses:
AbstractIndexedTable
public abstract class AbstractTable extends SQL implements TableInterface, DatabaseConnectionChangeListener
Ancestor for all table classes.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringFILENAMEthe name of the props file.protected booleanm_AnsiQuoteswhether to use ANSI quotes around table/column names.protected static Propertiesm_Propertiesthe properties file.protected Stringm_TableNamename of the table.-
Fields inherited from class adams.db.generic.SQL
m_DatabaseConnection, m_Debug, m_Queries, m_Quirks, m_TableManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.db.SQLIntf
FAKE_TABLE_NAME
-
-
Constructor Summary
Constructors Constructor Description AbstractTable(AbstractDatabaseConnection dbcon, String tableName)Initializes the table.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancolumnExists(String column)Checks that a given column exists.voiddatabaseConnectionStateChanged(DatabaseConnectionChangeEvent e)A change in the database connection occurred.protected static PropertiesgetProperties()Returns the properties.AbstractDatabaseQueriesgetQueries()Returns the underlying queries helper instance.StringgetTableName()Get name of table.protected StringgetTablePrefix()Returns the table prefix.static String[]getTables()Returns a list with classnames of tables.abstract booleaninit()Initialize table, e.g., creating.static booleanisEnabled(Class cls)Returns whether the specified table is enabled and should get created if non-existent.StringquoteName(String name)Returns the column/table quoted if ANSI quotes are to be used.booleantableExists()Checks that a given table exists.StringtoString()Returns a short string representation.booleanuseAnsiQuotes()Returns whether ANSI quotes are to be used around table/column names.-
Methods inherited from class adams.db.generic.SQL
columnExists, doSelect, drop, execute, executeGeneratedKeys, getDatabaseConnection, getDebug, getMaxColumnNameLength, getResultSet, getSimpleResultSet, prepareStatement, prepareStatement, prepareStatement, select, selectDistinct, selectDouble, selectInt, selectLong, selectString, selectStrings, setDebug, singleton, tableExists, truncate, update, updatePrefix, updateTableName
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
-
-
-
Field Detail
-
FILENAME
public static final String FILENAME
the name of the props file.- See Also:
- Constant Field Values
-
m_Properties
protected static Properties m_Properties
the properties file.
-
m_TableName
protected String m_TableName
name of the table.
-
m_AnsiQuotes
protected boolean m_AnsiQuotes
whether to use ANSI quotes around table/column names.
-
-
Constructor Detail
-
AbstractTable
public AbstractTable(AbstractDatabaseConnection dbcon, String tableName)
Initializes the table.- Parameters:
dbcon- the database context this table is used intableName- the name of the table
-
-
Method Detail
-
getTablePrefix
protected String getTablePrefix()
Returns the table prefix.- Returns:
- the table prefix
-
isEnabled
public static boolean isEnabled(Class cls)
Returns whether the specified table is enabled and should get created if non-existent.- Parameters:
cls- the table class to check- Returns:
- true if table is to be available
-
getTableName
public String getTableName()
Get name of table.- Specified by:
getTableNamein interfaceTableInterface- Overrides:
getTableNamein classSQL- Returns:
- table name
-
useAnsiQuotes
public boolean useAnsiQuotes()
Returns whether ANSI quotes are to be used around table/column names.- Returns:
- true if to be used
-
getQueries
public AbstractDatabaseQueries getQueries()
Returns the underlying queries helper instance.- Returns:
- the instance
-
quoteName
public String quoteName(String name)
Returns the column/table quoted if ANSI quotes are to be used.- Parameters:
name- the table/column name to quote (if necessary)- Returns:
- the potentially quoted name
- See Also:
useAnsiQuotes()
-
tableExists
public boolean tableExists()
Checks that a given table exists.- Returns:
- true if the table exists.
-
columnExists
public boolean columnExists(String column)
Checks that a given column exists.- Parameters:
column- the column to look for- Returns:
- true if the column exists.
-
init
public abstract boolean init()
Initialize table, e.g., creating.- Returns:
- successful initialization
-
databaseConnectionStateChanged
public void databaseConnectionStateChanged(DatabaseConnectionChangeEvent e)
A change in the database connection occurred. Derived classes can override this method to react to changes in the connection.- Specified by:
databaseConnectionStateChangedin interfaceDatabaseConnectionChangeListener- Parameters:
e- the event
-
toString
public String toString()
Returns a short string representation.
-
getTables
public static String[] getTables()
Returns a list with classnames of tables.- Returns:
- the table classnames
-
getProperties
protected static Properties getProperties()
Returns the properties. Loads them if necessary.- Returns:
- the properties
-
-