Package adams.db
Class Sequences
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.db.Sequences
-
- All Implemented Interfaces:
LoggingSupporter
,SizeOfHandler
,SequenceProvider
,Serializable
public abstract class Sequences extends LoggingObject implements SequenceProvider
A class for retrieving sequences from database queries.- 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 Properties
m_Properties
the properties.static String
PREFIX_TEMPLATE
the prefix for a template.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Sequences()
Initializes the object.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Hashtable<Integer,Integer>
filterColumns(ResultSet rs)
Filters the columns that can be displayed.protected int
findColumn(ResultSet rs, String colName, boolean numeric)
Returns the index of the column in the resultset.protected String
getColumnName(ResultSet rs, int index)
Returns the name of the column.Hashtable<String,String>
getTemplates()
Returns all the templates currently stored.protected double
getValue(ResultSet rs, int index, int type)
Returns the value at the specified index.protected boolean
isTypeDate(int type)
Checks whether the SQL type represents a date/time/timestamp one.protected boolean
isTypeNumeric(int type)
Checks whether the SQL type represents a numeric one.abstract void
refresh()
Reloads the templates.Vector<XYSequence>
retrieve(String query)
Retrieves sequence(s) from a given SQL statement.abstract Vector<XYSequence>
retrieve(String query, String nameX)
Retrieves sequence(s) from a given SQL statement.-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
FILENAME
public static final String FILENAME
the name of the props file.- See Also:
- Constant Field Values
-
PREFIX_TEMPLATE
public static final String PREFIX_TEMPLATE
the prefix for a template.- See Also:
- Constant Field Values
-
m_Properties
protected Properties m_Properties
the properties.
-
-
Method Detail
-
refresh
public abstract void refresh()
Reloads the templates.- Specified by:
refresh
in interfaceSequenceProvider
-
isTypeNumeric
protected boolean isTypeNumeric(int type)
Checks whether the SQL type represents a numeric one.- Parameters:
type
- the type to check- Returns:
- true if numeric
- See Also:
Types
-
isTypeDate
protected boolean isTypeDate(int type)
Checks whether the SQL type represents a date/time/timestamp one.- Parameters:
type
- the type to check- Returns:
- true if date/time/timestamp
- See Also:
Types
-
findColumn
protected int findColumn(ResultSet rs, String colName, boolean numeric)
Returns the index of the column in the resultset.- Parameters:
rs
- the resultset to usecolName
- the name of the columnnumeric
- whether the column has to be numeric- Returns:
- the index of the column, -1 if not found
-
filterColumns
protected Hashtable<Integer,Integer> filterColumns(ResultSet rs)
Filters the columns that can be displayed.
Relation: Index <-> type (of SQL Types).- Parameters:
rs
- the Resultset to analyze- Returns:
- the relation
-
getColumnName
protected String getColumnName(ResultSet rs, int index)
Returns the name of the column.- Parameters:
rs
- the ResultSet to useindex
- the index (1-based) of the column- Returns:
- the name, or null in case of error
-
getValue
protected double getValue(ResultSet rs, int index, int type)
Returns the value at the specified index.- Parameters:
rs
- the resultset to useindex
- the column index (1-based)type
- the type of the column- Returns:
- the value
-
retrieve
public Vector<XYSequence> retrieve(String query)
Retrieves sequence(s) from a given SQL statement.- Specified by:
retrieve
in interfaceSequenceProvider
- Parameters:
query
- the statement to retrieve the sequences- Returns:
- the sequence(s)
-
retrieve
public abstract Vector<XYSequence> retrieve(String query, String nameX)
Retrieves sequence(s) from a given SQL statement.- Specified by:
retrieve
in interfaceSequenceProvider
- Parameters:
query
- the statement to retrieve the sequencesnameX
- the name of the column to use as x-axis, if null then the first column will be used- Returns:
- the sequence(s)
-
getTemplates
public Hashtable<String,String> getTemplates()
Returns all the templates currently stored.- Specified by:
getTemplates
in interfaceSequenceProvider
- Returns:
- the templates (name <-> sql relation)
-
-