org.modeshape.graph.query.process
Class QueryResultColumns

java.lang.Object
  extended by org.modeshape.graph.query.process.QueryResultColumns
All Implemented Interfaces:
Serializable, QueryResults.Columns
Direct Known Subclasses:
FullTextSearchResultColumns

@Immutable
public class QueryResultColumns
extends Object
implements QueryResults.Columns

Defines the columns associated with the results of a query. This definition allows the values to be accessed

See Also:
Serialized Form

Field Summary
protected static String DEFAULT_SELECTOR_NAME
           
protected static QueryResultColumns EMPTY
           
protected static List<Column> NO_COLUMNS
           
 
Constructor Summary
protected QueryResultColumns(boolean includeFullTextSearchScores, List<Column> columns)
          Create a new definition for the query results given the supplied columns.
  QueryResultColumns(List<Column> columns, boolean includeFullTextSearchScores)
          Create a new definition for the query results given the supplied columns.
 
Method Summary
static QueryResultColumns empty()
          Get an empty results column definition.
 boolean equals(Object obj)
          
 int getColumnCount()
          Get the number of columns in each tuple.
 int getColumnIndexForName(String columnName)
          Get the index of the column given the column name.
 int getColumnIndexForProperty(String selectorName, String propertyName)
          Get the index of the column given the name of the selector and the property name from where the column should be obtained.
 List<String> getColumnNames()
          Get the names of the columns.
 List<Column> getColumns()
          Get the columns.
 int getFullTextSearchScoreIndexFor(String selectorName)
          Get the index of the tuple value containing the full-text search score for the node taken from the named selector.
 int getLocationCount()
          Get the number of Location objects in each tuple.
 int getLocationIndex(String selectorName)
          Get the index of a tuple's correct Location object given the name of the selector used in the query.
 int getLocationIndexForColumn(int columnIndex)
          Get the index of a tuple's correct Location object given the column index.
 int getLocationIndexForColumn(String columnName)
          Get the index of a tuple's correct Location object given the column index.
 String getPropertyNameForColumn(int columnIndex)
          Get the name of the property that corresponds to the supplied column in each tuple.
 String getPropertyNameForColumn(String columnName)
          Get the name of the property that corresponds to the supplied column in each tuple.
 List<String> getSelectorNames()
          Get the names of the selectors that are associated with these results.
 int getTupleSize()
          Get the size of the tuple arrays.
 List<String> getTupleValueNames()
          Get the names of the all of the tuple values.
 boolean hasFullTextSearchScores()
          Determine whether these results include full-text search scores.
 boolean hasSelector(String selectorName)
          Determine if these results contain values from the selector with the supplied name.
static boolean includeFullTextScores(Constraint constraint)
           
static boolean includeFullTextScores(Iterable<Constraint> constraints)
           
 boolean includes(QueryResults.Columns other)
          Determine whether this mapping includes all of the columns (and locations) in the supplied mapping.
 boolean isUnionCompatible(QueryResults.Columns other)
          Determine whether this column and the other are union-compatible (that is, having the same columns).
 QueryResults.Columns subSelect(Column... columns)
          Obtain a new definition for the query results that can be used to reference the same tuples that use this columns definition, but that defines a subset of the columns in this definition.
 QueryResults.Columns subSelect(List<Column> columns)
          Obtain a new definition for the query results that can be used to reference the same tuples that use this columns definition, but that defines a subset of the columns in this definition.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_COLUMNS

protected static final List<Column> NO_COLUMNS

EMPTY

protected static final QueryResultColumns EMPTY

DEFAULT_SELECTOR_NAME

protected static final String DEFAULT_SELECTOR_NAME
See Also:
Constant Field Values
Constructor Detail

QueryResultColumns

public QueryResultColumns(List<Column> columns,
                          boolean includeFullTextSearchScores)
Create a new definition for the query results given the supplied columns.

Parameters:
columns - the columns that define the results; should never be modified directly
includeFullTextSearchScores - true if room should be made in the tuples for the full-text search scores for each Location, or false otherwise

QueryResultColumns

protected QueryResultColumns(boolean includeFullTextSearchScores,
                             List<Column> columns)
