org.opengts.dbtools
Class DBSelect<gDBR extends DBRecord>

java.lang.Object
  extended by org.opengts.dbtools.DBSelect<gDBR>

public class DBSelect<gDBR extends DBRecord>
extends java.lang.Object

DBSelect represents an SQL select statement.


Constructor Summary
DBSelect(DBFactory<gDBR> fact)
          Constructor
DBSelect(DBFactory<gDBR> fact, DBWhere where)
          Constructor
DBSelect(DBFactory<gDBR> fact, java.lang.String where)
          Constructor
 
Method Summary
 DBWhere createDBWhere()
          Creates a new DBWhere instance (calling 'setWhere(...)' is still required in order to used the created DBWhere instance for this DBSelect).
 DBFactory<gDBR> getFactory()
          Gets the table DBFactory instance for this DBSelect
 long getLimit()
          Gets the defined limit
 long getOffset()
          Gets the defined offset
 java.lang.String[] getOrderByFields()
          Gets the order-byte fields
 java.lang.String[] getSelectedFields()
          Gets the selected fields
 java.lang.String getTranslatedTableName()
          Gets the table name for this DBSelect
 java.lang.String getTranslatedTableName(DBProvider dbp)
          Gets the table name for this DBSelect
 java.lang.String getUntranslatedTableName()
          Gets the table name for this DBSelect
 java.lang.String getWhere()
          Gets the where clause for this DBSelect
 boolean hasFactory()
          Returns true if a DBFactory instance has been properly defined for this instance
 boolean hasLimit()
          Returns true if a limit has been defined for this DBSelect
 boolean hasOffset()
          Returns true if a offset has been defined for this DBSelect
 boolean hasOrderByFields()
          Returns true if this DBSelect has order-by fields defined
 boolean hasSelectedFields()
          Returns true if this DBSelect has selected fields defined
 boolean hasWhere()
          Returns true if this DBSelect has a defined where clause
 boolean isOrderAscending()
          Returns true if the ording is ascending, false if descending
 void setLastRecordKey(DBRecordKey<gDBR> rcdKey)
          Sets the DBRecordKey of the last record retrieved by this DBSelect.
Called by DBRecordIterator to allow subclasses of this DBSelect to adjust the selection criteria if necessary.
 void setLimit(long limit)
          Sets the LIMIT for this DBSelect
 void setOffset(long offset)
          Sets the OFFSET for this DBSelect
 void setOrderAscending(boolean ascending)
          Set ascending/descending sort order
 void setOrderByFields(java.lang.String... obf)
          Sets the order-by fields
 void setSelectedFields(java.util.Set<java.lang.String> sf)
          Sets a list of selected fields
 void setSelectedFields(java.lang.String... sf)
          Sets an array of selected fields
 void setUntranslatedTableName(java.lang.String utableName)
          Sets the untranslated table name for this DBSelect (if not set, the table name of the defined DBFactory will be used).
 void setWhere(DBWhere wh)
          Sets the DBWhere instance used for this DBSelect
 void setWhere(java.lang.String wh)
          Sets the where clause used for this DBSelect
 boolean supportsLimit()
          Returns true if the DBProvider supports a LIMIT clause
 boolean supportsOffset()
          Returns true if the DBProvider supports a OFFSET clause
 java.lang.String toString()
          Returns the DBSelect statement as a String representation
 java.lang.String toString(java.lang.String dbpName)
          Returns the DBSelect statement as a String representation, for the specified DBProvider name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DBSelect

public DBSelect(DBFactory<gDBR> fact)
Constructor

Parameters:
fact - The table DBFactory instance

DBSelect

public DBSelect(DBFactory<gDBR> fact,
                java.lang.String where)
Constructor

Parameters:
fact - The table DBFactory instance
where - The initial selection SQL 'WHERE' clause

DBSelect

public DBSelect(DBFactory<gDBR> fact,
                DBWhere where)
Constructor

Parameters:
fact - The table DBFactory instance
where - The initial selection SQL 'WHERE' clause
Method Detail

hasFactory

public boolean hasFactory()
Returns true if a DBFactory instance has been properly defined for this instance

Returns:
True if this DBSelect instance has a defined table DBFactory

getFactory

public DBFactory<gDBR> getFactory()
Gets the table DBFactory instance for this DBSelect

Returns:
The table DBFactory instance

setSelectedFields

public void setSelectedFields(java.util.Set<java.lang.String> sf)
Sets a list of selected fields

Parameters:
sf - An Set of field names to select

setSelectedFields

