|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.intermine.sql.query.Query
public class Query
Represents an SQL query in parsed form.
| Field Summary | |
|---|---|
protected boolean |
distinct
|
protected boolean |
explain
|
protected java.util.Set<AbstractTable> |
from
|
protected java.util.Set<AbstractValue> |
groupBy
|
protected java.util.Set<AbstractConstraint> |
having
|
protected int |
limit
|
protected int |
offset
|
protected java.util.List<AbstractValue> |
orderBy
|
protected java.util.List<Query> |
queriesInUnion
|
protected java.util.List<SelectValue> |
select
|
protected java.util.Set<AbstractConstraint> |
where
|
| Constructor Summary | |
|---|---|
Query()
Construct a new Query. |
|
Query(java.util.Map<java.lang.String,AbstractTable> aliasToTable)
Construct a new Query. |
|
Query(java.util.Map<java.lang.String,AbstractTable> aliasToTable,
java.util.List<Query> queriesInUnion)
Construct a new Query. |
|
Query(java.lang.String sql)
Construct a new parsed Query from a String. |
|
Query(java.lang.String sql,
boolean treeParse)
Construct a new parsed Query from a String. |
|
| Method Summary | |
|---|---|
void |
addFrom(AbstractTable obj)
Adds a table to the from list of this query. |
void |
addGroupBy(AbstractValue obj)
Adds a field to the GROUP BY clause of this query. |
void |
addHaving(AbstractConstraint obj)
Adds a constraint to the HAVING clause of this query. |
void |
addOrderBy(AbstractValue obj)
Adds a field to the ORDER BY clause of this query. |
void |
addSelect(SelectValue obj)
Adds a field to the select list of this query. |
void |
addToUnion(Query query)
Adds another Query to the UNION set of this query. |
void |
addWhere(AbstractConstraint obj)
Adds a constraint to the where clause for this query. |
protected static java.lang.String |
collectionToSQLString(java.util.Collection<? extends SQLStringable> c,
java.util.Collection<java.lang.String> extraValues,
java.lang.String comma)
Converts a collection of objects that implement the getSQLString method into a String, with the given comma string between each element. |
protected static java.lang.String |
collectionToSQLString(java.util.Collection<? extends SQLStringable> c,
java.lang.String comma)
Converts a collection of objects that implement the getSQLString method into a String, with the given comma string between each element. |
boolean |
equals(java.lang.Object obj)
Overrides Object.equals(). |
boolean |
equalsNoUnion(java.lang.Object obj)
Returns true if this Query is equivalent to obj, disregarding other queries in the UNION. |
java.util.Set<AbstractTable> |
getFrom()
Gets the Set of from tables for this query. |
java.util.Set<AbstractValue> |
getGroupBy()
Gets the Set of fields in the GROUP BY clause of this query. |
java.util.Set<AbstractConstraint> |
getHaving()
Gets the set of constraints forming the HAVING clause of this query. |
int |
getLimit()
Gets the LIMIT number for this query. |
int |
getOffset()
Gets the OFFSET number for this query. |
java.util.List<AbstractValue> |
getOrderBy()
Gets the list of fields forming the ORDER BY clause of this query. |
java.util.List<SelectValue> |
getSelect()
Gets the list of select fields for this query. |
java.lang.String |
getSQLString()
Convert this Query into a SQL String query. |
java.lang.String |
getSQLStringForPrecomputedTable(java.lang.String extraSelect)
Convert this Query into a SQL String query, without regard to the other members of the the UNION, with an extra field in the SELECT list. |
java.lang.String |
getSQLStringNoUnion()
Convert this Query into a SQL String query, without regard to the other members of the UNION. |
java.util.List<Query> |
getUnion()
Returns the List of queries in the UNION set of this query. |
java.util.Set<AbstractConstraint> |
getWhere()
Gets the Set of constraints in the where clause of this query. |
int |
hashCode()
Overrides Object.hashCode(). |
int |
hashCodeNoUnion()
Returns a partial hashcode, ignoring other queries in the union. |
boolean |
isDistinct()
Gets the current distinct status of this query. |
boolean |
isExplain()
Gets the current explain status of this query. |
static void |
main(java.lang.String[] args)
A testing method - converts the argument into a Query object, and then converts it back to a String again. |
void |
processGroupClause(antlr.collections.AST ast)
Processes an AST node that describes a GROUP clause. |
void |
processLimitClause(antlr.collections.AST ast)
Processes an AST node that describes a Limit clause. |
AbstractConstraint |
processNewAbstractConstraint(antlr.collections.AST ast)
Processes an AST node that describes an AbstractConstraint. |
AbstractValue |
processNewAbstractValue(antlr.collections.AST ast)
Processes a single AST node that describes an AbstractValue. |
Field |
processNewField(antlr.collections.AST ast)
Processes an AST node that describes a Field. |
Function |
processNewSafeFunction(antlr.collections.AST ast)
Processes an AST node that describes a safe function. |
void |
processNewSelect(antlr.collections.AST ast)
Processes an AST node that describes a SelectValue. |
Function |
processNewTypecast(antlr.collections.AST ast)
Processes an AST node that describes a typecast. |
Function |
processNewUnsafeFunction(antlr.collections.AST ast)
Processes an AST node that describes an unsafe function. |
void |
processOrderClause(antlr.collections.AST ast)
Processes an AST node that describes a ORDER clause. |
void |
processSelectList(antlr.collections.AST ast)
Processes an AST node that describes a SELECT list. |
void |
setDistinct(boolean distinct)
Sets the distinct status of this query. |
void |
setExplain(boolean explain)
Sets the explain status of this query. |
void |
setLimitOffset(int limit,
int offset)
Sets the LIMIT and OFFSET numbers for this query. |
java.lang.String |
toString()
Overrides Object.toString(). |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected java.util.List<SelectValue> select
protected java.util.Set<AbstractTable> from
protected java.util.Set<AbstractConstraint> where
protected java.util.Set<AbstractValue> groupBy
protected java.util.Set<AbstractConstraint> having
protected java.util.List<AbstractValue> orderBy
protected int limit
protected int offset
protected boolean explain
protected boolean distinct
protected java.util.List<Query> queriesInUnion
| Constructor Detail |
|---|
public Query()
public Query(java.util.Map<java.lang.String,AbstractTable> aliasToTable)
aliasToTable - a map of tables in a surrounding query, which are in the scope of this
query.
public Query(java.util.Map<java.lang.String,AbstractTable> aliasToTable,
java.util.List<Query> queriesInUnion)
aliasToTable - a Map of tables in a surrounding query, which are in the scope of this
queryqueriesInUnion - a List of Queries which are in the currently-being-created UNION of
queries, to which this constructor should add thispublic Query(java.lang.String sql)
sql - a SQL SELECT String to parse
java.lang.IllegalArgumentException - if the SQL String is invalid
public Query(java.lang.String sql,
boolean treeParse)
sql - a SQL SELECT String to parsetreeParse - true if a tree-parse step is required (usually so)
java.lang.IllegalArgumentException - if the SQL String is invalid| Method Detail |
|---|
public boolean isDistinct()
public void setDistinct(boolean distinct)
distinct - the new distinct statuspublic boolean isExplain()
public void setExplain(boolean explain)
explain - the new explain statuspublic java.util.List<SelectValue> getSelect()
public void addSelect(SelectValue obj)
obj - a SelectValue to add to the listpublic java.util.Set<AbstractTable> getFrom()
public void addFrom(AbstractTable obj)
obj - an AbstractTable to add to the setpublic java.util.Set<AbstractConstraint> getWhere()
public void addWhere(AbstractConstraint obj)
obj - an AbstractConstraint to add to the where clausepublic java.util.Set<AbstractValue> getGroupBy()
public void addGroupBy(AbstractValue obj)
obj - an AbstractValue to add to the GROUP BY clausepublic java.util.Set<AbstractConstraint> getHaving()
public void addHaving(AbstractConstraint obj)
obj - an AbstractConstraint to add to the HAVING clausepublic java.util.List<AbstractValue> getOrderBy()
public void addOrderBy(AbstractValue obj)
obj - an AbstractValue to add to the ORDER BY clausepublic int getLimit()
public int getOffset()
public void setLimitOffset(int limit,
int offset)
limit - the LIMIT numberoffset - the OFFSET numberpublic void addToUnion(Query query)
query - the Query to UNION with this Querypublic java.util.List<Query> getUnion()
public java.lang.String getSQLString()
getSQLString in interface SQLStringablepublic java.lang.String getSQLStringNoUnion()
public java.lang.String getSQLStringForPrecomputedTable(java.lang.String extraSelect)
extraSelect - an extra String to put into the select list
protected static java.lang.String collectionToSQLString(java.util.Collection<? extends SQLStringable> c,
java.lang.String comma)
c - the Collection of SQLStringable objectscomma - the String to use as a separator between elements
protected static java.lang.String collectionToSQLString(java.util.Collection<? extends SQLStringable> c,
java.util.Collection<java.lang.String> extraValues,
java.lang.String comma)
c - the Collection of SQLStringable objectsextraValues - a Collection of extra values which are Strings to addcomma - the String to use as a separator between elements
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - an Object to compare to
public boolean equalsNoUnion(java.lang.Object obj)
obj - the object to compare to
public int hashCode()
hashCode in class java.lang.Objectpublic int hashCodeNoUnion()
public java.lang.String toString()
toString in class java.lang.Objectpublic void processSelectList(antlr.collections.AST ast)
ast - an AST node to processpublic void processNewSelect(antlr.collections.AST ast)
ast - an AST node to processpublic void processGroupClause(antlr.collections.AST ast)
ast - an AST node to processpublic void processOrderClause(antlr.collections.AST ast)
ast - an AST node to processpublic AbstractValue processNewAbstractValue(antlr.collections.AST ast)
ast - as AST node to process
public Field processNewField(antlr.collections.AST ast)
ast - an AST node to process
public Function processNewTypecast(antlr.collections.AST ast)
ast - an AST node to process
public Function processNewUnsafeFunction(antlr.collections.AST ast)
ast - an AST node to process
public Function processNewSafeFunction(antlr.collections.AST ast)
ast - an AST node to process
public AbstractConstraint processNewAbstractConstraint(antlr.collections.AST ast)
ast - an AST node to process
public void processLimitClause(antlr.collections.AST ast)
ast - an AST node to process
public static void main(java.lang.String[] args)
throws java.lang.Exception
args - command-line arguments
java.lang.Exception - anytime
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||