Create a new definition for the query results given the supplied columns.

Parameters:
includeFullTextSearchScores - true if room should be made in the tuples for the full-text search scores for each Location, or false otherwise
columns - the columns that define the results; should never be modified directly
Method Detail

empty

public static QueryResultColumns empty()
Get an empty results column definition.

Returns:
the empty columns definition; never null

includeFullTextScores

public static boolean includeFullTextScores(Iterable<Constraint> constraints)

includeFullTextScores

public static boolean includeFullTextScores(Constraint constraint)

subSelect

public QueryResults.Columns subSelect(List<Column> columns)
Obtain a new definition for the query results that can be used to reference the same tuples that use this columns definition, but that defines a subset of the columns in this definition. This is useful in a PROJECT operation, since that reduces the number of columns.

Specified by:
subSelect in interface QueryResults.Columns
Parameters:
columns - the new columns, which must be a subset of the columns in this definition; may not be null
Returns:
the new columns definition; never null
See Also:
QueryResults.Columns.subSelect(java.util.List)

subSelect

public QueryResults.Columns subSelect(Column... columns)
Obtain a new definition for the query results that can be used to reference the same tuples that use this columns definition, but that defines a subset of the columns in this definition. This is useful in a PROJECT operation, since that reduces the number of columns.

Specified by:
subSelect in interface QueryResults.Columns
Parameters:
columns - the new columns, which must be a subset of the columns in this definition; may not be null
Returns:
the new columns definition; never null
See Also:
QueryResults.Columns.subSelect(org.modeshape.graph.query.model.Column[])

getColumns

public List<Column> getColumns()
Get the columns.

Specified by:
getColumns in interface QueryResults.Columns
Returns:
the immutable list of columns, with size equal to QueryResults.Columns.getColumnCount(); never null
See Also:
QueryResults.Columns.getColumns()

getColumnNames

public List<String> getColumnNames()
Get the names of the columns.

Specified by:
getColumnNames in interface QueryResults.Columns
Returns:
the immutable list of column names, with size equal to QueryResults.Columns.getColumnCount(); never null
See Also:
QueryResults.Columns.getColumnNames()

getColumnCount

public int getColumnCount()
Get the number of columns in each tuple.

Specified by:
getColumnCount in interface QueryResults.Columns
Returns:
the number of columns; always positive
See Also:
QueryResults.Columns.getColumnCount()

getLocationCount

public int getLocationCount()
Get the number of Location objects in each tuple.

Specified by:
getLocationCount in interface QueryResults.Columns
Returns:
the number of Location objects; always positive
See Also:
QueryResults.Columns.getLocationCount()

getSelectorNames

public List<String> getSelectorNames()
Get the names of the selectors that are associated with these results. These results contain a single Location object for each of the selectors.

Specified by:
getSelectorNames in interface QueryResults.Columns
Returns:
the immutable list of selector names, with size equal to QueryResults.Columns.getLocationCount(); never null
See Also:
QueryResults.Columns.getSelectorNames()

getTupleSize

public int getTupleSize()
Get the size of the tuple arrays.

Specified by:
getTupleSize in interface QueryResults.Columns
Returns:
the length of each tuple array
See Also:
QueryResults.Columns.getTupleSize()

getTupleValueNames

public List<String> getTupleValueNames()
Get the names of the all of the tuple values.

Specified by:
getTupleValueNames in interface QueryResults.Columns
Returns:
the immutable list of names
See Also:
QueryResults.Columns.getTupleValueNames()

getLocationIndexForColumn

public int getLocationIndexForColumn(int columnIndex)
Get the index of a tuple's correct Location object given the column index.

Specified by:
getLocationIndexForColumn in interface QueryResults.Columns
Parameters:
columnIndex - the column index
Returns:
the Location index that corresponds to the supplied column; never negative
See Also:
QueryResults.Columns.getLocationIndexForColumn(int)

getLocationIndexForColumn

public int getLocationIndexForColumn(String columnName)
Get the index of a tuple's correct Location object given the column index.

Specified by:
getLocationIndexForColumn in interface QueryResults.Columns
Parameters:
columnName - the column name
Returns:
the Location index that corresponds to the supplied column; never negative
See Also:
QueryResults.Columns.getLocationIndexForColumn(java.lang.String)

