com.javaranch.db
Class DBQuery

java.lang.Object
  |
  +--com.javaranch.db.DBQuery

public class DBQuery
extends java.lang.Object


Constructor Summary
DBQuery(java.lang.String table)
           
DBQuery(java.lang.String table, java.lang.String column, int searchValue)
           
DBQuery(java.lang.String table, java.lang.String column, int[] searchValues)
           
DBQuery(java.lang.String table, java.lang.String column, int[] searchValues, java.lang.String[] dataColumns)
           
DBQuery(java.lang.String table, java.lang.String column, int searchValue, java.lang.String[] dataColumns)
           
DBQuery(java.lang.String table, java.lang.String column, java.lang.String searchText)
           
DBQuery(java.lang.String table, java.lang.String column, java.lang.String[] searchText)
           
DBQuery(java.lang.String table, java.lang.String column, java.lang.String[] searchText, java.lang.String[] dataColumns)
           
DBQuery(java.lang.String table, java.lang.String column, java.lang.String searchText, java.lang.String[] dataColumns)
           
 
Method Summary
 void addSearch(java.lang.String column, int searchValue)
           
 void addSearch(java.lang.String column, int[] searchValues)
          Add search parameters to the existing search using 'AND'.
 void addSearch(java.lang.String column, java.lang.String searchText)
          Add search parameters to the existing search using 'AND'.
 void addSearch(java.lang.String column, java.lang.String[] searchText)
          Add search parameters to the existing search using 'AND'.
 void addStartsWithSearch(java.lang.String column, java.lang.String substring)
          Add search parameters to the existing search using 'AND', looking for a substring at the beginning of a column.
 void addSubstringSearch(java.lang.String column, java.lang.String substring)
          Add search parameters to the existing search using 'AND', looking for a substring within a column.
 boolean equals(java.lang.Object obj)
           
 java.lang.String[] getDataColumns()
          For use by DBFacade.
 java.lang.String getOrderByClause()
          For use by DBFacade.
 java.lang.String getSQL()
           
 java.lang.String getTable()
          For use by DBFacade.
 java.lang.String getWhereClause()
          For use by DBFacade.
 int hashCode()
           
 void setDataColumns(java.lang.String[] dataColumns)
          Specify the columns you want to get back from the query.
 void setOrderByClause(java.lang.String orderBy)
          Specify the order to receive the data.
 void setSearch(java.lang.String column, int searchValue)
           
 void setSearch(java.lang.String column, int[] searchValues)
           
 void setSearch(java.lang.String column, java.lang.String searchText)
          The heart of this query object.
 void setSearch(java.lang.String column, java.lang.String[] searchText)
           
 void setStartsWithSearch(java.lang.String column, java.lang.String substring)
          Set the query search to look for a substring at the beginning of a column.
 void setSubstringSearch(java.lang.String column, java.lang.String substring)
          Set the query search to look for a substring within a column.
 void setWhereClause(java.lang.String whereClause)
          In case you want to use an 'interesting' where clause that DBQuery cannot create otherwise.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DBQuery

public DBQuery(java.lang.String table)

DBQuery

public DBQuery(java.lang.String table,
               java.lang.String column,
               java.lang.String searchText)

DBQuery

public DBQuery(java.lang.String table,
               java.lang.String column,
               int searchValue)

DBQuery

public DBQuery(java.lang.String table,
               java.lang.String column,
               int[] searchValues)

DBQuery

public DBQuery(java.lang.String table,
               java.lang.String column,
               java.lang.String[] searchText)

DBQuery

public DBQuery(java.lang.String table,
               java.lang.String column,
               java.lang.String searchText,
               java.lang.String[] dataColumns)

DBQuery

public DBQuery(java.lang.String table,
               java.lang.String column,
               java.lang.String[] searchText,
               java.lang.String[] dataColumns)
Parameters:
searchText - An "OR" will be used between each searchText item.

DBQuery

public DBQuery(java.lang.String table,
               java.lang.String column,
               int searchValue,
               java.lang.String[] dataColumns)

DBQuery

public DBQuery(java.lang.String table,
               java.lang.String column,
               int[] searchValues,
               java.lang.String[] dataColumns)
Parameters:
searchValues - An "OR" will be used between each searchValues item.
Method Detail

setOrderByClause

public void setOrderByClause(java.lang.String orderBy)
Specify the order to receive the data.

Parameters:
orderBy - Pass in null if order is not important, otherwise pass in the SQL that would normally follow the "ORDER BY" SQL phrase - usually, this is simply the name of a column.


setSearch

public void setSearch(java.lang.String column,
                      java.lang.String searchText)
The heart of this query object.


addSearch

public void addSearch(java.lang.String column,
                      java.lang.String searchText)
Add search parameters to the existing search using 'AND'.


setSearch

public void setSearch(java.lang.String column,
                      int searchValue)

addSearch

public void addSearch(java.lang.String column,
                      int searchValue)

setSubstringSearch

public void setSubstringSearch(java.lang.String column,
                               java.lang.String substring)
Set the query search to look for a substring within a column. Creates a SQL "LIKE" query statement.

Parameters:
substring - the string fragment to look for in a column.

addSubstringSearch

public void addSubstringSearch(java.lang.String column,
                               java.lang.String substring)
Add search parameters to the existing search using 'AND', looking for a substring within a column. Creates a SQL "LIKE" query statement.

Parameters:
substring - the string fragment to look for in a column.

setStartsWithSearch

public void setStartsWithSearch(java.lang.String column,
                                java.lang.String substring)
Set the query search to look for a substring at the beginning of a column. Creates a SQL "LIKE" query statement.

Parameters:
substring - the string fragment to look for in a column.

addStartsWithSearch

public void addStartsWithSearch(java.lang.String column,
                                java.lang.String substring)
Add search parameters to the existing search using 'AND', looking for a substring at the beginning of a column. Creates a SQL "LIKE" query statement.

Parameters:
substring - the string fragment to look for in a column.

setSearch

public void setSearch(java.lang.String column,
                      java.lang.String[] searchText)
Parameters:
searchText - The array of strings will be used to build a SQL "IN" statement.

addSearch

public void addSearch(java.lang.String column,
                      java.lang.String[] searchText)
Add search parameters to the existing search using 'AND'.

Parameters:
searchText - The array of strings will be used to build a SQL "IN" statement.

setSearch

public void setSearch(java.lang.String column,
                      int[] searchValues)
Parameters:
searchValues - The array of strings will be used to build a SQL "IN" statement.

addSearch

public void addSearch(java.lang.String column,
                      int[] searchValues)
Add search parameters to the existing search using 'AND'.

Parameters:
searchValues - The array of strings will be used to build a SQL "IN" statement.

setWhereClause

public void setWhereClause(java.lang.String whereClause)
In case you want to use an 'interesting' where clause that DBQuery cannot create otherwise.


setDataColumns

public void setDataColumns(java.lang.String[] dataColumns)
Specify the columns you want to get back from the query.


getDataColumns

public java.lang.String[] getDataColumns()
For use by DBFacade. Made public for use by unit tests.


getTable

public java.lang.String getTable()
For use by DBFacade. Made public for use by unit tests.


getWhereClause

public java.lang.String getWhereClause()
For use by DBFacade. Made public for use by unit tests.


getOrderByClause

public java.lang.String getOrderByClause()
For use by DBFacade. Made public for use by unit tests.


hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSQL

public java.lang.String getSQL()


Copyright ©2004 Paul Wheaton All Rights Reserved