com.flexive.shared.cmis.search
Class CmisResultSet

java.lang.Object
  extended by com.flexive.shared.cmis.search.CmisResultSet
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<CmisResultRow>

public class CmisResultSet
extends java.lang.Object
implements java.io.Serializable, java.lang.Iterable<CmisResultRow>

Disclaimer: this API is part of the CMIS interface and is not yet considered stable.

The search result of a CMIS SQL query.

You can iterate over the rows by using the result object, or explicitly using the getRows() function:

 final CmisResultSet result = EJBLookup.getCmisSearchEngine().search("...");
 for (CmisResultRow row : result) {
   for (CmisResultColumn column : row) {
      System.out.println(column.getValue());
   }
 }

Since:
3.1
Version:
$Rev$
Author:
Daniel Lichtenberger (daniel.lichtenberger@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
See Also:
Serialized Form

Constructor Summary
CmisResultSet(int columnCount)
          Constructor used for creating empty result sets (used for testing only).
CmisResultSet(java.util.List<CmisResultColumnDefinition> columns)
           
 
Method Summary
 CmisResultSet addRow(CmisResultRow row)
          Add the given row to this result set.
<T> java.util.List<T>
collectColumnValues(int columnIndex)
          Projects the values of a single column to a list.
<T> java.util.List<T>
collectColumnValues(int columnIndex, boolean unboxFxValue)
          Projects the values of a single column to a list.
<T> java.util.List<T>
collectColumnValues(java.lang.String columnAlias)
          Projects the values of a single column to a list.
<T> java.util.List<T>
collectColumnValues(java.lang.String columnAlias, boolean unboxFxValue)
          Projects the values of a single column to a list.
 java.util.List<CmisResultRow> filterEqual(int columnIndex, java.lang.Object value)
          Filter all rows where a column's value matches the given object.
 CmisResultSet freeze()
          Freeze the result set and prevent further modifications (i.e.
 CmisResultValue getColumn(int rowIndex, int columnIndex)
          Return the column value at the given row and column.
 CmisResultValue getColumn(int rowIndex, java.lang.String columnAlias)
          Return the column value at the given row and column.
 java.util.List<java.lang.String> getColumnAliases()
          Return the column aliases of this result set.
 java.util.List<java.lang.Long> getColumnAssignmentIds()
          Return the column aliases of this result set.
 int getColumnCount()
          Return the number of columns in this result set.
 java.util.List<CmisResultColumnDefinition> getColumns()
           
 CmisResultRow getRow(int index)
          Get the row with the given index (0-based).
 int getRowCount()
          Return the number of rows in this result set.
 java.util.List<CmisResultRow> getRows()
          Return all rows of the result set.
 TimestampRecorder getTimestampRecorder()
          Return the TimestampRecorder instance used for recording the execution times of this query.
 java.util.Iterator<CmisResultRow> iterator()
          Return an Iterator over the rows of this resultset.
 CmisResultRow newRow()
          Create a new row for this result set.
 void setTimestampRecorder(TimestampRecorder timestampRecorder)
          Set the TimestampRecorder instance used for recording the execution times of this query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmisResultSet

public CmisResultSet(java.util.List<CmisResultColumnDefinition> columns)

CmisResultSet

public CmisResultSet(int columnCount)
Constructor used for creating empty result sets (used for testing only).

Parameters:
columnCount - the number of columns
Method Detail

getRows

public java.util.List<CmisResultRow> getRows()
Return all rows of the result set.

Returns:
all rows of the result set.

getRow

public CmisResultRow getRow(int index)
Get the row with the given index (0-based).

Parameters:
index - the row index (0-based)
Returns:
the row with the given index (0-based).

getColumns

public java.util.List<CmisResultColumnDefinition> getColumns()
Returns:
the column definitions.
Since:
3.1.4

getColumn

public CmisResultValue getColumn(int rowIndex,
                                 int columnIndex)
Return the column value at the given row and column.

Parameters:
rowIndex - the row index (0-based)
columnIndex - the column index (1-based)
Returns:
the column value at the given row and column.

getColumn

public CmisResultValue getColumn(int rowIndex,
                                 java.lang.String columnAlias)
Return the column value at the given row and column.

Parameters:
rowIndex - the row index (0-based)
columnAlias - the column alias (case insensitive)
Returns:
the column value at the given row and column.

newRow

public CmisResultRow newRow()
Create a new row for this result set. The row is initialized with the columns of this result set, but is not yet added to it. To add the row, call addRow(CmisResultRow).

Returns:
a new row for this result set

addRow

public CmisResultSet addRow(CmisResultRow row)
Add the given row to this result set. The row must have been initialized with newRow(). Before adding, the row object is "frozen", i.e. it cannot be manipulated afterwards.

Parameters:
row - the row to be added
Returns:
this

getColumnAliases

public java.util.List<java.lang.String> getColumnAliases()
Return the column aliases of this result set. The order corresponds to the columns of the result set.

Returns:
the column aliases of this result set

getColumnAssignmentIds

public java.util.List<java.lang.Long> getColumnAssignmentIds()
Return the column aliases of this result set. The order corresponds to the columns of the result set.

Returns:
the column aliases of this result set

getColumnCount

public int getColumnCount()
Return the number of columns in this result set.

Returns:
the number of columns in this result set.

getRowCount

public int getRowCount()
Return the number of rows in this result set.

Returns:
the number of rows in this result set.

filterEqual

public java.util.List<CmisResultRow> filterEqual(int columnIndex,
                                                 java.lang.Object value)
Filter all rows where a column's value matches the given object.

Parameters:
columnIndex - the 1-based column index
value - the value to be filtered. Note that column values of type FxValue are unboxed automatically, so you can supply the "value type" instead of the full FxValue instance here (i.e. String instead of FxString.
Returns:
all rows where the column's value matches the given object.

collectColumnValues

public <T> java.util.List<T> collectColumnValues(int columnIndex)
Projects the values of a single column to a list.

Parameters:
columnIndex - the 1-based column index
Returns:
all column values collected in a list

collectColumnValues

public <T> java.util.List<T> collectColumnValues(java.lang.String columnAlias)
Projects the values of a single column to a list.

Parameters:
columnAlias - the column alias
Returns:
all column values collected in a list

collectColumnValues

public <T> java.util.List<T> collectColumnValues(java.lang.String columnAlias,
                                                 boolean unboxFxValue)
Projects the values of a single column to a list.

Parameters:
columnAlias - the column alias
unboxFxValue - if FxValue-derived values should be unboxed
Returns:
all column values collected in a list

collectColumnValues

public <T> java.util.List<T> collectColumnValues(int columnIndex,
                                                 boolean unboxFxValue)
Projects the values of a single column to a list.

Parameters:
columnIndex - the 1-based column index
unboxFxValue - if FxValue-derived values should be unboxed
Returns:
all column values collected in a list

freeze

public CmisResultSet freeze()
Freeze the result set and prevent further modifications (i.e. adding of more rows).

Returns:
the frozen result set

getTimestampRecorder

public TimestampRecorder getTimestampRecorder()
Return the TimestampRecorder instance used for recording the execution times of this query.

Returns:
the TimestampRecorder instance used for recording the execution times of this query.

setTimestampRecorder

public void setTimestampRecorder(TimestampRecorder timestampRecorder)
Set the TimestampRecorder instance used for recording the execution times of this query.

Parameters:
timestampRecorder - the timestamp recorder instance

iterator

public java.util.Iterator<CmisResultRow> iterator()
Return an Iterator over the rows of this resultset.

Specified by:
iterator in interface java.lang.Iterable<CmisResultRow>
Returns:
an Iterator over the rows of this resultset.