public class Changes
extends java.lang.Object
Contains the Change Notifications API, supports normal and continuous feed Changes.
// 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
}
ChangesResult| Modifier and Type | Field and Description |
|---|---|
private CouchDbClientBase |
dbc |
private com.google.gson.Gson |
gson |
private org.apache.http.client.methods.HttpGet |
httpGet |
private ChangesResult.Row |
nextRow |
private java.io.BufferedReader |
reader |
private boolean |
stop |
private URIBuilder |
uriBuilder |
| Constructor and Description |
|---|
Changes(CouchDbClientBase dbc) |
| Modifier and Type | Method and Description |
|---|---|
Changes |
continuousChanges()
Requests Change notifications of feed type continuous.
|
Changes |
filter(java.lang.String filter) |
ChangesResult |
getChanges()
Requests Change notifications of feed type normal.
|
private ChangesResult.Row |
getNextRow() |
private java.io.BufferedReader |
getReader() |
boolean |
hasNext()
Checks whether a feed is available in the continuous stream, blocking
until a feed is received.
|
Changes |
heartBeat(long heartBeat) |
Changes |
includeDocs(boolean includeDocs) |
Changes |
limit(int limit) |
ChangesResult.Row |
next() |
private boolean |
readNextRow()
Reads and sets the next feed in the stream.
|
private void |
setNextRow(ChangesResult.Row nextRow) |
private void |
setReader(java.io.BufferedReader reader) |
Changes |
since(java.lang.String since) |
void |
stop()
Stops a running continuous feed.
|
Changes |
style(java.lang.String style) |
private void |
terminate() |
Changes |
timeout(long timeout) |
private java.io.BufferedReader reader
private org.apache.http.client.methods.HttpGet httpGet
private ChangesResult.Row nextRow
private boolean stop
private CouchDbClientBase dbc
private com.google.gson.Gson gson
private URIBuilder uriBuilder
Changes(CouchDbClientBase dbc)
public Changes continuousChanges()
Feed notifications are accessed in an iterator style.
public boolean hasNext()
public ChangesResult.Row next()
public void stop()
public ChangesResult getChanges()
public Changes since(java.lang.String since)
public Changes limit(int limit)
public Changes heartBeat(long heartBeat)
public Changes timeout(long timeout)
public Changes filter(java.lang.String filter)
public Changes includeDocs(boolean includeDocs)
public Changes style(java.lang.String style)
private boolean readNextRow()
private java.io.BufferedReader getReader()
private void setReader(java.io.BufferedReader reader)
private ChangesResult.Row getNextRow()
private void setNextRow(ChangesResult.Row nextRow)
private void terminate()