getLocationIndex

public int getLocationIndex(String selectorName)
Get the index of a tuple's correct Location object given the name of the selector used in the query.

Specified by:
getLocationIndex in interface QueryResults.Columns
Parameters:
selectorName - the selector name
Returns:
the Location index that corresponds to the supplied column; never negative
See Also:
QueryResults.Columns.getLocationIndex(java.lang.String)

hasSelector

public boolean hasSelector(String selectorName)
Determine if these results contain values from the selector with the supplied name.

Specified by:
hasSelector in interface QueryResults.Columns
Parameters:
selectorName - the selector name
Returns:
true if the results have values from the supplied selector, or false otherwise
See Also:
QueryResults.Columns.hasSelector(java.lang.String)

getPropertyNameForColumn

public String getPropertyNameForColumn(int columnIndex)
Get the name of the property that corresponds to the supplied column in each tuple.

Specified by:
getPropertyNameForColumn in interface QueryResults.Columns
Parameters:
columnIndex - the column index
Returns:
the property name; never null
See Also:
QueryResults.Columns.getPropertyNameForColumn(int)

getPropertyNameForColumn

public String getPropertyNameForColumn(String columnName)
Get the name of the property that corresponds to the supplied column in each tuple.

Specified by:
getPropertyNameForColumn in interface QueryResults.Columns
Parameters:
columnName - the column name
Returns:
the property name; never null
See Also:
QueryResults.Columns.getPropertyNameForColumn(java.lang.String)

getColumnIndexForName

public int getColumnIndexForName(String columnName)
Get the index of the column given the column name.

Specified by:
getColumnIndexForName in interface QueryResults.Columns
Parameters:
columnName - the column name
Returns:
the column index
See Also:
QueryResults.Columns.getColumnIndexForName(java.lang.String)

getColumnIndexForProperty

public int getColumnIndexForProperty(String selectorName,
                                     String propertyName)
Get the index of the column given the name of the selector and the property name from where the column should be obtained.

Specified by:
getColumnIndexForProperty in interface QueryResults.Columns
Parameters:
selectorName - the selector name
propertyName - the name of the property
Returns:
the column index that corresponds to the supplied column; never negative
See Also:
QueryResults.Columns.getColumnIndexForProperty(java.lang.String, java.lang.String)

getFullTextSearchScoreIndexFor

public int getFullTextSearchScoreIndexFor(String selectorName)
Get the index of the tuple value containing the full-text search score for the node taken from the named selector.

Specified by:
getFullTextSearchScoreIndexFor in interface QueryResults.Columns
Parameters:
selectorName - the selector name
Returns:
the index that corresponds to the Double full-text search score, or -1 if there is no full-text search score for the named selector
See Also:
QueryResults.Columns.getFullTextSearchScoreIndexFor(java.lang.String)

hasFullTextSearchScores

public boolean hasFullTextSearchScores()
Determine whether these results include full-text search scores.

Specified by:
hasFullTextSearchScores in interface QueryResults.Columns
Returns:
true if the full-text search scores are included in the results, or false otherwise
See Also:
QueryResults.Columns.hasFullTextSearchScores()

includes

public boolean includes(QueryResults.Columns other)
Determine whether this mapping includes all of the columns (and locations) in the supplied mapping.

Specified by:
includes in interface QueryResults.Columns
Parameters:
other - the other mapping; may not be null
Returns:
true if all of the other mapping's columns and locations are included in this mapping, or false otherwise
See Also:
QueryResults.Columns.includes(org.modeshape.graph.query.QueryResults.Columns)

isUnionCompatible

public boolean isUnionCompatible(QueryResults.Columns other)
Determine whether this column and the other are union-compatible (that is, having the same columns).

Specified by:
isUnionCompatible in interface QueryResults.Columns
Parameters:
other - the other mapping; may not be null
Returns:
true if this and the supplied columns definition are union-compatible, or false if they are not
See Also:
QueryResults.Columns.isUnionCompatible(org.modeshape.graph.query.QueryResults.Columns)

equals

public boolean equals(Object obj)

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

toString

public String toString()

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


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