public class LiveResult extends Object implements QueryListener
QueryListener the receives and maintains a local copy of tuples. Methods exists
to retrieve the current list of tuples maintained locally. The live results can also be constructed
with a nested QueryListener.
In this mode the live result will propagate events it received to the nested listener. It will also modify update
and remove events to include the old or removed tuple (in addition to the new tuple.)| Constructor and Description |
|---|
LiveResult()
Construct a LiveResult that will maintain the list of tuples for you which you can query at your leisure.
|
LiveResult(QueryListener listener)
Contruct a LiveResult that will maintain the tuples for you, plus you can also be informed of all the events.
|
| Modifier and Type | Method and Description |
|---|---|
void |
deleteBegin(BeginDeleteEvent event)
Event to indicate the start of delete query.
|
void |
deleteEnd(EndDeleteEvent event)
Event to indicate the delete query is complete.
|
void |
exceptionRaised(QueryExceptionEvent event)
Event when an exception occurs during the query.
|
Collection<Tuple> |
getTuples()
Retrieves the current tuples in the result
|
Collection<Tuple> |
getTuples(boolean waitForSnapshot)
Retrieves the current tuples in the result
|
boolean |
isEmpty()
Is the result empty
|
void |
queryClosed(QueryClosedEvent event)
Event when a query being listened to is closed.
|
void |
setTimeout(int ms)
setTimeout limits the amount of time to wait for the snapshot to complete.
|
int |
size()
The size of the result
|
void |
snapshotBegin(BeginSnapshotEvent event)
Event to indicate the start of snapshot results.
|
void |
snapshotEnd(EndSnapshotEvent event)
Event to indicate the snapshot is complete.
|
void |
tupleAdded(TupleAddedEvent event)
Event when a new tuple is added to the Query result.
|
void |
tupleRemoved(TupleRemovedEvent event)
Event when an existing tuple is removed from a result.
|
void |
tupleUpdated(TupleUpdatedEvent event)
Event when an existing tuple in the result is updated.
|
void |
waitForSnapshot()
Blocking call that waits for the query snapshot to complete.
|
public LiveResult(QueryListener listener)
listener - The listener to dispatch events to when changes occur on this LiveResultpublic LiveResult()
public void setTimeout(int ms)
ms - - number of milliseconds to wait before abandoning waiting for snapshot complete.public final boolean isEmpty()
public final int size()
public final Collection<Tuple> getTuples()
public final Collection<Tuple> getTuples(boolean waitForSnapshot)
waitForSnapshot - waits for the query snapshot to complete before returning from the callpublic final void waitForSnapshot()
public void tupleAdded(TupleAddedEvent event)
tupleAdded in interface QueryListenerevent - add eventpublic void tupleUpdated(TupleUpdatedEvent event)
tupleUpdated in interface QueryListenerevent - update eventpublic void tupleRemoved(TupleRemovedEvent event)
tupleRemoved in interface QueryListenerevent - remove eventpublic void snapshotBegin(BeginSnapshotEvent event)
snapshotBegin in interface QueryListenerevent - snapshot beginpublic void snapshotEnd(EndSnapshotEvent event)
snapshotEnd in interface QueryListenerevent - snapshot endpublic void exceptionRaised(QueryExceptionEvent event)
exceptionRaised in interface QueryListenerevent - exception eventpublic void queryClosed(QueryClosedEvent event)
queryClosed in interface QueryListenerevent - query closed eventpublic void deleteBegin(BeginDeleteEvent event)
QueryListenerdeleteBegin in interface QueryListenerevent - delete beginpublic void deleteEnd(EndDeleteEvent event)
QueryListenerdeleteEnd in interface QueryListenerevent - delete end