net.ontopia.topicmaps.query.core
Interface QueryResultIF

All Known Subinterfaces:
BufferedQueryResultIF
All Known Implementing Classes:
BooleanQueryResult, BufferedQueryResult, QueryResult, QueryResult

public interface QueryResultIF

PUBLIC: Used to represent the results of queries. A query result is conceptually a table where each column corresponds to a variable bound by the query, and each row corresponds to a match to the query. That is, each row has a value for each column, and this is the value of the variable in that particular match.

The query result object always has a current row in the result (except before the first call to next()), and the getValue(int ix) method will return the value in column ix of this row. To find the column number for a particular variable, call getIndex("VAR"); alternatively, call getValue("VAR") directly.

The next() method is used to simultaneously step to the next row and check if there is a next row.


Method Summary
 void close()
          PUBLIC: Closes the query result, which allows it to free its resources.
 java.lang.String getColumnName(int ix)
          PUBLIC: Returns the name of the given column.
 java.lang.String[] getColumnNames()
          PUBLIC: Returns the names of the columns.
 int getIndex(java.lang.String colname)
          PUBLIC: Returns the index of the named column.
 java.lang.Object getValue(int ix)
          PUBLIC: Returns the value in the given column in the current match.
 java.lang.Object getValue(java.lang.String colname)
          PUBLIC: Returns the value in the given column in the current match.
 java.lang.Object[] getValues()
          PUBLIC: Returns the current match as an array of values.
 java.lang.Object[] getValues(java.lang.Object[] values)
          PUBLIC: Reads the values of the current match into the specified array.
 int getWidth()
          PUBLIC: Returns the number of columns in the result.
 boolean next()
          PUBLIC: Steps to the next match, returning true if a valid match was found, and false if there are no more matches.
 

Method Detail

next

boolean next()
PUBLIC: Steps to the next match, returning true if a valid match was found, and false if there are no more matches. Must be called before values can be returned.


getWidth

int getWidth()
PUBLIC: Returns the number of columns in the result.


getIndex

int getIndex(java.lang.String colname)
PUBLIC: Returns the index of the named column. Returns -1 if the column does not exist. The column index is zero-based.


getColumnNames

java.lang.String[] getColumnNames()
PUBLIC: Returns the names of the columns.


getColumnName

java.lang.String getColumnName(int ix)
PUBLIC: Returns the name of the given column. The column index is zero-based.

Throws:
java.lang.IndexOutOfBoundsException - if there is no such column.

getValue

java.lang.Object getValue(int ix)
PUBLIC: Returns the value in the given column in the current match. The column index is zero-based. Requires next() to have been called first.

Throws:
java.lang.IndexOutOfBoundsException - if there is no such column.

getValue

java.lang.Object getValue(java.lang.String colname)
PUBLIC: Returns the value in the given column in the current match. Requires next() to have been called first.

Throws:
java.lang.IllegalArgumentException - if there is no such column.

getValues

java.lang.Object[] getValues()
PUBLIC: Returns the current match as an array of values. Note that the returned array should not be modified as it may lead to undefined results. Requires next() to have been called first.


getValues

java.lang.Object[] getValues(java.lang.Object[] values)
PUBLIC: Reads the values of the current match into the specified array. Requires next() to have been called first.

Since:
1.3.2

close

void close()
PUBLIC: Closes the query result, which allows it to free its resources.

Since:
1.3.4


Copyright © 2000-2012 Ontopia.