Package org.lightcouch
Class Changes
- java.lang.Object
-
- org.lightcouch.Changes
-
public class Changes extends java.lang.ObjectContains the Change Notifications API, supports normal and continuous feed Changes.
Usage Example:
// feed type normal String since = dbClient.context().info().getUpdateSeq(); // latest update seq ChangesResult changeResult = dbClient.changes() .since(since) .limit(10) .filter("example/filter") .getChanges(); for (ChangesResult.Row row : changeResult.getResults()) { String docId = row.getId() JsonObject doc = row.getDoc(); } // feed type continuous Changes changes = dbClient.changes() .includeDocs(true) .heartBeat(30000) .continuousChanges(); while (changes.hasNext()) { ChangesResult.Row feed = changes.next(); String docId = feed.getId(); JsonObject doc = feed.getDoc(); // changes.stop(); // stop continuous feed }- Since:
- 0.0.2
- See Also:
ChangesResult
-
-
Field Summary
Fields Modifier and Type Field Description private CouchDbClientBasedbcprivate com.google.gson.Gsongsonprivate org.apache.http.client.methods.HttpGethttpGetprivate ChangesResult.RownextRowprivate java.io.BufferedReaderreaderprivate booleanstopprivate URIBuilderuriBuilder
-
Constructor Summary
Constructors Constructor Description Changes(CouchDbClientBase dbc)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChangescontinuousChanges()Requests Change notifications of feed type continuous.Changesfilter(java.lang.String filter)ChangesResultgetChanges()Requests Change notifications of feed type normal.private ChangesResult.RowgetNextRow()private java.io.BufferedReadergetReader()booleanhasNext()Checks whether a feed is available in the continuous stream, blocking until a feed is received.ChangesheartBeat(long heartBeat)ChangesincludeDocs(boolean includeDocs)Changeslimit(int limit)ChangesResult.Rownext()private booleanreadNextRow()Reads and sets the next feed in the stream.private voidsetNextRow(ChangesResult.Row nextRow)private voidsetReader(java.io.BufferedReader reader)Changessince(java.lang.String since)voidstop()Stops a running continuous feed.Changesstyle(java.lang.String style)private voidterminate()Changestimeout(long timeout)
-
-
-
Field Detail
-
reader
private java.io.BufferedReader reader
-
httpGet
private org.apache.http.client.methods.HttpGet httpGet
-
nextRow
private ChangesResult.Row nextRow
-
stop
private boolean stop
-
dbc
private CouchDbClientBase dbc
-
gson
private com.google.gson.Gson gson
-
uriBuilder
private URIBuilder uriBuilder
-
-
Constructor Detail
-
Changes
Changes(CouchDbClientBase dbc)
-
-
Method Detail
-
continuousChanges
public Changes continuousChanges()
Requests Change notifications of feed type continuous.Feed notifications are accessed in an iterator style.
- Returns:
Changes
-
hasNext
public boolean hasNext()
Checks whether a feed is available in the continuous stream, blocking until a feed is received.- Returns:
- true If a feed is available
-
next
public ChangesResult.Row next()
- Returns:
- The next feed in the stream.
-
stop
public void stop()
Stops a running continuous feed.
-
getChanges
public ChangesResult getChanges()
Requests Change notifications of feed type normal.- Returns:
ChangesResult
-
since
public Changes since(java.lang.String since)
-
limit
public Changes limit(int limit)
-
heartBeat
public Changes heartBeat(long heartBeat)
-
timeout
public Changes timeout(long timeout)
-
filter
public Changes filter(java.lang.String filter)
-
includeDocs
public Changes includeDocs(boolean includeDocs)
-
style
public Changes style(java.lang.String style)
-
readNextRow
private boolean readNextRow()
Reads and sets the next feed in the stream.
-
getReader
private java.io.BufferedReader getReader()
-
setReader
private void setReader(java.io.BufferedReader reader)
-
getNextRow
private ChangesResult.Row getNextRow()
-
setNextRow
private void setNextRow(ChangesResult.Row nextRow)
-
terminate
private void terminate()
-
-