gov.ornl.csed.csiir.idr.kdd.dataservice.server.models
Class ResultSetResponse

java.lang.Object
  extended by gov.ornl.csed.csiir.idr.kdd.dataservice.server.models.ResultSetResponse
All Implemented Interfaces:
java.lang.Iterable<ResultSetResponse.ResultRecord>

public final class ResultSetResponse
extends java.lang.Object
implements java.lang.Iterable<ResultSetResponse.ResultRecord>

The ResultSetResponse object represents a subset of result records returned from a query to the data service.

Usage example:

 ResultSetReponse results = ...;
 for(ResultRecord record : results) {
 	System.out.print("Record: ");
 	for(ResultField value : record) {
 		System.out.print(value.getObject.toString());
 		System.out.print("; ");
 	}
 	System.out.println();
 }
 
 


Nested Class Summary
static class ResultSetResponse.ListSet
          The ListSet class represents a list of lists and allows them to be iterated as a matrix of rows and columns.
static class ResultSetResponse.ResultRecord
          The ResultRecord class represents the fields of a single record.
 
Constructor Summary
ResultSetResponse()
           
ResultSetResponse(java.lang.String queryId, boolean lastSet)
           
ResultSetResponse(java.lang.String queryId, java.util.Map<java.lang.String,java.lang.String> columnInfo)
           
ResultSetResponse(java.lang.String queryId, java.util.Map<java.lang.String,java.lang.String> columnInfo, boolean lastSet)
           
 
Method Summary
 void addRecord(java.util.List<java.lang.Object> record)
          Adds a record to the result set.
 boolean equals(java.lang.Object obj)
           
 int fieldSize()
          Returns the number of fields in each record of this result set.
 java.util.List<gov.ornl.csed.csiir.idr.kdd.dataservice.server.models.ResultSetResponse.InternalColumn> getColumnList()
          Retrieves the internal representation for this result set.
 java.util.Date getDate(int recordIndex, int fieldIndex)
          Retrieves an Java Date representation of a field value for the supplied record index and field index.
 java.util.Date getDate(int recordIndex, java.lang.String fieldName)
          Retrieves an Java Date representation of a field value for the supplied record index and field name.
 java.lang.Double getDouble(int recordIndex, int fieldIndex)
          Retrieves an Java Double representation of a field value for the supplied record index and field index.
 java.lang.Double getDouble(int recordIndex, java.lang.String fieldName)
          Retrieves an Java Double representation of a field value for the supplied record index and field name.
 java.lang.String getFieldName(int fieldIndex)
          Retrieves the field name for a supplied field index.
 java.util.Map<java.lang.String,java.lang.Integer> getFieldNameMap()
          Retrieves the Map from field name to field index.
 java.lang.String getFieldType(int fieldIndex)
          Retrieves the Java field type for a given field index.
 java.lang.String getFieldType(java.lang.String fieldName)
          Retrieves the Java field type for a given field name.
 java.lang.Float getFloat(int recordIndex, int fieldIndex)
          Retrieves an Java Float representation of a field value for the supplied record index and field index.
 java.lang.Float getFloat(int recordIndex, java.lang.String fieldName)
          Retrieves an Java Float representation of a field value for the supplied record index and field name.
 java.lang.Integer getInteger(int recordIndex, int fieldIndex)
          Retrieves an Java Integer representation of a field value for the supplied record index and field index.
 java.lang.Integer getInteger(int recordIndex, java.lang.String fieldName)
          Retrieves an Java Integer representation of a field value for the supplied record index and field name.
 java.util.List<?> getList(int recordIndex, int fieldIndex)
          Retrieves an Java List representation of a field value for the supplied record index and field index.
 java.util.List<?> getList(int recordIndex, java.lang.String fieldName)
          Retrieves an Java List representation of a field value for the supplied record index and field name.
 java.lang.Long getLong(int recordIndex, int fieldIndex)
          Retrieves an Java Long representation of a field value for the supplied record index and field index.
 java.lang.Long getLong(int recordIndex, java.lang.String fieldName)
          Retrieves an Java Long representation of a field value for the supplied record index and field name.
 java.lang.Object getObject(int recordIndex, int fieldIndex)
          Retrieves a Java Object representation of a field value for the supplied record index and field index.
 java.lang.Object getObject(int recordIndex, java.lang.String fieldName)
          Retrieves an Java Object representation of a field value for the supplied record index and field name.
 java.lang.String getQueryId()
          Retrieve the unique query ID of the query that generated this result set.
 int getQueryProcessingTime()
          Retrieves the time, in milliseconds, that it took to execute the query that generated these results.
 java.lang.String getString(int recordIndex, int fieldIndex)
          Retrieves a Java String representation of a field value for the supplied record index and field index.
 java.lang.String getString(int recordIndex, java.lang.String fieldName)
          Retrieves an Java String representation of a field value for the supplied record index and field name.
 long getTotalMatchingRecords()
          Retrieves the total number of records that matched the executed query.
 int hashCode()
           
 boolean isLastSet()
          Returns true is this is the last set of results for a query.
 java.util.Iterator<ResultSetResponse.ResultRecord> iterator()
          Returns an iterator over the result set records.
 int recordSize()
          Returns the number of records in this result set
 void setColumnList(java.util.List<gov.ornl.csed.csiir.idr.kdd.dataservice.server.models.ResultSetResponse.InternalColumn> columnList)
          Sets the internal representation for this result set.
 void setFieldNameMap(java.util.Map<java.lang.String,java.lang.Integer> columnNameMap)
          Sets the Map for field name to field index.
 void setLastSet(boolean lastSet)
          Set whether this is that last set of results for a query.
 void setQueryId(java.lang.String queryId)
          Set the unique query ID.
 void setQueryProcessingTime(int queryProcessingTime)
          Set the query processing time.
 void setTotalMatchingRecords(long totalMatchingRecords)
          Set the total number of records that matched the executed query.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResultSetResponse

