com.streambase.liveview.client

## Class SnapshotQueryListener

- java.lang.Object
- - com.streambase.liveview.client.SnapshotQueryListener

- All Implemented Interfaces:
    QueryListener, SnapshotResult, Closeable, AutoCloseable, EventListener

      public final class SnapshotQueryListener
      extends Object
      implements SnapshotResult, QueryListener

  A Convenience implementation of `QueryListener` that provides a pull based iterator pattern for iterating over snapshot queries. This should be used with snapshot queries only. Snapshots that hit the row limit are ended without any special notification.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SnapshotQueryListener()`
    `SnapshotQueryListener(int dataQueueCapacity)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` closes any resource associated with the snapshot result
    `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.
    `List<Schema.Field>` | `getFields()` Retrieves the fields describing the tuples that will be returned.
    `boolean` | `hasNext()` See if there are more tuples to retrieve.
    `Tuple` | `next()` Retrieves the next tuple in the result.
    `void` | `queryClosed(QueryClosedEvent event)` Event when a query being listened to is closed.
    `void` | `setQuery(Query queryImpl)`
    `void` | `snapshotBegin(BeginSnapshotEvent event)` Event to indicate the start of the result snapshot.
    `void` | `snapshotEnd(EndSnapshotEvent event)` Event to indicate the query snapshot is complete.
    `void` | `tupleAdded(TupleAddedEvent event)` Event when a new tuple is added to the result.
    `void` | `tupleRemoved(TupleRemovedEvent event)` Event when an existing tuple is removed from the result.
    `void` | `tupleUpdated(TupleUpdatedEvent event)` Event when an existing tuple in the result is updated.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.streambase.liveview.client.QueryListener

      `aggMarkBegin, aggMarkEnd`

- - ### Constructor Detail

    - #### SnapshotQueryListener

          public SnapshotQueryListener()

    - #### SnapshotQueryListener

          public SnapshotQueryListener(int dataQueueCapacity)

  - ### Method Detail

    - #### getFields

          public List<Schema.Field> getFields()
                                       throws LiveViewException

      Retrieves the fields describing the tuples that will be returned.
      Specified by:
        `getFields` in interface `SnapshotResult`
      Returns:
        the fields describing the tuples
      Throws:
        `LiveViewException` - if exception occurs on the Query

    - #### hasNext

          public boolean hasNext()
                          throws LiveViewException

      See if there are more tuples to retrieve. If there are not currently any Tuples waiting to be read, this will block until either the next Tuple or the Snapshot end arrives.
      Specified by:
        `hasNext` in interface `SnapshotResult`
      Returns:
        true if more tuples exist in result
      Throws:
        `LiveViewException`

    - #### next

          public Tuple next()
                     throws LiveViewException

      Retrieves the next tuple in the result. If there are not currently any Tuples waiting to be read, this will block until either the next Tuple or the Snapshot end arrives.
      Specified by:
        `next` in interface `SnapshotResult`
      Returns:
        the next tuple
      Throws:
        `LiveViewException` - if exception occurs on the Query

    - #### tupleAdded

          public void tupleAdded(TupleAddedEvent event)

      Event when a new tuple is added to the result.
      Specified by:
        `tupleAdded` in interface `QueryListener`
      Parameters:
        `event` - add event

    - #### tupleUpdated

          public void tupleUpdated(TupleUpdatedEvent event)

      Event when an existing tuple in the result is updated.
      Specified by:
        `tupleUpdated` in interface `QueryListener`
      Parameters:
        `event` - update event

    - #### tupleRemoved

          public void tupleRemoved(TupleRemovedEvent event)

      Event when an existing tuple is removed from the result.
      Specified by:
        `tupleRemoved` in interface `QueryListener`
      Parameters:
        `event` - remove event

    - #### snapshotBegin

          public void snapshotBegin(BeginSnapshotEvent event)

      Event to indicate the start of the result snapshot. This is the first method called when a query starts returning results, but this method is also called to indicate a reset (a complete restart of the query.)
      Specified by:
        `snapshotBegin` in interface `QueryListener`
      Parameters:
        `event` - snapshot begin

    - #### snapshotEnd

          public void snapshotEnd(EndSnapshotEvent event)

      Event to indicate the query snapshot is complete.
      Specified by:
        `snapshotEnd` in interface `QueryListener`
      Parameters:
        `event` - snapshot end

    - #### exceptionRaised

          public void exceptionRaised(QueryExceptionEvent event)

      Event when an exception occurs during the query. Since 1.3, reaching the row limit is considered an exception.
      Specified by:
        `exceptionRaised` in interface `QueryListener`
      Parameters:
        `event` - exception event

    - #### queryClosed

          public void queryClosed(QueryClosedEvent event)

      Event when a query being listened to is closed.
      Specified by:
        `queryClosed` in interface `QueryListener`
      Parameters:
        `event` - query closed event

    - #### setQuery

          public void setQuery(Query queryImpl)

    - #### close

          public void close()

      Description copied from interface: `SnapshotResult`
      closes any resource associated with the snapshot result
      Specified by:
        `close` in interface `SnapshotResult`
      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`

    - #### deleteBegin

          public void deleteBegin(BeginDeleteEvent event)

      Description copied from interface: `QueryListener`
      Event to indicate the start of delete query.
      Specified by:
        `deleteBegin` in interface `QueryListener`
      Parameters:
        `event` - delete begin

    - #### deleteEnd

          public void deleteEnd(EndDeleteEvent event)

      Description copied from interface: `QueryListener`
      Event to indicate the delete query is complete.
      Specified by:
        `deleteEnd` in interface `QueryListener`
      Parameters:
        `event` - delete end

Copyright © 2015–2018 Cloud Software Group, Inc.. All rights reserved.