public void setSelectedFields(java.lang.String... sf)
Sets an array of selected fields

Parameters:
sf - An array of field names to select

hasSelectedFields

public boolean hasSelectedFields()
Returns true if this DBSelect has selected fields defined

Returns:
True if this DBSelect has selected fields defined

getSelectedFields

public java.lang.String[] getSelectedFields()
Gets the selected fields

Returns:
The selected fields, or null if no fields have been defined

setUntranslatedTableName

public void setUntranslatedTableName(java.lang.String utableName)
Sets the untranslated table name for this DBSelect (if not set, the table name of the defined DBFactory will be used).

Parameters:
utableName - The untranslated table name

getUntranslatedTableName

public java.lang.String getUntranslatedTableName()
Gets the table name for this DBSelect

Returns:
The defined table name

getTranslatedTableName

public java.lang.String getTranslatedTableName(DBProvider dbp)
Gets the table name for this DBSelect

Returns:
The defined table name

getTranslatedTableName

public java.lang.String getTranslatedTableName()
Gets the table name for this DBSelect

Returns:
The defined table name

createDBWhere

public DBWhere createDBWhere()
Creates a new DBWhere instance (calling 'setWhere(...)' is still required in order to used the created DBWhere instance for this DBSelect).

Returns:
The new DBWhere instance

setWhere

public void setWhere(DBWhere wh)
Sets the DBWhere instance used for this DBSelect

Parameters:
wh - The DBWhere instance used for this DBSelect

setWhere

public void setWhere(java.lang.String wh)
Sets the where clause used for this DBSelect

Parameters:
wh - The where clause used for this DBSelect

hasWhere

public boolean hasWhere()
Returns true if this DBSelect has a defined where clause

Returns:
True if this DBSelect has a defined where clause

getWhere

public java.lang.String getWhere()
Gets the where clause for this DBSelect

Returns:
The where clause for this DBSelect

setOrderByFields

public void setOrderByFields(java.lang.String... obf)
Sets the order-by fields

Parameters:
obf - The field names by which the returned results set will be sorted

hasOrderByFields

public boolean hasOrderByFields()
Returns true if this DBSelect has order-by fields defined

Returns:
True if this DBSelect has order-by fields defined

setOrderAscending

public void setOrderAscending(boolean ascending)
Set ascending/descending sort order

Parameters:
ascending - True to sort ascending, false to sort descending

isOrderAscending

public boolean isOrderAscending()
Returns true if the ording is ascending, false if descending

Returns:
True if the ording is ascending, false if descending

getOrderByFields

public java.lang.String[] getOrderByFields()
Gets the order-byte fields

Returns:
An array of order-by fields, or null if no order-by fields have been defined

supportsLimit

public boolean supportsLimit()
Returns true if the DBProvider supports a LIMIT clause

Returns:
True if the DBProvider supports a LIMIT clause

setLimit

public void setLimit(long limit)
Sets the LIMIT for this DBSelect

Parameters:
limit - The record limit

hasLimit

public boolean hasLimit()
Returns true if a limit has been defined for this DBSelect

Returns:
True if a limit has been defined for this DBSelect

getLimit

public long getLimit()
Gets the defined limit

Returns:
The defined limit, or -1 if no limit has been defined

supportsOffset

public boolean supportsOffset()
Returns true if the DBProvider supports a OFFSET clause

Returns:
True if the DBProvider supports a OFFSET clause

setOffset

public void setOffset(long offset)
Sets the OFFSET for this DBSelect

Parameters:
offset - The record offset

hasOffset

public boolean hasOffset()
Returns true if a offset has been defined for this DBSelect

Returns:
True if a offset has been defined for this DBSelect

getOffset

public long getOffset()
Gets the defined offset

Returns:
The defined offset, or -1 if no offset has been defined

setLastRecordKey

public void setLastRecordKey(DBRecordKey<gDBR> rcdKey)
Sets the DBRecordKey of the last record retrieved by this DBSelect.
Called by DBRecordIterator to allow subclasses of this DBSelect to adjust the selection criteria if necessary.

Parameters:
rcdKey - The DBRecordKey of the last record retrieved by this DBSelect.

toString

public java.lang.String toString(java.lang.String dbpName)
Returns the DBSelect statement as a String representation, for the specified DBProvider name. (used for debugging purposes)

Parameters:
dbpName - The DBProvider name
Returns:
The DBSelect statement as a String representation

toString

public java.lang.String toString()
Returns the DBSelect statement as a String representation

Overrides:
toString in class java.lang.Object
Returns:
The DBSelect statement as a String representation