public ResultSetResponse()

ResultSetResponse

public ResultSetResponse(java.lang.String queryId,
                         boolean lastSet)

ResultSetResponse

public ResultSetResponse(java.lang.String queryId,
                         java.util.Map<java.lang.String,java.lang.String> columnInfo)

ResultSetResponse

public ResultSetResponse(java.lang.String queryId,
                         java.util.Map<java.lang.String,java.lang.String> columnInfo,
                         boolean lastSet)
Method Detail

addRecord

public void addRecord(java.util.List<java.lang.Object> record)
               throws java.lang.IndexOutOfBoundsException
Adds a record to the result set. Used internally.

Parameters:
record - the data set record to add
Throws:
java.lang.IndexOutOfBoundsException

recordSize

public int recordSize()
Returns the number of records in this result set

Returns:
the number of records

fieldSize

public int fieldSize()
Returns the number of fields in each record of this result set.

Returns:
the number of fields

iterator

public java.util.Iterator<ResultSetResponse.ResultRecord> iterator()
Returns an iterator over the result set records.

Specified by:
iterator in interface java.lang.Iterable<ResultSetResponse.ResultRecord>
See Also:
Iterable.iterator()

getFieldName

public java.lang.String getFieldName(int fieldIndex)
                              throws java.lang.IndexOutOfBoundsException
Retrieves the field name for a supplied field index.

Parameters:
fieldIndex - the field index
Returns:
the field name
Throws:
java.lang.IndexOutOfBoundsException

getFieldType

public java.lang.String getFieldType(int fieldIndex)
                              throws java.lang.IndexOutOfBoundsException
Retrieves the Java field type for a given field index.

Parameters:
fieldIndex - the field index
Returns:
the field type
Throws:
java.lang.IndexOutOfBoundsException

getFieldType

public java.lang.String getFieldType(java.lang.String fieldName)
                              throws java.lang.IllegalArgumentException,
                                     java.lang.IndexOutOfBoundsException
Retrieves the Java field type for a given field name.

Parameters:
fieldName - the field name
Returns:
the field type
Throws:
java.lang.IllegalArgumentException
java.lang.IndexOutOfBoundsException

getObject

public java.lang.Object getObject(int recordIndex,
                                  int fieldIndex)
                           throws java.lang.IndexOutOfBoundsException
Retrieves a Java Object representation of a field value for the supplied record index and field index.

Parameters:
recordIndex - the record index
fieldIndex - the field index
Returns:
the object
Throws:
java.lang.IndexOutOfBoundsException

getObject

public java.lang.Object getObject(int recordIndex,
                                  java.lang.String fieldName)
                           throws java.lang.IllegalArgumentException,
                                  java.lang.IndexOutOfBoundsException
Retrieves an Java Object representation of a field value for the supplied record index and field name.

