public interface ResultReader
The result tree is traversed through a set of events by calling
next(). Each event can trigger a state change which changes the set
of methods that can be called.
Available methods in a certain state
| Event | Available methods |
|---|---|
START_RESULTS |
next, hasNext |
END_RESULTS |
hasNext |
START_NODE |
next, hasNext, getName, getTypeName |
END_NODE |
next, hasNext |
RESULT |
next, hasNext, getName, getTypeName, getValue, getInt | getLong | getDouble | getString (depends on the result type) |
START_ARRAY |
next, hasNext, getName, getTypeName |
END_ARRAY |
next, hasNext | START_ELEMENT |
next, hasNext, getName, getTypeName, getIndex |
END_ELEMENT |
next, hasNext |
| Modifier and Type | Interface and Description |
|---|---|
static class |
ResultReader.Event
Read events which occur in a result file.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the reader and underlying streams.
|
double |
getDouble()
Returns the current double result.
|
int |
getIndex()
Returns the index of the current result element.
|
long |
getLong()
Returns the current long integer result.
|
java.lang.String |
getName()
Returns the name of the current result.
|
java.lang.String |
getString()
Returns the current string result.
|
java.lang.String |
getTypeName()
Returns the type of the current result.
|
java.lang.String |
getValue()
Reads the unparsed value of the current result from the input.
|
boolean |
hasNext()
Returns whether any read events remain or the result tree has been fully
traversed.
|
ResultReader.Event |
next()
Returns the next result read event.
|
ResultReader.Event |
nextResult()
Reads the next result (item, node or array).
|
double |
readDouble(java.lang.String name)
Reads the next double result from the input.
|
void |
readEndArray()
Reads the end of the current result array.
|
void |
readEndArrayItem()
Reads the end of the current array element.
|
void |
readEndNode()
Reads the end of the current result node.
|
void |
readEndResults()
Reads the end of the result tree.
|
long |
readLong(java.lang.String name)
Reads the next long integer result from the input.
|
void |
readStartArray()
Reads the next result array.
|
int |
readStartArrayItem()
Reads the next array element.
|
void |
readStartNode()
Reads the next result node.
|
void |
readStartNode(java.lang.String expectedType)
Reads the next result node.
|
void |
readStartNode(java.lang.String expectedType,
java.lang.String expectedName)
Reads the next result node.
|
void |
readStartResults()
Reads the start of the result tree.
|
java.lang.String |
readString(java.lang.String name)
Reads the next string result from the input.
|
void close()
throws ResultException
ResultExceptionResultReader.Event next() throws ResultException
java.lang.IllegalStateException - if no events remainResultExceptionResultReader.Event nextResult() throws ResultException
ResultReader.Event.RESULT, ResultReader.Event.START_NODE or
ResultReader.Event.START_ARRAYjava.lang.IllegalStateException - if not in an result node or array elementResultExceptionboolean hasNext()
throws ResultException
Calling next() after this mehtod returned false will
result in an exception.
ResultExceptionjava.lang.String getName()
throws ResultException
null is returned.nulljava.lang.IllegalStateException - if not called in a result item, node or arrayResultExceptionjava.lang.String getTypeName()
throws ResultException
java.lang.IllegalStateException - if not called in a result item or nodeResultExceptionint getIndex()
throws ResultException
java.lang.IllegalStateException - if not in an array elementResultExceptionjava.lang.String getValue()
throws ResultException
java.lang.IllegalStateException - if not in a result itemResultExceptionvoid readStartResults()
throws ResultException
java.lang.IllegalStateException - if the start of the result tree has been read alreadyResultExceptionvoid readEndResults()
throws ResultException
java.lang.IllegalStateException - if the next event is not the end of the result treeResultExceptionvoid readStartArray()
throws ResultException
ResultExceptionvoid readEndArray()
throws ResultException
java.lang.IllegalStateException - if not in an result arrayResultExceptionint readStartArrayItem()
throws ResultException
java.lang.IllegalStateException - if not in an array or if the last call returned -1ResultExceptionvoid readEndArrayItem()
throws ResultException
java.lang.IllegalStateException - if not in an array elementResultExceptionvoid readStartNode()
throws ResultException
ResultExceptionvoid readStartNode(java.lang.String expectedType)
throws ResultException
expectedType - the expected type nameResultExceptionvoid readStartNode(java.lang.String expectedType,
java.lang.String expectedName)
throws ResultException
expectedType - the expected type nameexpectedName - the expected nameResultExceptionvoid readEndNode()
throws ResultException
java.lang.IllegalStateException - if not in an result nodeResultExceptionlong getLong()
throws ResultException
java.lang.IllegalStateException - if not in a long result itemResultExceptionlong readLong(java.lang.String name)
throws ResultException
nextResult(); getLong();
java.lang.IllegalStateException - if the next result is not a longResultExceptiondouble getDouble()
throws ResultException
java.lang.IllegalStateException - if not in a double result itemResultExceptiondouble readDouble(java.lang.String name)
throws ResultException
nextResult(); getDouble();
java.lang.IllegalStateException - if the next result is not a doubleResultExceptionjava.lang.String getString()
throws ResultException
java.lang.IllegalStateException - if not in a string result itemResultExceptionjava.lang.String readString(java.lang.String name)
throws ResultException
nextResult(); getString();
java.lang.IllegalStateException - if the next result is not a stringResultException