Package adams.db
Class AbstractCQETable<T>
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.db.AbstractCQETable<T>
-
- Type Parameters:
T
- the managed type of object
- All Implemented Interfaces:
adams.core.logging.LoggingSupporter
,adams.core.SizeOfHandler
,Serializable
public abstract class AbstractCQETable<T> extends adams.core.logging.LoggingObject
Ancestor for CQEngine tables.- Version:
- $Revision$
- 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 static adams.core.logging.Logger
LOGGER
the static logger.protected com.googlecode.cqengine.IndexedCollection<T>
m_Collection
the object collection.protected adams.db.AbstractDatabaseConnection
m_DatabaseConnection
connection to database.protected boolean
m_Debug
whether debugging is turned on.protected static com.googlecode.cqengine.query.parser.sql.SQLParser
m_Parser
the SQL parser.protected static adams.core.Properties
m_Properties
the properties file.protected String
m_TableName
name of the table.
-
Constructor Summary
Constructors Constructor Description AbstractCQETable(adams.db.AbstractDatabaseConnection dbcon, String tableName)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static String
backquote(adams.core.base.BaseRegExp s)
Backquotes the regular expression and ensures that it is surrounded by single quotes.static String
backquote(String s)
Backquotes the string and ensures that it is surrounded by single quotes.void
clear()
Clears the collection.static void
closeAll(com.googlecode.cqengine.resultset.ResultSet r)
Close objects related to this ResultSet.protected com.googlecode.cqengine.resultset.ResultSet<T>
doSelect(boolean distinct, String where)
Do a select on given columns for all data, with condition.com.googlecode.cqengine.IndexedCollection<T>
getCollection()
Returns the collection in use.adams.db.AbstractDatabaseConnection
getDatabaseConnection()
Returns the database connection this table is for.boolean
getDebug()
Returns whether debugging is enabled.com.googlecode.cqengine.query.parser.sql.SQLParser<T>
getParser()
Returns the parser in use.protected static adams.core.Properties
getProperties()
Returns the properties.String
getTableName()
Get name of table.static boolean
isEnabled(Class table)
Checks whether the table is enabled.boolean
isThere(com.googlecode.cqengine.query.Query<T> query)
Returns true if this table holds data that satisfies the query condition.boolean
isThere(String condition)
Returns true if this table holds data that satisfies 'condition'.protected abstract com.googlecode.cqengine.IndexedCollection<T>
newCollection()
Returns a new instance of the collection to use.protected abstract com.googlecode.cqengine.query.parser.sql.SQLParser<T>
newParser()
Returns a new instance of the parser to use.protected boolean
remove(com.googlecode.cqengine.resultset.ResultSet<T> rs)
Removes all objects in the result set.com.googlecode.cqengine.resultset.ResultSet<T>
select(String where)
Do a select on all columns for all data in, with condition.com.googlecode.cqengine.resultset.ResultSet<T>
selectDistinct(String where)
Do a select distinct on all columns for all data, with condition.void
setDebug(boolean value)
Sets whether debugging is enabled, outputs more on the console.protected void
updatePrefix()
Updates the prefix of the console object output streams.
-
-
-
Field Detail
-
FILENAME
public static final String FILENAME
the name of the props file.- See Also:
- Constant Field Values
-
m_Properties
protected static adams.core.Properties m_Properties
the properties file.
-
LOGGER
protected static adams.core.logging.Logger LOGGER
the static logger.
-
m_Parser
protected static com.googlecode.cqengine.query.parser.sql.SQLParser m_Parser
the SQL parser.
-
m_TableName
protected String m_TableName
name of the table.
-
m_Debug
protected boolean m_Debug
whether debugging is turned on.
-
m_DatabaseConnection
protected adams.db.AbstractDatabaseConnection m_DatabaseConnection
connection to database.
-
m_Collection
protected com.googlecode.cqengine.IndexedCollection<T> m_Collection
the object collection.
-
-
Constructor Detail
-
AbstractCQETable
public AbstractCQETable(adams.db.AbstractDatabaseConnection dbcon, String tableName)
Constructor.- Parameters:
dbcon
- the database context to usetableName
- the name of the table
-
-
Method Detail
-
getTableName
public String getTableName()
Get name of table.- Returns:
- table name
-
newParser
protected abstract com.googlecode.cqengine.query.parser.sql.SQLParser<T> newParser()
Returns a new instance of the parser to use.- Returns:
- the parser
-
getParser
public com.googlecode.cqengine.query.parser.sql.SQLParser<T> getParser()
Returns the parser in use.- Returns:
- the parser
-
newCollection
protected abstract com.googlecode.cqengine.IndexedCollection<T> newCollection()
Returns a new instance of the collection to use.- Returns:
- the collection
-
getCollection
public com.googlecode.cqengine.IndexedCollection<T> getCollection()
Returns the collection in use.- Returns:
- the collection
-
clear
public void clear()
Clears the collection.
-
updatePrefix
protected void updatePrefix()
Updates the prefix of the console object output streams.
-
backquote
public static String backquote(adams.core.base.BaseRegExp s)
Backquotes the regular expression and ensures that it is surrounded by single quotes.- Parameters:
s
- the regular expression to backquote and enclose- Returns:
- the processed string
-
backquote
public static String backquote(String s)
Backquotes the string and ensures that it is surrounded by single quotes.- Parameters:
s
- the string to backquote and enclose- Returns:
- the processed string
-
getDatabaseConnection
public adams.db.AbstractDatabaseConnection getDatabaseConnection()
Returns the database connection this table is for.- Returns:
- the database connection
-
setDebug
public void setDebug(boolean value)
Sets whether debugging is enabled, outputs more on the console.- Parameters:
value
- if true debugging is enabled
-
getDebug
public boolean getDebug()
Returns whether debugging is enabled.- Returns:
- true if debugging is enabled
-
isThere
public boolean isThere(String condition)
Returns true if this table holds data that satisfies 'condition'.- Parameters:
condition
- boolean SQL eg "JOBNO=100 AND SAMPLENO=2"- Returns:
- true if condition holds for tablename
-
isThere
public boolean isThere(com.googlecode.cqengine.query.Query<T> query)
Returns true if this table holds data that satisfies the query condition.- Parameters:
query
- the query to use- Returns:
- true if condition holds for tablename
-
select
public com.googlecode.cqengine.resultset.ResultSet<T> select(String where) throws Exception
Do a select on all columns for all data in, with condition.- Parameters:
where
- condition- Returns:
- resultset of data
- Throws:
Exception
- if SQL fails to parse
-
selectDistinct
public com.googlecode.cqengine.resultset.ResultSet<T> selectDistinct(String where) throws Exception
Do a select distinct on all columns for all data, with condition.- Parameters:
where
- condition- Returns:
- resultset of data
- Throws:
Exception
- if SQL fails to parse
-
doSelect
protected com.googlecode.cqengine.resultset.ResultSet<T> doSelect(boolean distinct, String where) throws Exception
Do a select on given columns for all data, with condition. Can be distinct.- Parameters:
distinct
- whether values in columns has to be distinctwhere
- condition, can be null- Returns:
- resultset of data
- Throws:
Exception
- if SQL fails to parse
-
remove
protected boolean remove(com.googlecode.cqengine.resultset.ResultSet<T> rs)
Removes all objects in the result set.- Parameters:
rs
- the result of objects to remove- Returns:
- true if successfully removed
-
closeAll
public static void closeAll(com.googlecode.cqengine.resultset.ResultSet r)
Close objects related to this ResultSet.- Parameters:
r
- The ResultSet to clean up after
-
isEnabled
public static boolean isEnabled(Class table)
Checks whether the table is enabled.- Parameters:
table
- the CQE table class- Returns:
- true if enabled
-
getProperties
protected static adams.core.Properties getProperties()
Returns the properties. Loads them if necessary.- Returns:
- the properties
-
-