Parameters:
recordIndex - the record index
fieldName - the field name
Returns:
the object
Throws:
java.lang.IllegalArgumentException
java.lang.IndexOutOfBoundsException

getString

public java.lang.String getString(int recordIndex,
                                  int fieldIndex)
                           throws java.lang.IndexOutOfBoundsException
Retrieves a Java String representation of a field value for the supplied record index and field index.

Parameters:
recordIndex - the record index
fieldIndex - the field index
Returns:
the string
Throws:
java.lang.IndexOutOfBoundsException

getString

public java.lang.String getString(int recordIndex,
                                  java.lang.String fieldName)
                           throws java.lang.IllegalArgumentException,
                                  java.lang.IndexOutOfBoundsException
Retrieves an Java String representation of a field value for the supplied record index and field name.

Parameters:
recordIndex - the record index
fieldName - the field name
Returns:
the string
Throws:
java.lang.IllegalArgumentException
java.lang.IndexOutOfBoundsException

getInteger

public java.lang.Integer getInteger(int recordIndex,
                                    int fieldIndex)
                             throws java.lang.IndexOutOfBoundsException,
                                    java.lang.NumberFormatException
Retrieves an Java Integer representation of a field value for the supplied record index and field index.

Parameters:
recordIndex - the record index
fieldIndex - the field name
Returns:
the integer
Throws:
java.lang.IndexOutOfBoundsException
java.lang.NumberFormatException

getInteger

public java.lang.Integer getInteger(int recordIndex,
                                    java.lang.String fieldName)
                             throws java.lang.IllegalArgumentException,
                                    java.lang.NumberFormatException,
                                    java.lang.IndexOutOfBoundsException
Retrieves an Java Integer representation of a field value for the supplied record index and field name.

Parameters:
recordIndex - the record index
fieldName - the field name
Returns:
the integer
Throws:
java.lang.IllegalArgumentException
java.lang.NumberFormatException
java.lang.IndexOutOfBoundsException

getLong

public java.lang.Long getLong(int recordIndex,
                              int fieldIndex)
                       throws java.lang.IndexOutOfBoundsException,
                              java.lang.NumberFormatException
Retrieves an Java Long representation of a field value for the supplied record index and field index.

Parameters:
recordIndex - the record index
fieldIndex - the field name
Returns:
the long
Throws:
java.lang.NumberFormatException
java.lang.IndexOutOfBoundsException

getLong

public java.lang.Long getLong(int recordIndex,
                              java.lang.String fieldName)
                       throws java.lang.IllegalArgumentException,
                              java.lang.NumberFormatException,
                              java.lang.IndexOutOfBoundsException
Retrieves an Java Long representation of a field value for the supplied record index and field name.

Parameters:
recordIndex - the record index
fieldName - the field name
Returns:
the long
Throws:
java.lang.IllegalArgumentException
java.lang.NumberFormatException
java.lang.IndexOutOfBoundsException

getFloat

public java.lang.Float getFloat(int recordIndex,
                                int fieldIndex)
                         throws java.lang.IndexOutOfBoundsException,
                                java.lang.NumberFormatException
Retrieves an Java Float representation of a field value for the supplied record index and field index.

Parameters:
recordIndex - the record index
fieldIndex - the field name
Returns:
the float
Throws:
java.lang.IndexOutOfBoundsException
java.lang.NumberFormatException

getFloat

public java.lang.Float getFloat(int recordIndex,
                                java.lang.String fieldName)
                         throws java.lang.IllegalArgumentException,
                                java.lang.NumberFormatException,
                                java.lang.IndexOutOfBoundsException
Retrieves an Java Float representation of a field value for the supplied record index and field name.

Parameters:
recordIndex - the record index
fieldName - the field name
Returns:
the float
Throws:
java.lang.IllegalArgumentException
java.lang.NumberFormatException
java.lang.IndexOutOfBoundsException

getDouble

public java.lang.Double getDouble(int recordIndex,
                                  int fieldIndex)
                           throws java.lang.IndexOutOfBoundsException,
                                  java.lang.NumberFormatException
Retrieves an Java Double representation of a field value for the supplied record index and field index.

Parameters:
recordIndex - the record index
fieldIndex - the field index
Returns:
the double
Throws:
java.lang.IndexOutOfBoundsException
java.lang.NumberFormatException

getDouble

