Package org.lightcouch
Class Changes
java.lang.Object
org.lightcouch.Changes
Contains 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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate CouchDbClientBaseprivate com.google.gson.Gsonprivate org.apache.http.client.methods.HttpGetprivate ChangesResult.Rowprivate BufferedReaderprivate booleanprivate URIBuilder -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRequests Change notifications of feed type continuous.Requests Change notifications of feed type normal.private ChangesResult.Rowprivate BufferedReaderbooleanhasNext()Checks whether a feed is available in the continuous stream, blocking until a feed is received.heartBeat(long heartBeat) includeDocs(boolean includeDocs) limit(int limit) next()private booleanReads and sets the next feed in the stream.private voidsetNextRow(ChangesResult.Row nextRow) private voidsetReader(BufferedReader reader) voidstop()Stops a running continuous feed.private voidtimeout(long timeout)
-
Field Details
-
reader
-
httpGet
private org.apache.http.client.methods.HttpGet httpGet -
nextRow
-
stop
private boolean stop -
dbc
-
gson
private com.google.gson.Gson gson -
uriBuilder
-
-
Constructor Details
-
Changes
Changes(CouchDbClientBase dbc)
-
-
Method Details
-
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
- Returns:
- The next feed in the stream.
-
stop
public void stop()Stops a running continuous feed. -
getChanges
Requests Change notifications of feed type normal.- Returns:
ChangesResult
-
since
-
limit
-
heartBeat
-
timeout
-
filter
-
includeDocs
-
style
-
readNextRow
private boolean readNextRow()Reads and sets the next feed in the stream. -
getReader
-
setReader
-
getNextRow
-
setNextRow
-
terminate
private void terminate()
-