org.modeshape.graph.query.process
Class QueryResults

java.lang.Object
  extended by org.modeshape.graph.query.process.QueryResults
All Implemented Interfaces:
Serializable, QueryResults

@Immutable
public class QueryResults
extends Object
implements QueryResults

The resulting output of a query.

See Also:
Serialized Form

Nested Class Summary
 class QueryResults.TupleCursor
          An interface used to walk through the results.
 
Nested classes/interfaces inherited from interface org.modeshape.graph.query.QueryResults
QueryResults.Columns, QueryResults.Cursor, QueryResults.Statistics
 
Field Summary
 
Fields inherited from interface org.modeshape.graph.query.QueryResults
FORMATTER
 
Constructor Summary
QueryResults(QueryResults.Columns columns, QueryResults.Statistics statistics)
          Create an empty QueryResults object for the supplied context, command, and result columns.
QueryResults(QueryResults.Columns columns, QueryResults.Statistics statistics, List<Object[]> tuples)
          Create a results object for the supplied context, command, and result columns and with the supplied tuples.
QueryResults(QueryResults.Columns columns, QueryResults.Statistics statistics, List<Object[]> tuples, Problems problems, String plan)
          Create a results object for the supplied context, command, and result columns and with the supplied tuples.
QueryResults(QueryResults.Columns columns, QueryResults.Statistics statistics, Problems problems)
          Create an empty QueryResults object for the supplied context, command, and result columns.
 
Method Summary
 QueryResults.Columns getColumns()
          Get the description of the columns contained in these results.
 QueryResults.Cursor getCursor()
          Get a cursor that can be used to walk through the results.
 String getPlan()
          Get a description of the query plan, if requested.
 Problems getProblems()
          Get the problems encountered during execution.
 int getRowCount()
          Get the number of rows in the results.
 QueryResults.Statistics getStatistics()
          Get the statistics that describe the time metrics for this query.
 List<Object[]> getTuples()
          Get the actual tuples that contain the results.
 boolean hasErrors()
          Return true if there is at least one error recorded in the problems.
 boolean hasWarnings()
          Return true if there is at least one warning recorded in the problems.
 String toString()
          
 String toString(TypeSystem typeSystem, int maxTuples)
          Get a string representation of this result object, with a maximum number of tuples to include.
 void toString(TypeSystem typeSystem, StringBuilder sb)
          Get a string representation of this result object.
 void toString(TypeSystem typeSystem, StringBuilder sb, int maxTuples)
          Get a string representation of this result object, with a maximum number of tuples to include.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueryResults

public QueryResults(QueryResults.Columns columns,
                    QueryResults.Statistics statistics,
                    List<Object[]> tuples,
                    Problems problems,
                    String plan)
Create a results object for the supplied context, command, and result columns and with the supplied tuples.

Parameters:
columns - the definition of the query result columns
statistics - the statistics for this query; may not be null
tuples - the tuples
problems - the problems; may be null if there are no problems
plan - the text representation of the query plan, if the hints asked for it

QueryResults

public QueryResults(QueryResults.Columns columns,
                    QueryResults.Statistics statistics,
                    List<Object[]> tuples)
Create a results object for the supplied context, command, and result columns and with the supplied tuples.

Parameters:
columns - the definition of the query result columns
statistics - the statistics for this query; may not be null
tuples - the tuples

QueryResults

public QueryResults(QueryResults.Columns columns,
                    QueryResults.Statistics statistics,
                    Problems problems)
Create an empty QueryResults object for the supplied context, command, and result columns.

Parameters:
columns - the definition of the query result columns
statistics - the statistics for this query; may not be null
problems - the problems; may be null if there are no problems

QueryResults

public QueryResults(QueryResults.Columns columns,
                    QueryResults.Statistics statistics)
Create an empty QueryResults object for the supplied context, command, and result columns.

Parameters:
columns - the definition of the query result columns
statistics - the statistics for this query; may not be null
Method Detail

getColumns

public QueryResults.Columns getColumns()
Get the description of the columns contained in these results. These columns can be used to discover the indexes of the corresponding values from the arrays representing the tuples.

Specified by:
getColumns in interface QueryResults
Returns:
the column descriptions; never null
See Also:
QueryResults.getColumns()

getCursor

public QueryResults.Cursor getCursor()
Get a cursor that can be used to walk through the results.

Specified by:
getCursor in interface QueryResults
Returns:
the cursor; never null, though possibly empty (meaning QueryResults.TupleCursor.hasNext() may return true)

getTuples

public List<Object[]> getTuples()
Get the actual tuples that contain the results. Each element in the list represents a tuple, and each tuple corresponds to the column definitions.

Specified by:
getTuples in interface QueryResults
Returns:
the list of tuples; never null but possibly empty
See Also:
QueryResults.getTuples()

getRowCount

public int getRowCount()
Get the number of rows in the results.

Specified by:
getRowCount in interface QueryResults
Returns:
the number of rows; never negative
See Also:
QueryResults.getRowCount()

getPlan

public String getPlan()
Get a description of the query plan, if requested.

Specified by:
getPlan in interface QueryResults
Returns:
the query plan, or null if the plan was not requested
See Also:
QueryResults.getPlan()

getProblems

public Problems getProblems()
Get the problems encountered during execution.

Specified by:
getProblems in interface QueryResults
Returns:
the problems; never null but possibly empty
See Also:
QueryResults.getProblems()

hasErrors

public boolean hasErrors()
Return true if there is at least one error recorded in the problems.

Specified by:
hasErrors in interface QueryResults
Returns:
true if there is one or more errors associated with the query, or false otherwise
See Also:
QueryResults.hasErrors()

hasWarnings

public boolean hasWarnings()
Return true if there is at least one warning recorded in the problems.

Specified by:
hasWarnings in interface QueryResults
Returns:
true if there is one or more warnings associated with the query, or false otherwise
See Also:
QueryResults.hasWarnings()

getStatistics

public QueryResults.Statistics getStatistics()
Get the statistics that describe the time metrics for this query.

Specified by:
getStatistics in interface QueryResults
Returns:
the statistics; never null
See Also:
QueryResults.getStatistics()

toString

public String toString()

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

toString

public String toString(TypeSystem typeSystem,
                       int maxTuples)
Get a string representation of this result object, with a maximum number of tuples to include.

Parameters:
typeSystem - the type system that can be used to convert the values to a string; may be null if Object.toString() should be used
maxTuples - the maximum number of tuples to print, or Integer.MAX_VALUE if all the tuples are to be printed
Returns:
the string representation; never null

toString

public void toString(TypeSystem typeSystem,
                     StringBuilder sb)
Get a string representation of this result object.

Parameters:
typeSystem - the type system that can be used to convert the values to a string; may be null if Object.toString() should be used
sb - the string builder to which the results should be written; may not be null

toString

public void toString(TypeSystem typeSystem,
                     StringBuilder sb,
                     int maxTuples)
Get a string representation of this result object, with a maximum number of tuples to include.

Parameters:
typeSystem - the type system that can be used to convert the values to a string; may be null if Object.toString() should be used
sb - the string builder to which the results should be written; may not be null
maxTuples - the maximum number of tuples to print, or Integer.MAX_VALUE if all the tuples are to be printed


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