public class QueryResult<T extends ResultType> extends Object implements Iterable<QueryResult.Entry<T>>
It is created trough successful invocation of
Maapi.queryStart(int,String,String,int,int,List,Class)
method. Its purpose is to iterate, stop or reset a XPath Query
specified from parameters in queryStart
.
The Iterator
that returns from the QueryResult.iterator()
method
fetches result in chunks from server for local processing as needed and
is specified by the chunksize
in queryStart
method when iterating over the result set.
Iterating trough the result multiple times could be done trough
a call to QueryResult.reset()
and retrieval of a new QueryResult.iterator()
is required.
When iteration is done a call to QueryResult.stop()
will free up
resources from the server it is good practice to do so when
done processing on this object.
Modifier and Type | Class and Description |
---|---|
static class |
QueryResult.Entry<E extends ResultType>
Represent result entry in a XPath query.
|
Modifier and Type | Method and Description |
---|---|
Iterator<QueryResult.Entry<T>> |
iterator()
Retrieves an iterator from which one could iterate over the
result.
|
void |
reset()
Reset/Rewind a running query so that it starts from the
beginning again.
|
void |
reset(int offset)
Reset/Rewind a running query to a specific offset.
|
long |
resultCount()
Get number of elements in the result.
|
void |
stop()
Stops the running query and makes the server end
free up any internal resources associated with the query.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public void reset() throws ConfException, IOException
QueryResult.iterator()
will then return the first chunk of
results.
The method can be called at any time (i.e. both after all results have been returned to essentially run the same query again, as well as after fetching just one or a couple of results).
ConfException
IOException
public void reset(int offset) throws ConfException, IOException
QueryResult.iterator()
will then reinitialize with first chunk starting with element at offset.
The method can be called at any time.
ConfException
IOException
public long resultCount() throws ConfException, IOException
ConfException
IOException
public void stop() throws ConfException, IOException
Stops the running query and makes the server end free up any internal resources associated with the query.
ConfException
IOException
public Iterator<QueryResult.Entry<T>> iterator()
iterator
in interface Iterable<QueryResult.Entry<T extends ResultType>>