public class View
extends java.lang.Object
List<Foo> list = dbClient.view("example/foo")
.startKey("start-key")
.endKey("end-key")
.limit(10)
.includeDocs(true)
.query(Foo.class);
// scalar values
int count = dbClient.view("example/by_tag")
.key("couchdb")
.queryForInt();
// pagination
Page<Foo> page = dbClient.view("example/foo").queryPage(...);
CouchDbClientBase.view(String),
ViewResult| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
ACTION |
private java.lang.String |
allDocsKeys |
private static java.lang.String |
CURRENT_KEYS |
private static java.lang.String |
CURRENT_START_KEY |
private static java.lang.String |
CURRENT_START_KEY_DOC_ID |
private CouchDbClientBase |
dbc |
private java.lang.Boolean |
descending |
private java.lang.String |
endKey |
private java.lang.String |
endKeyDocId |
private java.lang.Boolean |
group |
private java.lang.Integer |
groupLevel |
private com.google.gson.Gson |
gson |
private java.lang.Boolean |
includeDocs |
private java.lang.Boolean |
inclusiveEnd |
private java.lang.String |
key |
private java.lang.Integer |
limit |
private static org.apache.commons.logging.Log |
log |
private static java.lang.String |
MAP_JS |
private DesignDocument.MapReduce |
mapRedtempViewM |
private static java.lang.String |
NEXT |
private static java.lang.String |
PREVIOUS |
private java.lang.Boolean |
reduce |
private static java.lang.String |
REDUCE_JS |
private java.lang.Integer |
skip |
private java.lang.String |
stale |
private static java.lang.String |
START_KEY |
private static java.lang.String |
START_KEY_DOC_ID |
private java.lang.String |
startKey |
private java.lang.String |
startKeyDocId |
private static java.lang.String |
TEMP_VIEWS_DIR |
private java.lang.Boolean |
updateSeq |
private URIBuilder |
uriBuilder |
| Constructor and Description |
|---|
View(CouchDbClientBase dbc,
java.lang.String viewId) |
| Modifier and Type | Method and Description |
|---|---|
View |
descending(java.lang.Boolean descending)
Reverses the reading direction, not the sort order.
|
View |
endKey(java.lang.Object... endKey) |
View |
endKeyDocId(java.lang.String endKeyDocId) |
private java.lang.String |
getKeyAsJson(java.lang.Object... key) |
View |
group(java.lang.Boolean group) |
View |
groupLevel(java.lang.Integer groupLevel) |
View |
includeDocs(java.lang.Boolean includeDocs) |
View |
inclusiveEnd(java.lang.Boolean inclusiveEnd) |
View |
key(java.lang.Object... key) |
View |
keys(java.util.List<java.lang.String> keys)
Supplies a key list when calling _all_docs View.
|
View |
limit(java.lang.Integer limit) |
<T> java.util.List<T> |
query(java.lang.Class<T> classOfT)
Queries a view.
|
boolean |
queryForBoolean() |
int |
queryForInt() |
long |
queryForLong() |
java.io.InputStream |
queryForStream()
Queries a view as an
InputStream |
java.lang.String |
queryForString() |
private <T> Page<T> |
queryNextPage(int rowsPerPage,
java.lang.String currentStartKey,
java.lang.String currentStartKeyDocId,
java.lang.String startKey,
java.lang.String startKeyDocId,
java.lang.Class<T> classOfT) |
<T> Page<T> |
queryPage(int rowsPerPage,
java.lang.String param,
java.lang.Class<T> classOfT)
Queries a view for pagination, returns a next or a previous page, this method
figures out which page to return based on the given param that is generated by an
earlier call to this method, quering the first page is done by passing a
null param. |
private <T> Page<T> |
queryPreviousPage(int rowsPerPage,
java.lang.String currentStartKey,
java.lang.String currentStartKeyDocId,
java.lang.String startKey,
java.lang.String startKeyDocId,
java.lang.Class<T> classOfT) |
private <V> V |
queryValue(java.lang.Class<V> classOfV)
Queries for scalar values.
|
<K,V,T> ViewResult<K,V,T> |
queryView(java.lang.Class<K> classOfK,
java.lang.Class<V> classOfV,
java.lang.Class<T> classOfT)
Queries a view.
|
View |
reduce(java.lang.Boolean reduce) |
View |
skip(java.lang.Integer skip) |
View |
stale(java.lang.String stale) |
View |
startKey(java.lang.Object... startKey) |
View |
startKeyDocId(java.lang.String startKeyDocId) |
View |
tempView(DesignDocument.MapReduce mapReduce) |
View |
tempView(java.lang.String id) |
View |
updateSeq(java.lang.Boolean updateSeq) |
private static final org.apache.commons.logging.Log log
private static final java.lang.String START_KEY
private static final java.lang.String START_KEY_DOC_ID
private static final java.lang.String CURRENT_START_KEY
private static final java.lang.String CURRENT_START_KEY_DOC_ID
private static final java.lang.String CURRENT_KEYS
private static final java.lang.String ACTION
private static final java.lang.String NEXT
private static final java.lang.String PREVIOUS
private static final java.lang.String TEMP_VIEWS_DIR
private static final java.lang.String MAP_JS
private static final java.lang.String REDUCE_JS
private java.lang.String key
private java.lang.String startKey
private java.lang.String startKeyDocId
private java.lang.String endKey
private java.lang.String endKeyDocId
private java.lang.Integer limit
private java.lang.String stale
private java.lang.Boolean descending
private java.lang.Integer skip
private java.lang.Boolean group
private java.lang.Integer groupLevel
private java.lang.Boolean reduce
private java.lang.Boolean includeDocs
private java.lang.Boolean inclusiveEnd
private java.lang.Boolean updateSeq
private CouchDbClientBase dbc
private com.google.gson.Gson gson
private URIBuilder uriBuilder
private java.lang.String allDocsKeys
private DesignDocument.MapReduce mapRedtempViewM
View(CouchDbClientBase dbc, java.lang.String viewId)
public java.io.InputStream queryForStream()
InputStream
The stream should be properly closed after usage, as to avoid connection leaks.
InputStream.public <T> java.util.List<T> query(java.lang.Class<T> classOfT)
T - Object type TclassOfT - The class of type TList<T> public <K,V,T> ViewResult<K,V,T> queryView(java.lang.Class<K> classOfK, java.lang.Class<V> classOfV, java.lang.Class<T> classOfT)
K - Object type K (key)V - Object type V (value)classOfK - The class of type K.classOfV - The class of type V.classOfT - The class of type T.public java.lang.String queryForString()
public int queryForInt()
public long queryForLong()
public boolean queryForBoolean()
private <V> V queryValue(java.lang.Class<V> classOfV)
public <T> Page<T> queryPage(int rowsPerPage, java.lang.String param, java.lang.Class<T> classOfT)
null param.T - Object type TrowsPerPage - The number of rows per page.param - The request parameter to use to query a page, or null to return the first page.classOfT - The class of type T.Pageprivate <T> Page<T> queryNextPage(int rowsPerPage, java.lang.String currentStartKey, java.lang.String currentStartKeyDocId, java.lang.String startKey, java.lang.String startKeyDocId, java.lang.Class<T> classOfT)
private <T> Page<T> queryPreviousPage(int rowsPerPage, java.lang.String currentStartKey, java.lang.String currentStartKeyDocId, java.lang.String startKey, java.lang.String startKeyDocId, java.lang.Class<T> classOfT)
public View key(java.lang.Object... key)
key - The key value, accepts a single value or multiple values for complex keys.public View startKey(java.lang.Object... startKey)
startKey - The start key value, accepts a single value or multiple values for complex keys.public View startKeyDocId(java.lang.String startKeyDocId)
public View endKey(java.lang.Object... endKey)
endKey - The end key value, accepts a single value or multiple values for complex keys.public View endKeyDocId(java.lang.String endKeyDocId)
public View limit(java.lang.Integer limit)
public View stale(java.lang.String stale)
stale - Accept values: ok | update_after (update_after as of CouchDB 1.1.0)public View descending(java.lang.Boolean descending)
public View skip(java.lang.Integer skip)
skip - Skips n number of documents.public View group(java.lang.Boolean group)
group - Specifies whether the reduce function reduces the result to a set of keys,
or to a single result. Defaults to false (single result).public View groupLevel(java.lang.Integer groupLevel)
public View reduce(java.lang.Boolean reduce)
reduce - Indicates whether to use the reduce function of the view,
defaults to true if the reduce function is defined.public View includeDocs(java.lang.Boolean includeDocs)
public View inclusiveEnd(java.lang.Boolean inclusiveEnd)
inclusiveEnd - Indicates whether the endkey is included in the result,
defaults to true.public View updateSeq(java.lang.Boolean updateSeq)
public View keys(java.util.List<java.lang.String> keys)
keys - public View tempView(java.lang.String id)
public View tempView(DesignDocument.MapReduce mapReduce)
private java.lang.String getKeyAsJson(java.lang.Object... key)