uk.ac.ic.doc.automed.wrappers
Class SQLQuery

java.lang.Object
  extended by uk.ac.ic.doc.automed.wrappers.AutoMedQuery
      extended by uk.ac.ic.doc.automed.wrappers.SQLQuery

public class SQLQuery
extends AutoMedQuery

An SQLQuery expression tree that can be generated by the high level wrapper SQLWrapper and used by a low level wrapper as the basis for generating SQL queries on a relational database.

Author:
Peter McBrien (pjm@doc.ic.ac.uk)

Field Summary
static AutoMedQueryToken AND
          SQL logical AND binary operator for use within WHERE expressions
static AutoMedQueryToken EQUAL
          SQL equality predicate for use within WHERE expressions
static AutoMedQueryToken FIELD
           
static AutoMedQueryToken FIELD_ALIAS
          Define an alias of a table.
static AutoMedQueryToken FROM
          The first field can contain a SQLQuery WHERE
static AutoMedQueryToken GREATERTHAN
           
static AutoMedQueryToken GREATERTHANEQUAL
           
static AutoMedQueryToken LESSTHAN
           
static AutoMedQueryToken LESSTHANEQUAL
           
static AutoMedQueryToken NOT
           
static AutoMedQueryToken NOTEQUAL
           
static AutoMedQueryToken OR
          SQL logical OR binary operator for use within WHERE expressions
static AutoMedQueryToken SELECT
          The SQL SELECT operator; the first field should contain a SQLQuery with a FROM operator, and the remaining fields should be relation attribute identifiers or constants
static AutoMedQueryToken TABLE
           
static AutoMedQueryToken TABLE_ALIAS
           
static AutoMedQueryToken UNION
          SQL UNION binary operator
static AutoMedQueryToken WHERE
          The only field should contain a logical operator or a comparison
 
Fields inherited from class uk.ac.ic.doc.automed.wrappers.AutoMedQuery
BINARY_CLASS, BOOLEAN, BOOLEAN_TOKEN, CLAUSE_CLASS, CONSTANT, CONSTANT_TOKEN, DATE_TOKEN, DOUBLE_TOKEN, FIELD_TYPE_AUTOMEDQUERY, FIELD_TYPE_INTEGER, FIELD_TYPE_ONE_OR_MORE, FIELD_TYPE_STRING, FLOAT, FLOAT_TOKEN, IDENTIFIER_TOKEN, INTEGER, INTEGER_TOKEN, LONG_TOKEN, STRING, STRING_TOKEN, SYMBOL_TOKEN, TIME, TIME_TOKEN, UNARY_CLASS, VALUE_CLASS
 
Constructor Summary
SQLQuery(AutoMedQueryToken token, java.lang.Object field)
           
SQLQuery(AutoMedQueryToken token, java.lang.Object[] fields)
           
 
Method Summary
 SQLQuery getSQLQuery(int fieldNumber)
          Return the SQLQuery held in a certain field, or null if the field is empty.
 java.lang.String toString()
          Convert this SQLQuery into a text equivalent.
 void translateToQueryText(java.lang.StringBuffer sql)
          Insert into a StringBuffer the text equivalent of this SQLQuery.
 
Methods inherited from class uk.ac.ic.doc.automed.wrappers.AutoMedQuery
getAutoMedQueryToken, getField, getString, setField
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SELECT

public static final AutoMedQueryToken SELECT
The SQL SELECT operator; the first field should contain a SQLQuery with a FROM operator, and the remaining fields should be relation attribute identifiers or constants


FROM

public static final AutoMedQueryToken FROM
The first field can contain a SQLQuery WHERE


FIELD_ALIAS

public static final AutoMedQueryToken FIELD_ALIAS
Define an alias of a table. The first field contains the real table name, the second field the alias name for the table.


WHERE

public static final AutoMedQueryToken WHERE
The only field should contain a logical operator or a comparison


OR

public static final AutoMedQueryToken OR
SQL logical OR binary operator for use within WHERE expressions


AND

public static final AutoMedQueryToken AND
SQL logical AND binary operator for use within WHERE expressions


NOT

public static final AutoMedQueryToken NOT

EQUAL

public static final AutoMedQueryToken EQUAL
SQL equality predicate for use within WHERE expressions


LESSTHAN

public static final AutoMedQueryToken LESSTHAN

LESSTHANEQUAL

public static final AutoMedQueryToken LESSTHANEQUAL

GREATERTHAN

public static final AutoMedQueryToken GREATERTHAN

GREATERTHANEQUAL

public static final AutoMedQueryToken GREATERTHANEQUAL

NOTEQUAL

public static final AutoMedQueryToken NOTEQUAL

TABLE

public static final AutoMedQueryToken TABLE

FIELD

public static final AutoMedQueryToken FIELD

TABLE_ALIAS

public static final AutoMedQueryToken TABLE_ALIAS

UNION

public static final AutoMedQueryToken UNION
SQL UNION binary operator

Constructor Detail

SQLQuery

public SQLQuery(AutoMedQueryToken token,
                java.lang.Object[] fields)

SQLQuery

public SQLQuery(AutoMedQueryToken token,
                java.lang.Object field)
Method Detail

getSQLQuery

public final SQLQuery getSQLQuery(int fieldNumber)
Return the SQLQuery held in a certain field, or null if the field is empty.

Parameters:
fieldNumber - the field to return.

translateToQueryText

public void translateToQueryText(java.lang.StringBuffer sql)
Insert into a StringBuffer the text equivalent of this SQLQuery.

Parameters:
sql - A StringBuffer that will have appended to it the text of this query.

toString

public java.lang.String toString()
Convert this SQLQuery into a text equivalent.

Overrides:
toString in class java.lang.Object
Returns:
the String version of this SQLQuery, that can be used in the native query language interface of this datasource.