ModeShape Distribution 3.0.0.Beta4

org.modeshape.jcr.query.process
Class QueryResultColumns

java.lang.Object
  extended by org.modeshape.jcr.query.process.QueryResultColumns
All Implemented Interfaces:
Serializable, Iterable<Column>, QueryResults.Columns

@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
           
protected static List<String> NO_TYPES
           
 
Constructor Summary
protected QueryResultColumns(boolean includeFullTextSearchScores, List<? extends Column> columns, List<String> columnTypes)
          Create a new definition for the query results given the supplied columns.
  QueryResultColumns(List<? extends Column> columns, List<String> columnTypes, boolean includeFullTextSearchScores)
          Create a new definition for the query results given the supplied columns.
 
Method Summary
protected  Integer columnIndexForName(String columnName)
           
protected static String columnNameFor(Column column, List<String> columnNames, Set<Column> columnsWithDuplicateNames, Collection<String> selectorNames)
           
static QueryResultColumns empty()
          Get an empty results column definition.
 boolean equals(Object obj)
           
protected static Set<Column> findColumnsWithSameNames(List<Column> columns)
           
 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<? extends Column> getColumns()
          Get the columns.
 List<String> getColumnTypes()
          Get the type name for each column.
 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 QueryResults.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 getPropertyNameForColumnName(String columnName)
          Get the name of the property that corresponds to the named column in each tuple.
 String getSelectorNameForColumnName(String columnName)
          Get the name of the selector that produced the column with the given name.
 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).
 Iterator<Column> iterator()
           
 QueryResults.Columns joinWith(QueryResults.Columns rightColumns)
          Obtain a new definition for the query results that is a combination of the these columns and the supplied columns, where the columns from this object appear first, followed by columns from the supplied set.
 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

NO_TYPES

protected static final List<String> NO_TYPES

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<? extends Column> columns,
                          List<String> columnTypes,
                          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
columnTypes - the names of the types for each column in columns
includeFullTextSearchScores - true if room should be made in the tuples for the full-text search scores for each QueryResults.Location, or false otherwise

QueryResultColumns

protected QueryResultColumns(boolean includeFullTextSearchScores,
                             List<? extends Column> columns,
                             List<String> columnTypes)
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 QueryResults.Location, or false otherwise
columns - the columns that define the results; should never be modified directly
columnTypes - the names of the types for each column in columns
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)
Description copied from interface: QueryResults.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

subSelect

public QueryResults.Columns subSelect(Column... columns)
Description copied from interface: QueryResults.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

joinWith

public QueryResults.Columns joinWith(QueryResults.Columns rightColumns)
Description copied from interface: QueryResults.Columns
Obtain a new definition for the query results that is a combination of the these columns and the supplied columns, where the columns from this object appear first, followed by columns from the supplied set. This is useful in a JOIN operation.

Specified by:
joinWith in interface QueryResults.Columns
Parameters:
rightColumns - 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

getColumns

public List<? extends Column> getColumns()
Description copied from interface: QueryResults.Columns
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

iterator

public Iterator<Column> iterator()
Specified by:
iterator in interface Iterable<Column>

getColumnNames

public List<String> getColumnNames()
Description copied from interface: QueryResults.Columns
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

getColumnTypes

public List<String> getColumnTypes()
Description copied from interface: QueryResults.Columns
Get the type name for each column.

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

getColumnCount

public int getColumnCount()
Description copied from interface: QueryResults.Columns
Get the number of columns in each tuple.

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

getLocationCount

public int getLocationCount()
Description copied from interface: QueryResults.Columns
Get the number of QueryResults.Location objects in each tuple.

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

getSelectorNames

public List<String> getSelectorNames()
Description copied from interface: QueryResults.Columns
Get the names of the selectors that are associated with these results. These results contain a single QueryResults.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

getTupleSize

public int getTupleSize()
Description copied from interface: QueryResults.Columns
Get the size of the tuple arrays.

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

getTupleValueNames

public List<String> getTupleValueNames()
Description copied from interface: QueryResults.Columns
Get the names of the all of the tuple values.

Specified by:
getTupleValueNames in interface QueryResults.Columns
Returns:
the immutable list of names

getLocationIndexForColumn

public int getLocationIndexForColumn(int columnIndex)
Description copied from interface: QueryResults.Columns
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

getLocationIndexForColumn

public int getLocationIndexForColumn(String columnName)
Description copied from interface: QueryResults.Columns
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

getLocationIndex

public int getLocationIndex(String selectorName)
Description copied from interface: QueryResults.Columns
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

hasSelector

public boolean hasSelector(String selectorName)
Description copied from interface: QueryResults.Columns
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

getPropertyNameForColumn

public String getPropertyNameForColumn(int columnIndex)
Description copied from interface: QueryResults.Columns
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

getPropertyNameForColumnName

public String getPropertyNameForColumnName(String columnName)
Description copied from interface: QueryResults.Columns
Get the name of the property that corresponds to the named column in each tuple.

Specified by:
getPropertyNameForColumnName in interface QueryResults.Columns
Parameters:
columnName - the column name
Returns:
the property name, or the supplied column name if there is no property for it

getColumnIndexForName

public int getColumnIndexForName(String columnName)
Description copied from interface: QueryResults.Columns
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

columnIndexForName

protected Integer columnIndexForName(String columnName)

getSelectorNameForColumnName

public String getSelectorNameForColumnName(String columnName)
Description copied from interface: QueryResults.Columns
Get the name of the selector that produced the column with the given name.

Specified by:
getSelectorNameForColumnName in interface QueryResults.Columns
Parameters:
columnName - the column name
Returns:
the selector name

getColumnIndexForProperty

public int getColumnIndexForProperty(String selectorName,
                                     String propertyName)
Description copied from interface: QueryResults.Columns
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

getFullTextSearchScoreIndexFor

public int getFullTextSearchScoreIndexFor(String selectorName)
Description copied from interface: QueryResults.Columns
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

hasFullTextSearchScores

public boolean hasFullTextSearchScores()
Description copied from interface: QueryResults.Columns
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

includes

public boolean includes(QueryResults.Columns other)
Description copied from interface: QueryResults.Columns
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

isUnionCompatible

public boolean isUnionCompatible(QueryResults.Columns other)
Description copied from interface: QueryResults.Columns
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

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

columnNameFor

protected static String columnNameFor(Column column,
                                      List<String> columnNames,
                                      Set<Column> columnsWithDuplicateNames,
                                      Collection<String> selectorNames)

findColumnsWithSameNames

protected static Set<Column> findColumnsWithSameNames(List<Column> columns)

toString

public String toString()

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

ModeShape Distribution 3.0.0.Beta4

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