示例#1
0
  /**
   * Queries a view as an {@link InputStream}
   *
   * <p>The stream should be properly closed after usage, as to avoid connection leaks.
   *
   * @return The result as an {@link InputStream}.
   */
  public InputStream queryForStream() {
    URI uri = uriBuilder.build();
    if (allDocsKeys != null) { // bulk docs
      return getStream(dbc.post(uri, allDocsKeys));
    }
    if (mapRedtempViewM != null) { // temp view
      return getStream(dbc.post(uri, gson.toJson(mapRedtempViewM)));
    }

    return dbc.get(uri);
  }
示例#2
0
  View(CouchDbClientBase dbc, String viewId) {
    assertNotEmpty(viewId, "View id");
    this.dbc = dbc;
    this.gson = dbc.getGson();

    String view = viewId;
    if (viewId.contains("/")) {
      String[] v = viewId.split("/");
      view = String.format("_design/%s/_view/%s", v[0], v[1]);
    }
    this.uriBuilder = URIBuilder.buildUri(dbc.getDBUri()).path(view);
  }
示例#3
0
 public View includeDocs(Boolean includeDocs) {
   this.includeDocs = includeDocs;
   uriBuilder.query("include_docs", this.includeDocs);
   return this;
 }
示例#4
0
 /**
  * @param reduce Indicates whether to use the reduce function of the view, defaults to true if the
  *     reduce function is defined.
  */
 public View reduce(Boolean reduce) {
   this.reduce = reduce;
   uriBuilder.query("reduce", this.reduce);
   return this;
 }
示例#5
0
 public View groupLevel(Integer groupLevel) {
   this.groupLevel = groupLevel;
   uriBuilder.query("group_level", this.groupLevel);
   return this;
 }
示例#6
0
 /**
  * @param 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 group(Boolean group) {
   this.group = group;
   uriBuilder.query("group", this.group);
   return this;
 }
示例#7
0
 /** @param skip Skips <i>n</i> number of documents. */
 public View skip(Integer skip) {
   this.skip = skip;
   uriBuilder.query("skip", this.skip);
   return this;
 }
示例#8
0
 /** Reverses the reading direction, not the sort order. */
 public View descending(Boolean descending) {
   this.descending = Boolean.valueOf(gson.toJson(descending));
   uriBuilder.query("descending", this.descending);
   return this;
 }
示例#9
0
 public View limit(Integer limit) {
   this.limit = limit;
   uriBuilder.query("limit", this.limit);
   return this;
 }
示例#10
0
 public View endKeyDocId(String endKeyDocId) {
   this.endKeyDocId = endKeyDocId;
   uriBuilder.query("endkey_docid", this.endKeyDocId);
   return this;
 }
示例#11
0
 /**
  * @param endKey The end key value, accepts a single value or multiple values for complex keys.
  */
 public View endKey(Object... endKey) {
   this.endKey = getKeyAsJson(endKey);
   uriBuilder.query("endkey", this.endKey);
   return this;
 }
示例#12
0
 public View startKeyDocId(String startKeyDocId) {
   this.startKeyDocId = startKeyDocId;
   uriBuilder.query("startkey_docid", this.startKeyDocId);
   return this;
 }
示例#13
0
 /**
  * @param startKey The start key value, accepts a single value or multiple values for complex
  *     keys.
  */
 public View startKey(Object... startKey) {
   this.startKey = getKeyAsJson(startKey);
   uriBuilder.query("startkey", this.startKey);
   return this;
 }
示例#14
0
 /** @param key The key value, accepts a single value or multiple values for complex keys. */
 public View key(Object... key) {
   this.key = getKeyAsJson(key);
   uriBuilder.query("key", this.key);
   return this;
 }
示例#15
0
 /**
  * @param inclusiveEnd Indicates whether the endkey is included in the result, defaults to true.
  */
 public View inclusiveEnd(Boolean inclusiveEnd) {
   this.inclusiveEnd = inclusiveEnd;
   uriBuilder.query("inclusive_end", this.inclusiveEnd);
   return this;
 }
示例#16
0
 public View updateSeq(Boolean updateSeq) {
   this.updateSeq = updateSeq;
   uriBuilder.query("update_seq", this.updateSeq);
   return this;
 }
示例#17
0
 /** @param stale Accept values: ok | update_after (update_after as of CouchDB 1.1.0) */
 public View stale(String stale) {
   this.stale = stale;
   uriBuilder.query("stale", this.stale);
   return this;
 }