org.apache.turbine.util.db
Class Query

java.lang.Object
  |
  +--org.apache.turbine.util.db.Query

public class Query
extends java.lang.Object

Used to assemble an SQL SELECT query. Attributes exist for the sections of a SELECT: modifiers, columns, from clause, where clause, and order by clause. The various parts of the query are appended to buffers which only accept unique entries. This class is used primarily by BasePeer.

Version:
$Id$
Author:
John D. McNally

Field Summary
private static java.lang.String AND
           
private static java.lang.String BETWEEN
           
private static java.lang.String FROM
           
private  StringStackBuffer fromTables
           
private static java.lang.String IN
           
private  java.lang.String limit
           
private static java.lang.String LIMIT
           
private static java.lang.String OR
           
private static java.lang.String ORDER_BY
           
private  StringStackBuffer orderByColumns
           
private  java.lang.String rowcount
           
private static java.lang.String ROWCOUNT
           
private static java.lang.String SELECT
           
private  StringStackBuffer selectColumns
           
private  StringStackBuffer selectModifiers
           
private static java.lang.String WHERE
           
private  StringStackBuffer whereCriteria
           
 
Constructor Summary
Query()
           
 
Method Summary
 StringStackBuffer getFromClause()
          Retrieve the from buffer in order to specify which tables are involved in this query.
 java.lang.String getLimit()
          Get the limit number.
 StringStackBuffer getOrderByClause()
          Retrieve the order by columns buffer in order to specify which columns are used to sort the results of the query.
 java.lang.String getRowcount()
          Get the rowcount number.
 StringStackBuffer getSelectClause()
          Retrieve the columns buffer in order to specify which columns are returned in this query.
 StringStackBuffer getSelectModifiers()
          Retrieve the modifier buffer in order to add modifiers to this query.
 StringStackBuffer getWhereClause()
          Retrieve the where buffer in order to specify the selection criteria E.g.
 void setLimit(java.lang.String limit)
          Set the limit number.
 void setRowcount(java.lang.String rowcount)
          Set the rowcount number.
 java.lang.String toString()
          Outputs the query statement.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

SELECT

private static final java.lang.String SELECT

FROM

private static final java.lang.String FROM

WHERE

private static final java.lang.String WHERE

AND

private static final java.lang.String AND

OR

private static final java.lang.String OR

ORDER_BY

private static final java.lang.String ORDER_BY

IN

private static final java.lang.String IN

BETWEEN

private static final java.lang.String BETWEEN

LIMIT

private static final java.lang.String LIMIT

ROWCOUNT

private static final java.lang.String ROWCOUNT

selectModifiers

private StringStackBuffer selectModifiers

selectColumns

private StringStackBuffer selectColumns

fromTables

private StringStackBuffer fromTables

whereCriteria

private StringStackBuffer whereCriteria

orderByColumns

private StringStackBuffer orderByColumns

limit

private java.lang.String limit

rowcount

private java.lang.String rowcount
Constructor Detail

Query

public Query()
Method Detail

getSelectModifiers

public StringStackBuffer getSelectModifiers()
Retrieve the modifier buffer in order to add modifiers to this query. E.g. DISTINCT and ALL.
Returns:
A StringStackBuffer used to add modifiers.

getSelectClause

public StringStackBuffer getSelectClause()
Retrieve the columns buffer in order to specify which columns are returned in this query.
Returns:
A StringStackBuffer used to add columns to be selected.

getFromClause

public StringStackBuffer getFromClause()
Retrieve the from buffer in order to specify which tables are involved in this query.
Returns:
A StringStackBuffer used to add tables involved in the query.

getWhereClause

public StringStackBuffer getWhereClause()
Retrieve the where buffer in order to specify the selection criteria E.g. column_a=3. Expressions added to the buffer will be separated using AND.
Returns:
A StringStackBuffer used to add selection criteria.

getOrderByClause

public StringStackBuffer getOrderByClause()
Retrieve the order by columns buffer in order to specify which columns are used to sort the results of the query.
Returns:
A StringStackBuffer used to add columns to sort on.

setLimit

public void setLimit(java.lang.String limit)
Set the limit number. This is used to limit the number of rows returned by a query, and the row where the resultset starts.
Parameters:
limit - A String.

setRowcount

public void setRowcount(java.lang.String rowcount)
Set the rowcount number. This is used to limit the number of rows returned by Sybase and MS SQL/Server.
Parameters:
rowcount - A String.

getLimit

public java.lang.String getLimit()
Get the limit number. This is used to limit the number of returned by a query in Postgres.
Returns:
A String with the limit.

getRowcount

public java.lang.String getRowcount()
Get the rowcount number. This is used to limit the number of returned by a query in Sybase and MS SQL/Server.
Returns:
A String with the row count.

toString

public java.lang.String toString()
Outputs the query statement.
Overrides:
toString in class java.lang.Object
Returns:
A String with the query statement.


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.