public abstract class CouchDbClientBase extends Object
CouchDbClient
,
CouchDbClientAndroid
Modifier and Type | Method and Description |
---|---|
void |
batch(Object object)
Saves the given object in a batch request.
|
List<Response> |
bulk(List<?> objects,
boolean allOrNothing)
Performs a Bulk Documents request.
|
Changes |
changes()
Provides access to the Change Notifications API.
|
boolean |
contains(String id)
Checks if the database contains a document given an id.
|
CouchDbContext |
context()
Provides access to the database APIs.
|
CouchDbDesign |
design()
Provides access to the database design documents API.
|
org.apache.http.HttpResponse |
executeRequest(org.apache.http.client.methods.HttpRequestBase request)
Executes a HTTP request.
|
<T> T |
find(Class<T> classType,
String id)
Finds an Object of the specified type.
|
<T> T |
find(Class<T> classType,
String id,
Params params)
Finds an Object of the specified type.
|
<T> T |
find(Class<T> classType,
String id,
String rev)
Finds an Object of the specified type.
|
InputStream |
find(String id)
Finds a document and returns the result as an
InputStream . |
InputStream |
find(String id,
String rev)
Finds a document given an id and revision, returns the result as
InputStream . |
<T> T |
findAny(Class<T> classType,
String uri)
A General purpose find, that gives more control over the query.
|
URI |
getBaseUri() |
URI |
getDBUri() |
com.google.gson.Gson |
getGson() |
String |
invokeUpdateHandler(String updateHandlerUri,
String docId,
String query)
Invokes an Update Handler.
|
Response |
remove(Object object)
Removes an object from the database, the object must have the correct id and revision values.
|
Response |
remove(String id,
String rev)
Removes a document from the database, given both an id and revision values.
|
Replication |
replication()
Provides access to the replication APIs.
|
Replicator |
replicator()
Provides access to the replicator database APIs.
|
Response |
save(Object object)
Saves an object in the database.
|
Response |
saveAttachment(InputStream instream,
String name,
String contentType)
Saves an attachment under a new document with a generated UUID as the document id.
|
Response |
saveAttachment(InputStream instream,
String name,
String contentType,
String docId,
String docRev)
Saves an attachment under an existing document given both a document id
and revision, or under a new document given only the document id.
|
void |
setGsonBuilder(com.google.gson.GsonBuilder gsonBuilder)
Sets a
GsonBuilder to create Gson instance. |
void |
syncDesignDocsWithDb()
Synchronize all design documents on desk with the database.
|
Response |
update(Object object)
Updates an object in the database, the object must have the correct id and revision values.
|
View |
view(String viewId)
Provides access to the View APIs.
|
public CouchDbContext context()
public CouchDbDesign design()
public Replication replication()
public Replicator replicator()
public Changes changes()
public <T> T find(Class<T> classType, String id)
T
- Object type.classType
- The class of type T.id
- The document id.NoDocumentException
- If the document is not found in the database.public <T> T find(Class<T> classType, String id, Params params)
T
- Object type.classType
- The class of type T.id
- The document id.params
- Extra parameters to append.NoDocumentException
- If the document is not found in the database.public <T> T find(Class<T> classType, String id, String rev)
T
- Object type.classType
- The class of type T.id
- The document id to get.rev
- The document revision.NoDocumentException
- If the document is not found in the database.public <T> T findAny(Class<T> classType, String uri)
Unlike other finders, this method expects a fully formated and encoded URI to be supplied.
classType
- The class of type T.uri
- The URI.public InputStream find(String id)
Finds a document and returns the result as an InputStream
.
id
- The document id.InputStream
NoDocumentException
- If the document is not found in the database.find(String, String)
public InputStream find(String id, String rev)
Finds a document given an id and revision, returns the result as InputStream
.
id
- The document id.rev
- The document revision.InputStream
NoDocumentException
- If the document is not found in the database.public boolean contains(String id)
id
- The document id.public Response save(Object object) throws UnsupportedEncodingException
object
- The object to saveResponse
DocumentConflictException
- If a conflict is detected during the save.UnsupportedEncodingException
public void batch(Object object) throws UnsupportedEncodingException
object
- The object to save.UnsupportedEncodingException
public List<Response> bulk(List<?> objects, boolean allOrNothing) throws UnsupportedEncodingException
objects
- The List
of objects.allOrNothing
- Indicated whether the request has all-or-nothing semantics.List<Response>
Containing the resulted entries.UnsupportedEncodingException
public Response saveAttachment(InputStream instream, String name, String contentType) throws UnsupportedEncodingException
Saves an attachment under a new document with a generated UUID as the document id.
To retrieve an attachment, see find(String)
.
instream
- The InputStream
holding the binary data.name
- The attachment name.contentType
- The attachment "Content-Type".Response
UnsupportedEncodingException
public Response saveAttachment(InputStream instream, String name, String contentType, String docId, String docRev) throws UnsupportedEncodingException
Saves an attachment under an existing document given both a document id and revision, or under a new document given only the document id.
To retrieve an attachment, see find(String)
.
instream
- The InputStream
holding the binary data.name
- The attachment name.contentType
- The attachment "Content-Type".docId
- The document id to save the attachment under, or null
to save under a new document.docRev
- The document revision to save the attachment under, or null
when saving to a new document.Response
DocumentConflictException
UnsupportedEncodingException
public Response update(Object object) throws UnsupportedEncodingException
object
- The object to updateResponse
DocumentConflictException
- If a conflict is detected during the update.UnsupportedEncodingException
public Response remove(Object object)
object
- The object to removeResponse
NoDocumentException
- If the document could not be found in the database.public Response remove(String id, String rev)
id
- The document idrev
- The document revisionResponse
NoDocumentException
- If the document could not be found in the database.public String invokeUpdateHandler(String updateHandlerUri, String docId, String query)
updateHandlerUri
- The Update Handler URI, in the format: designDocId/updateFunction
docId
- The document id to update.query
- The query string parameters, e.g, field=field1&value=value1public org.apache.http.HttpResponse executeRequest(org.apache.http.client.methods.HttpRequestBase request)
request
- The HTTP request to execute.HttpResponse
public void syncDesignDocsWithDb() throws UnsupportedEncodingException
Shorthand for CouchDbDesign.synchronizeAllWithDb()
This method might be used to sync design documents upon a client creation, eg. a Spring bean init-method.
UnsupportedEncodingException
public void setGsonBuilder(com.google.gson.GsonBuilder gsonBuilder)
GsonBuilder
to create Gson
instance.
Useful for registering custom serializers/deserializers, such as JodaTime classes.
public URI getDBUri()
public URI getBaseUri()
public com.google.gson.Gson getGson()
Copyright © 2011–2016. All rights reserved.