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 String
FILENAME
the name of the props file.protected boolean
m_AnsiQuotes
whether to use ANSI quotes around table/column names.protected static Properties
m_Properties
the properties file.protected String
m_TableName
name of the table.-
Fields inherited from class adams.db.generic.SQL
m_DatabaseConnection, m_Debug, 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 boolean
columnExists(String column)
Checks that a given column exists.void
databaseConnectionStateChanged(DatabaseConnectionChangeEvent e)
A change in the database connection occurred.protected static Properties
getProperties()
Returns the properties.String
getTableName()
Get name of table.static String[]
getTables()
Returns a list with classnames of tables.abstract boolean
init()
Initialize table, e.g., creating.static boolean
isEnabled(Class cls)
Returns whether the specified table is enabled and should get created if non-existent.String
quoteName(String name)
Returns the column/table quoted if ANSI quotes are to be used.boolean
tableExists()
Checks that a given table exists.String
toString()
Returns a short string representation.boolean
useAnsiQuotes()
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
-
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:
getTableName
in interfaceTableInterface
- Overrides:
getTableName
in 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
-
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:
databaseConnectionStateChanged
in 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
-
-