|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.teiid.test.client.ctc.QueryResults
public class QueryResults
This class encapsulates results associated with a query.
Results are conceptually organized as a table of columns and rows, where the columns are the data fields that were specified in the query select statement, and the rows are individual records returned from the data set. The data values are arbitrary Java objects in each field/record cell.
Record # | Field1 Field2 Field3 ... FieldN ----------|--------------------------------------------- 1 | Value11 Value12 Value13 Value1N 2 | Value21 Value22 Value23 Value2N : | : : : : M | ValueM1 ValueM2 ValueM3 ValueMN
Methods are provided to access data by:
Results can be specified to be sorted based on a user-provided ordering. The ordering is a List of ElementSymbols, which should match the identifiers for the results fields. This list will typically be in the order that the parameters were specified in the query select statement. If no ordering list is specified, the order is the same as results fields are added to this object.
Nested Class Summary | |
---|---|
static class |
QueryResults.ColumnInfo
Represents all information about a column. |
Constructor Summary | |
---|---|
QueryResults()
Construct a default instance of this class. |
|
QueryResults(List fields)
Construct an instance of this class, specifying the order that the elements should be inserted into the map. |
|
QueryResults(List fields,
int numberOfRecords)
Construct an instance of this class, specifying the fields and the number of records that the result set should hold. |
|
QueryResults(List elements,
TupleBatch tupleBatch)
Construct a QueryResults from a TupleBatch. |
Method Summary | |
---|---|
void |
addField(QueryResults.ColumnInfo info)
Add a new field into this result set. |
void |
addFields(Collection fields)
Add a set of fields into this result set. |
int |
addRecord()
Add a new record for all fields. |
int |
addRecord(List record)
Add a new record for all fields. |
boolean |
containsField(String field)
Returns true if the specified field is in the result set. |
static List |
createColumnInfos(List symbols)
Convert a list of SingleElementSymbols to a List of ColumnInfo objects. |
boolean |
equals(Object object)
Compares with another result set |
QueryResults.ColumnInfo |
getColumnInfo(String columnName)
Get the column information given the column name. |
int |
getFieldCount()
Returns the number of fields in the result set. |
List |
getFieldIdents()
Returns all the field identifiers. |
int |
getIndexOfField(String field)
Returns the index of the specified field is in the result set. |
int |
getRecordCount()
Returns the number of records in the result set. |
List |
getRecords()
Get the records contained in this result. |
List |
getRecordValues(int recordNumber)
Returns the values for the specified record. |
List |
getTypes()
|
Object |
getValue(String columnName,
int recordNumber)
Get the value for the specified field and record. |
void |
readExternal(ObjectInput s)
Implements Externalizable interface to read serialized form |
void |
setValue(String field,
int recordNumber,
Object value)
Set the value at a particular record for a field. |
String |
toString()
Returns a string representation of an instance of this class. |
void |
writeExternal(ObjectOutput s)
Implements Externalizable interface to write serialized form |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public QueryResults()
The number of fields returned by the getFieldCount()
method will be 0 after this constructor has completed. The
number of records returned by the getRecordCount()
method will be 0 after this constructor has completed.
public QueryResults(List fields)
getFieldCount()
method will be the same as the number of fields
passed in
after this constructor has completed. The number of records returned by the getRecordCount()
method will be 0 after
this constructor has completed.
fields
- The set of field identifiers that will be in the result setpublic QueryResults(List fields, int numberOfRecords)
The number of records returned by the getRecordCount()
method will be numberOfRecords
after this
constructor has completed. The number of fields returned by the getFieldCount()
will be the same as the size of the
list of fields passed in after this constructor has completed.
fields
- The ordered list of variables in select statementnumberOfRecords
- The number of blank records to create; records will all contain null
values for all the fieldsaddField(org.teiid.test.client.ctc.QueryResults.ColumnInfo)
public QueryResults(List elements, TupleBatch tupleBatch)
elements
- List of SingleElementSymbolstupleBatch
- Batch of rowsMethod Detail |
---|
public List getFieldIdents()
This method will never return null
. The list of identifiers returned is not mutable -- changes made to this
list will not affect the QueryResults object.
public QueryResults.ColumnInfo getColumnInfo(String columnName)
columnName
- The name of the column.
public int getFieldCount()
public int getRecordCount()
public Object getValue(String columnName, int recordNumber) throws IllegalArgumentException, IndexOutOfBoundsException
The value returned is not mutable -- changes made to this value will not affect the QueryResults object.
Note that results must be retrieved with the same type of data node identifier that was specified in the select statement.
columnName
- The unique data element identifier for the fieldrecordNumber
- The record number
IllegalArgumentException
- If field is not in result set
IndexOutOfBoundsException
- If record is not in result setpublic List getRecordValues(int recordNumber) throws IndexOutOfBoundsException
The list of values returned is not mutable -- changes made to this list will not affect the QueryResults object.
recordNumber
- The record number
IndexOutOfBoundsException
public List getRecords()
public boolean containsField(String field)
field
- Unique identifier for a data element specified in result setpublic List getTypes()
public void addField(QueryResults.ColumnInfo info)
info
- The column information.public void addFields(Collection fields)
fields
- The field identifiers.public int addRecord()
setValue
calls.
Before this method is called, the fields must already be defined.
public int addRecord(List record)
Before this method is called, the fields must already be defined.
public void setValue(String field, int recordNumber, Object value) throws IllegalArgumentException, IndexOutOfBoundsException
The specified field and record must already exist in the data set, or an exception will be thrown. The
addField(ColumnInfo)
method can be used to append values or new records for fields.
field
- The unique data element identifier for the fieldrecordNumber
- The record number
IndexOutOfBoundsException
- If the specified record does not exist
IllegalArgumentException
public int getIndexOfField(String field) throws IllegalArgumentException
field
- Unique identifier for a data element specified in result set
IllegalArgumentException
- If field is not in result setpublic static List createColumnInfos(List symbols)
symbols
- List of SingleElementSymbols
public boolean equals(Object object)
equals
in class Object
public String toString()
toString
in class Object
public void readExternal(ObjectInput s) throws ClassNotFoundException, IOException
readExternal
in interface Externalizable
s
- Input stream to serialize from
ClassNotFoundException
IOException
public void writeExternal(ObjectOutput s) throws IOException
writeExternal
in interface Externalizable
s
- Output stream to serialize to
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |