public class DesignDocument
extends com.cloudant.client.org.lightcouch.Document
This is the type of design document objects used by the
DesignDocumentManager
.
This class can be used as a deserialization target for design documents stored in a database. For example:
DesignDocument exampleDDoc = database.find(DesignDocument.class, "_design/exampleDesignDoc");
This class can also be used to create or update design documents. For example:
// Create
DesignDocument ddoc = new DesignDocument();
// Call setters on ddoc to populate document
ddoc.setId("_design/exampleDesignDoc");
// Save to create the design document
database.save(ddoc)
// Update
DesignDocument ddoc = database.find(DesignDocument.class, "_design/exampleDesignDoc");
// Call setters to update values
Map<String, String> updates = new HashMap<String, String>();
updates.put("newUpdateHandler", "function (doc, req) { ... }");
ddoc.setUpdates(updates);
// Update the design document
database.update(ddoc);
DesignDocumentManager
Modifier and Type | Class and Description |
---|---|
static class |
DesignDocument.MapReduce
Encapsulates the Map-Reduce function of a view.
|
static class |
DesignDocument.Options
Encapsulates design document options.
|
Constructor and Description |
---|
DesignDocument() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o)
Compares this design document to the specified object.
|
java.util.Map<java.lang.String,java.lang.String> |
getFilters()
Get the changes feed filter functions defined in this design document.
|
com.google.gson.JsonObject |
getFulltext() |
com.google.gson.JsonObject |
getIndexes()
Get a JSON object containing all the indexes defined in the design document.
|
java.lang.String |
getLanguage()
Get the language used for the views defined in this design document.
|
java.util.Map<java.lang.String,java.lang.String> |
getLists()
Get the list functions defined in this design document.
|
DesignDocument.Options |
getOptions()
Get the options defined in this design document.
|
com.google.gson.JsonArray |
getRewrites()
Get the array of URL rewriting rules set in the design document's
rewrites property. |
java.util.Map<java.lang.String,java.lang.String> |
getShows()
Get the show functions defined in this design document.
|
java.util.Map<java.lang.String,java.lang.String> |
getUpdates()
Get the update handlers defined in this design document.
|
java.lang.String |
getValidateDocUpdate()
Get the string of the javascript function set for the design document's
validate_doc_update property. |
java.util.Map<java.lang.String,DesignDocument.MapReduce> |
getViews()
Get the views defined in this design document.
|
int |
hashCode() |
void |
setFilters(java.util.Map<java.lang.String,java.lang.String> filters)
Define the changes feed filter functions set in this design document.
|
void |
setFulltext(com.google.gson.JsonObject fulltext) |
void |
setIndexes(com.google.gson.JsonObject indexes)
Set a JSON object defining the indexes of this design document.
|
void |
setLanguage(java.lang.String language)
Set the language of the design document.
|
void |
setLists(java.util.Map<java.lang.String,java.lang.String> lists)
Set the list functions defined in this design document.
|
void |
setOptions(DesignDocument.Options options)
Set design document options.
|
void |
setRewrites(com.google.gson.JsonArray rewrites)
Set the array of URL rewriting rules set in the design document's
rewrites property. |
void |
setShows(java.util.Map<java.lang.String,java.lang.String> shows)
Set the show functions defined in this design document.
|
void |
setUpdates(java.util.Map<java.lang.String,java.lang.String> updates)
Set the update handlers defined in this design document.
|
void |
setValidateDocUpdate(java.lang.String validateDocUpdate)
Set the javascript function for the design document's
validate_doc_update property. |
void |
setViews(java.util.Map<java.lang.String,DesignDocument.MapReduce> views)
Set the views defined in this design document's view property.
|
public java.lang.String getLanguage()
public java.util.Map<java.lang.String,DesignDocument.MapReduce> getViews()
DesignDocument.MapReduce
from the viewpublic java.lang.String getValidateDocUpdate()
validate_doc_update
property.public com.google.gson.JsonArray getRewrites()
rewrites
property.public com.google.gson.JsonObject getFulltext()
fulltext
propertypublic com.google.gson.JsonObject getIndexes()
indexes
propertypublic java.util.Map<java.lang.String,java.lang.String> getFilters()
public java.util.Map<java.lang.String,java.lang.String> getShows()
public java.util.Map<java.lang.String,java.lang.String> getLists()
public java.util.Map<java.lang.String,java.lang.String> getUpdates()
public DesignDocument.Options getOptions()
null
if no options are definedpublic void setLanguage(java.lang.String language)
language
- typically "javascript"
public void setViews(java.util.Map<java.lang.String,DesignDocument.MapReduce> views)
views
- map of view name to MapReduce classpublic void setValidateDocUpdate(java.lang.String validateDocUpdate)
validate_doc_update
property.validateDocUpdate
- string defining validate_doc_update functionpublic void setRewrites(com.google.gson.JsonArray rewrites)
rewrites
property.rewrites
- array of JsonObjects each representing a rewrite rulepublic void setFulltext(com.google.gson.JsonObject fulltext)
fulltext
- JsonObject to set as the design document's fulltext
propertypublic void setIndexes(com.google.gson.JsonObject indexes)
indexes
- JsonObject defining the indexespublic void setFilters(java.util.Map<java.lang.String,java.lang.String> filters)
filters
- map of filter name to function stringpublic void setShows(java.util.Map<java.lang.String,java.lang.String> shows)
shows
- map of show function name to function stringpublic void setLists(java.util.Map<java.lang.String,java.lang.String> lists)
lists
- map of list function name to function stringpublic void setUpdates(java.util.Map<java.lang.String,java.lang.String> updates)
updates
- map of update handler name to function stringpublic void setOptions(DesignDocument.Options options)
options
- design document optionspublic int hashCode()
hashCode
in class com.cloudant.client.org.lightcouch.Document
public boolean equals(java.lang.Object o)
true
if and only
if the argument is not null
and is a DesignDocument
with the same
_id
, _rev
, and document contents.equals
in class com.cloudant.client.org.lightcouch.Document
o
- The object to compare this design document totrue
if the given object represents a design document equivalent to this
design document, false
otherwise