org.modeshape.graph.query.model
Class Query

java.lang.Object
  extended by org.modeshape.graph.query.model.Command
      extended by org.modeshape.graph.query.model.QueryCommand
          extended by org.modeshape.graph.query.model.Query
All Implemented Interfaces:
Serializable, LanguageObject, Visitable

@Immutable
public class Query
extends QueryCommand

See Also:
Serialized Form

Field Summary
static boolean IS_DISTINCT_DEFAULT
           
 
Constructor Summary
Query(Source source)
          Create a new query that uses the supplied source.
Query(Source source, Constraint constraint, List<Ordering> orderings, List<Column> columns, Limit limit, boolean isDistinct)
          Create a new query that uses the supplied source, constraint, orderings, columns and limits.
 
Method Summary
 void accept(Visitor visitor)
          Accept the supplied visitor, which should call back to the visitor to complete the double-dispatch operation.
 Query adding(Column... columns)
          Create a copy of this query, but that returns results that include the columns specified by this query as well as the supplied columns.
 Query adding(Ordering... orderings)
          Create a copy of this query, but that returns results that are ordered by the orderings of this column as well as those supplied.
 Query constrainedBy(Constraint constraint)
          Create a copy of this query, but one that uses the supplied constraint.
 Query distinct()
          Create a copy of this query, but one in which there are no duplicate rows in the results.
 boolean equals(Object obj)
          
 List<Column> getColumns()
          Return the columns defining the query results.
 Constraint getConstraint()
          Get the constraints, if there are any.
 Source getSource()
          Get the source for the results.
 int hashCode()
          
 boolean isDistinct()
          Determine whether this query is to return only distinct values.
 Query noDistinct()
          Create a copy of this query, but one in which there may be duplicate rows in the results.
 Query orderedBy(List<Ordering> orderings)
          Create a copy of this query, but one whose results should be ordered by the supplied orderings.
 Query returning(List<Column> columns)
          Create a copy of this query, but that returns results with the supplied columns.
 String toString()
          
 Query withLimit(int rowLimit)
          Create a copy of this query, but one that uses the supplied limit on the number of result rows.
 Query withOffset(int offset)
          Create a copy of this query, but one that uses the supplied offset.
 
Methods inherited from class org.modeshape.graph.query.model.QueryCommand
getLimits, getOrderings
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

IS_DISTINCT_DEFAULT

public static final boolean IS_DISTINCT_DEFAULT
See Also:
Constant Field Values
Constructor Detail

Query

public Query(Source source)
Create a new query that uses the supplied source.

Parameters:
source - the source
Throws:
IllegalArgumentException - if the source is null

Query

public Query(Source source,
             Constraint constraint,
             List<Ordering> orderings,
             List<Column> columns,
             Limit limit,
             boolean isDistinct)
Create a new query that uses the supplied source, constraint, orderings, columns and limits.

Parameters:
source - the source
constraint - the constraint (or composite constraint), or null or empty if there are no constraints
orderings - the specifications of how the results are to be ordered, or null if the order is to be implementation determined
columns - the columns to be included in the results, or null or empty if there are no explicit columns and the actual result columns are to be implementation determiend
limit - the limit for the results, or null if all of the results are to be included
isDistinct - true if duplicates are to be removed from the results
Throws:
IllegalArgumentException - if the source is null
Method Detail

getSource

public final Source getSource()
Get the source for the results.

Returns:
the query source; never null

getConstraint

public final Constraint getConstraint()
Get the constraints, if there are any.

Returns:
the constraint; may be null

getColumns

public final List<Column> getColumns()
Return the columns defining the query results. If there are no columns, then the columns are implementation determined.

Returns:
the list of columns; never null

isDistinct

public boolean isDistinct()
Determine whether this query is to return only distinct values.

Returns:
true if the query is to remove duplicate tuples, or false otherwise

distinct

public Query distinct()
Create a copy of this query, but one in which there are no duplicate rows in the results.

Returns:
the copy of the query with no duplicate result rows; never null

noDistinct

public Query noDistinct()
Create a copy of this query, but one in which there may be duplicate rows in the results.

Returns:
the copy of the query with potentially duplicate result rows; never null

constrainedBy

public Query constrainedBy(Constraint constraint)
Create a copy of this query, but one that uses the supplied constraint.

Parameters:
constraint - the constraint that should be used; never null
Returns:
the copy of the query that uses the supplied constraint; never null

orderedBy

public Query orderedBy(List<Ordering> orderings)
Create a copy of this query, but one whose results should be ordered by the supplied orderings.

Parameters:
orderings - the result ordering specification that should be used; never null
Returns:
the copy of the query that uses the supplied ordering; never null

withLimit

public Query withLimit(int rowLimit)
Create a copy of this query, but one that uses the supplied limit on the number of result rows.

Parameters:
rowLimit - the limit that should be used; must be a positive number
Returns:
the copy of the query that uses the supplied limit; never null

withOffset

public Query withOffset(int offset)
Create a copy of this query, but one that uses the supplied offset.

Parameters:
offset - the limit that should be used; may not be negative
Returns:
the copy of the query that uses the supplied offset; never null

returning

public Query returning(List<Column> columns)
Create a copy of this query, but that returns results with the supplied columns.

Parameters:
columns - the columns of the results; may not be null
Returns:
the copy of the query returning the supplied result columns; never null

adding

public Query adding(Ordering... orderings)
Create a copy of this query, but that returns results that are ordered by the orderings of this column as well as those supplied.

Parameters:
orderings - the additional orderings of the result rows; may no be null
Returns:
the copy of the query returning the supplied result columns; never null

adding

public Query adding(Column... columns)
Create a copy of this query, but that returns results that include the columns specified by this query as well as the supplied columns.

Parameters:
columns - the additional columns that should be included in the the results; may not be null
Returns:
the copy of the query returning the supplied result columns; never null

toString

public String toString()

Overrides:
toString in class Object
See Also:
Object.toString()

hashCode

public int hashCode()

Overrides:
hashCode in class Object
See Also:
Object.hashCode()

equals

public boolean equals(Object obj)

Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

accept

public void accept(Visitor visitor)
Accept the supplied visitor, which should call back to the visitor to complete the double-dispatch operation.

Parameters:
visitor - the visitor; never null
See Also:
Visitable.accept(org.modeshape.graph.query.model.Visitor)


Copyright © 2008-2010 JBoss, a division of Red Hat. All Rights Reserved.