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
ResultException
ResultReader.Event next() throws ResultException
java.lang.IllegalStateException
- if no events remainResultException
ResultReader.Event nextResult() throws ResultException
ResultReader.Event.RESULT
, ResultReader.Event.START_NODE
or
ResultReader.Event.START_ARRAY
java.lang.IllegalStateException
- if not in an result node or array elementResultException
boolean hasNext() throws ResultException
Calling next()
after this mehtod returned false
will
result in an exception.
ResultException
java.lang.String getName() throws ResultException
null
is returned.null
java.lang.IllegalStateException
- if not called in a result item, node or arrayResultException
java.lang.String getTypeName() throws ResultException
java.lang.IllegalStateException
- if not called in a result item or nodeResultException
int getIndex() throws ResultException
java.lang.IllegalStateException
- if not in an array elementResultException
java.lang.String getValue() throws ResultException
java.lang.IllegalStateException
- if not in a result itemResultException
void readStartResults() throws ResultException
java.lang.IllegalStateException
- if the start of the result tree has been read alreadyResultException
void readEndResults() throws ResultException
java.lang.IllegalStateException
- if the next event is not the end of the result treeResultException
void readStartArray() throws ResultException
ResultException
void readEndArray() throws ResultException
java.lang.IllegalStateException
- if not in an result arrayResultException
int readStartArrayItem() throws ResultException
java.lang.IllegalStateException
- if not in an array or if the last call returned -1ResultException
void readEndArrayItem() throws ResultException
java.lang.IllegalStateException
- if not in an array elementResultException
void readStartNode() throws ResultException
ResultException
void readStartNode(java.lang.String expectedType) throws ResultException
expectedType
- the expected type nameResultException
void readStartNode(java.lang.String expectedType, java.lang.String expectedName) throws ResultException
expectedType
- the expected type nameexpectedName
- the expected nameResultException
void readEndNode() throws ResultException
java.lang.IllegalStateException
- if not in an result nodeResultException
long getLong() throws ResultException
java.lang.IllegalStateException
- if not in a long result itemResultException
long readLong(java.lang.String name) throws ResultException
nextResult(); getLong();
java.lang.IllegalStateException
- if the next result is not a longResultException
double getDouble() throws ResultException
java.lang.IllegalStateException
- if not in a double result itemResultException
double readDouble(java.lang.String name) throws ResultException
nextResult(); getDouble();
java.lang.IllegalStateException
- if the next result is not a doubleResultException
java.lang.String getString() throws ResultException
java.lang.IllegalStateException
- if not in a string result itemResultException
java.lang.String readString(java.lang.String name) throws ResultException
nextResult(); getString();
java.lang.IllegalStateException
- if the next result is not a stringResultException