Interface ResultSet
- All Superinterfaces:
AutoCloseable,Iterable<ResultRow>
- All Known Implementing Classes:
AbstractResultSet,AbstractResultSet,AskResultSet,AskResultSet,SelectResultSet,SelectResultSet
This interface declares methods for getting values from a set of results of a SPARQL query issued to an ontology.
While this class is iterable, it is still necessary to close it either explicitly, or by declaring it within a try-with-resource block.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this result set releasing any sub-resources it holds.intfindColumn(String columnLabel) Retrieves index of a column with the specified label.voidfirst()Move the cursor to the first row.booleangetBoolean(int columnIndex) Retrieves value from column at the specified index and returns it as aboolean.booleangetBoolean(String columnLabel) Retrieves value from column with the specified label and returns it as aboolean.bytegetByte(int columnIndex) Retrieves value from column at the specified index and returns it asbyte.byteRetrieves value from column with the specified label and returns it asbyte.intGets the count of available columns.doublegetDouble(int columnIndex) Retrieves value from column at the specified index and returns it asdouble.doubleRetrieves value from column with the specified label and returns it asdouble.floatgetFloat(int columnIndex) Retrieves value from column at the specified index and returns it asfloat.floatRetrieves value from column with the specified label and returns it asfloat.intgetInt(int columnIndex) Retrieves value from column at the specified index and returns it asint.intRetrieves value from column with the specified label and returns it asint.longgetLong(int columnIndex) Retrieves value from column at the specified index and returns it aslong.longRetrieves value from column with the specified label and returns it aslong.getObject(int columnIndex) Retrieves value from column at the specified index and returns it asObject.<T> TRetrieves value from column at the specified index and returns it as an instance of the specified class.Retrieves value from column with the specified label and returns it asObject.<T> TRetrieves value from column with the specified label and returns it as an instance of the specified class.intRetrieves index of the current row.shortgetShort(int columnIndex) Retrieves value of column at the specified index and returns it asshort.shortRetrieves value of column with the specified label and returns it asshort.Retrieves theStatementthat produced thisResultSetobject.getString(int columnIndex) Retrieves value of column at the specified index and returns it asString.Retrieves value of column with the specified label and returns it asString.booleanhasNext()Returns true if the cursor does not point at the last row in this result set.booleanisBound(int variableIndex) Checks whether a value at the specified index is bound in the current result row.booleanChecks whether a value of the specified variable is bound in the current result row.booleanisFirst()Returns true if the cursor is at the first row of this result set.booleanisOpen()Retrieves status of this result set.iterator()Creates aIteratorover this result set.voidlast()Move the cursor to the last row in this results set.voidnext()Move the cursor one row forward.voidprevious()Move the cursor one row backwards.voidrelative(int rows) Move the cursor a relative number of rows, either positive or negative.voidsetRowIndex(int rowIndex) Move the cursor to the specified row index.default Spliterator<ResultRow>Creates aSpliteratorover this result set.stream()Creates a sequentialStreamover this result set.
-
Method Details
-
findColumn
Retrieves index of a column with the specified label.- Parameters:
columnLabel- Label of the column- Returns:
- index of the column or -1 if there is no such column
- Throws:
IllegalStateException- If called on a closed result set
-
getColumnCount
int getColumnCount()Gets the count of available columns.This number corresponds to the number of result variables bound in the query.
- Returns:
- Number of columns in the result set
- Throws:
IllegalStateException- If called on a closed result set
-
isBound
Checks whether a value at the specified index is bound in the current result row.Note that this method will return
falsealso in case the index is out of range of the variables known to the result set as a whole.- Parameters:
variableIndex- Index of the variable- Returns:
truewhen value is bound in the current row,falseotherwise- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- When unable to resolve binding status
-
isBound
Checks whether a value of the specified variable is bound in the current result row.Note that this method will return
falsealso in case the variable is not known to the result set at all.- Parameters:
variableName- Variable name- Returns:
truewhen value is bound in the current row,falseotherwise- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- When unable to resolve binding status
-
first
Move the cursor to the first row.- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If some other error occurs
-
getBoolean
Retrieves value from column at the specified index and returns it as aboolean.- Parameters:
columnIndex- Column index, the first column has index 0- Returns:
booleanvalue- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If thecolumnIndexis not a valid column index, the value cannot be cast tobooleanor there occurs some other error
-
getBoolean
Retrieves value from column with the specified label and returns it as aboolean.- Parameters:
columnLabel- Label of the column- Returns:
booleanvalue- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If there is no column with the specified label, the value cannot be cast tobooleanor there occurs some other error
-
getByte
Retrieves value from column at the specified index and returns it asbyte.- Parameters:
columnIndex- Column index, the first column has index 0- Returns:
bytevalue- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If thecolumnIndexis not a valid column index, the value cannot be cast tobyteor there occurs some other error
-
getByte
Retrieves value from column with the specified label and returns it asbyte.- Parameters:
columnLabel- Label of the column- Returns:
bytevalue- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If there is no column with the specified label, the value cannot be cast tobyteor there occurs some other error
-
getDouble
Retrieves value from column at the specified index and returns it asdouble.- Parameters:
columnIndex- Column index, the first column has index 0- Returns:
doublevalue- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If thecolumnIndexis not a valid column index, the value cannot be cast todoubleor there occurs some other error
-
getDouble
Retrieves value from column with the specified label and returns it asdouble.- Parameters:
columnLabel- Label of the column- Returns:
doublevalue- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If there is no column with the specified label, the value cannot be cast todoubleor there occurs some other error
-
getFloat
Retrieves value from column at the specified index and returns it asfloat.- Parameters:
columnIndex- Column index, the first column has index 0- Returns:
floatvalue- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If thecolumnIndexis not a valid column index, the value cannot be cast tofloator there occurs some other error
-
getFloat
Retrieves value from column with the specified label and returns it asfloat.- Parameters:
columnLabel- Label of the column- Returns:
floatvalue- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If there is no column with the specified label, the value cannot be cast tofloator there occurs some other error
-
getInt
Retrieves value from column at the specified index and returns it asint.- Parameters:
columnIndex- Column index, the first column has index 0- Returns:
intvalue- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If thecolumnIndexis not a valid column index, the value cannot be cast tointor there occurs some other error
-
getInt
Retrieves value from column with the specified label and returns it asint.- Parameters:
columnLabel- Label of the column- Returns:
intvalue- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If there is no column with the specified label, the value cannot be cast tointor there occurs some other error
-
getLong
Retrieves value from column at the specified index and returns it aslong.- Parameters:
columnIndex- Column index, the first column has index 0- Returns:
longvalue- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If thecolumnIndexis not a valid column index, the value cannot be cast tolongor there occurs some other error
-
getLong
Retrieves value from column with the specified label and returns it aslong.- Parameters:
columnLabel- Label of the column- Returns:
longvalue- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If there is no column with the specified label, the value cannot be cast tolongor there occurs some other error
-
getObject
Retrieves value from column at the specified index and returns it asObject.- Parameters:
columnIndex- Column index, the first column has index 0- Returns:
- column value cast to
Object - Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If thecolumnIndexis not a valid column index or there occurs some other error
-
getObject
Retrieves value from column with the specified label and returns it asObject.- Parameters:
columnLabel- Label of the column- Returns:
- column value cast to
Object - Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If there is no column with the specified label or there occurs some other error
-
getObject
Retrieves value from column at the specified index and returns it as an instance of the specified class.The mechanism of transforming the value to the specified class is not specified, it can be merely type casting or calling a constructor of the specified type.
- Type Parameters:
T- Return type- Parameters:
columnIndex- Column index, the first column has index 0cls- Requested class type- Returns:
- Value of the column
- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If thecolumnIndexis not a valid column index, the value cannot be cast to the specified type or there occurs some other error
-
getObject
Retrieves value from column with the specified label and returns it as an instance of the specified class.The mechanism of transforming the value to the specified class is not specified, it can be merely type casting or calling a constructor of the specified type.
- Type Parameters:
T- Return type- Parameters:
columnLabel- Label of the columncls- Requested class type- Returns:
- Value of the column.
- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If there is no column with the specified label, the value cannot be cast to the specified type or there occurs some other error
-
getRowIndex
Retrieves index of the current row.The first row has index 0.
- Returns:
- the current row index, -1 if there is no current row
- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If some other error occurs
-
getShort
Retrieves value of column at the specified index and returns it asshort.- Parameters:
columnIndex- Column index, the first column has index 0- Returns:
shortvalue- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If thecolumnIndexis not a valid column index, the value cannot be cast toshortor there occurs some other error
-
getShort
Retrieves value of column with the specified label and returns it asshort.- Parameters:
columnLabel- Label of the column- Returns:
shortvalue- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If there is no column with the specified label, the value cannot be cast toshortor there occurs some other error
-
getStatement
Retrieves theStatementthat produced thisResultSetobject. If this result set was generated some other way, this method will returnnull.- Returns:
- The
Statementthat produced thisResultSetor null - Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If some other error occurs
-
getString
Retrieves value of column at the specified index and returns it asString.- Parameters:
columnIndex- Column index, the first column has index 0- Returns:
Stringvalue- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If thecolumnIndexis not a valid column index, the value cannot be cast toStringor there occurs some other error
-
getString
Retrieves value of column with the specified label and returns it asString.- Parameters:
columnLabel- Label of the column- Returns:
Stringvalue- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If there is no column with the specified label, the value cannot be cast toStringor there occurs some other error
-
isFirst
Returns true if the cursor is at the first row of this result set.- Returns:
- True if the cursor is at the first row, false otherwise
- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If some other error occurs
-
hasNext
Returns true if the cursor does not point at the last row in this result set.- Returns:
- True if there is at least one next row
- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If some other error occurs
-
last
Move the cursor to the last row in this results set.Note that since the result set may be asynchronously updated, the last row does not have to always be the same.
- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If some other error occurs
-
next
Move the cursor one row forward.- Throws:
NoSuchElementException- If there are no more elementsIllegalStateException- If called on a closed result setOntoDriverException- If some other error occurs
-
previous
Move the cursor one row backwards.- Throws:
IllegalStateException- If called on a closed result set or the cursor is at the first rowOntoDriverException- If some other error occurs
-
relative
Move the cursor a relative number of rows, either positive or negative.- Parameters:
rows- The number of rows to move the cursor of- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If therowsnumber is not valid or some other error occurs
-
setRowIndex
Move the cursor to the specified row index.The first row has index 0.
- Parameters:
rowIndex- Index to move the cursor to- Throws:
IllegalStateException- If called on a closed result setOntoDriverException- If the index is not valid row index or some other error occurs
-
close
Closes this result set releasing any sub-resources it holds.After closing the result set is not usable any more and calling methods on it (except
closeandisOpen) will result inOntoDriverException.Calling
closeon already closed resource does nothing.Calling this method also results in immediate disconnection of all registered observers and cancellation of any running reasoning associated with this result set.
- Specified by:
closein interfaceAutoCloseable- Throws:
OntoDriverException- If an ontology access error occurs.
-
isOpen
boolean isOpen()Retrieves status of this result set.- Returns:
trueif the resource is open,falseotherwise
-
iterator
Creates aIteratorover this result set.Note that the iterator does not close this result set after finishing its iteration. The result has to be closed by the caller.
-
spliterator
Creates aSpliteratorover this result set.Note that the spliterator does not close this result set after finishing its iteration. The result has to be closed by the caller.
- Specified by:
spliteratorin interfaceIterable<ResultRow>- Returns:
- Spliterator over this result set
-
stream
Creates a sequentialStreamover this result set.The default implementation creates a stream using the default
spliterator().Note that the stream does not close this result set after finishing its iteration. The result set has to be closed by the caller.
- Returns:
- A
Streamover this result set.
-