public java.lang.Double getDouble(int recordIndex,
                                  java.lang.String fieldName)
                           throws java.lang.IllegalArgumentException,
                                  java.lang.NumberFormatException,
                                  java.lang.IndexOutOfBoundsException
Retrieves an Java Double representation of a field value for the supplied record index and field name.

Parameters:
recordIndex - the record index
fieldName - the field name
Returns:
double
Throws:
java.lang.IllegalArgumentException
java.lang.NumberFormatException
java.lang.IndexOutOfBoundsException

getDate

public java.util.Date getDate(int recordIndex,
                              int fieldIndex)
                       throws java.lang.IndexOutOfBoundsException,
                              java.text.ParseException
Retrieves an Java Date representation of a field value for the supplied record index and field index.

Parameters:
recordIndex - the record index
fieldIndex - the field index
Returns:
the date
Throws:
java.lang.IndexOutOfBoundsException
java.text.ParseException

getDate

public java.util.Date getDate(int recordIndex,
                              java.lang.String fieldName)
                       throws java.lang.IllegalArgumentException,
                              java.text.ParseException,
                              java.lang.IndexOutOfBoundsException
Retrieves an Java Date representation of a field value for the supplied record index and field name.

Parameters:
recordIndex - the record index
fieldName - the field name
Returns:
the date
Throws:
java.lang.IllegalArgumentException
java.text.ParseException
java.lang.IndexOutOfBoundsException

getList

public java.util.List<?> getList(int recordIndex,
                                 int fieldIndex)
                          throws java.lang.IndexOutOfBoundsException
Retrieves an Java List representation of a field value for the supplied record index and field index.

Parameters:
recordIndex - the record index
fieldIndex - the field index
Returns:
the list
Throws:
java.lang.IndexOutOfBoundsException

getList

public java.util.List<?> getList(int recordIndex,
                                 java.lang.String fieldName)
                          throws java.lang.IndexOutOfBoundsException,
                                 java.lang.IllegalArgumentException
Retrieves an Java List representation of a field value for the supplied record index and field name.

Parameters:
recordIndex - the record index
fieldName - the field name
Returns:
the list
Throws:
java.lang.IndexOutOfBoundsException
java.lang.IllegalArgumentException

getQueryId

public java.lang.String getQueryId()
Retrieve the unique query ID of the query that generated this result set.

Returns:
the unique ID

setQueryId

public void setQueryId(java.lang.String queryId)
Set the unique query ID. Used for serialization.

Parameters:
queryId - the unique query ID

getQueryProcessingTime

public int getQueryProcessingTime()
Retrieves the time, in milliseconds, that it took to execute the query that generated these results.

Returns:
the query execution time in milliseconds

setQueryProcessingTime

public void setQueryProcessingTime(int queryProcessingTime)
Set the query processing time. Used for serialization.

Parameters:
queryProcessingTime - the query processing time in milliseconds.

getTotalMatchingRecords

public long getTotalMatchingRecords()
Retrieves the total number of records that matched the executed query.

Returns:
the total number of matching records

setTotalMatchingRecords

public void setTotalMatchingRecords(long totalMatchingRecords)
Set the total number of records that matched the executed query. Used for serialization.

Parameters:
totalMatchingRecords - the total number of matching records

isLastSet

public boolean isLastSet()
Returns true is this is the last set of results for a query.

Returns:
true if this is the last set, otherwise false

setLastSet

public void setLastSet(boolean lastSet)
Set whether this is that last set of results for a query. Used for serialization.

Parameters:
lastSet - true if this is the last set, false otherwise

getColumnList

public java.util.List<gov.ornl.csed.csiir.idr.kdd.dataservice.server.models.ResultSetResponse.InternalColumn> getColumnList()
Retrieves the internal representation for this result set. Used for serialization.

Returns:
the internal representation

setColumnList

public void setColumnList(java.util.List<gov.ornl.csed.csiir.idr.kdd.dataservice.server.models.ResultSetResponse.InternalColumn> columnList)
Sets the internal representation for this result set. Used for serialization.

Parameters:
columnList - the list of columns

getFieldNameMap

public java.util.Map<java.lang.String,java.lang.Integer> getFieldNameMap()
Retrieves the Map from field name to field index. Used internally.

Returns:
the map

setFieldNameMap

public void setFieldNameMap(java.util.Map<java.lang.String,java.lang.Integer> columnNameMap)
Sets the Map for field name to field index. Used internally.

Parameters:
columnNameMap - the map of field name to field index

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object