public class Document
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Document.ChangeEvent
The type of event raised when a Document changes.
|
static interface |
Document.ChangeListener
A delegate that can be used to listen for Document changes.
|
static interface |
Document.DocumentUpdater
A delegate that can be used to update a Document.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
TAG |
| Constructor and Description |
|---|
Document(Database database,
java.lang.String documentId)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeListener(Document.ChangeListener changeListener) |
UnsavedRevision |
createRevision()
Creates an unsaved new revision whose parent is the currentRevision,
or which will be the first revision if the document doesn't exist yet.
|
boolean |
delete()
Deletes this document by adding a deletion revision.
|
protected void |
forgetCurrentRevision() |
java.util.List<SavedRevision> |
getConflictingRevisions()
Returns all the current conflicting revisions of the document.
|
SavedRevision |
getCurrentRevision()
Get the current revision
|
java.lang.String |
getCurrentRevisionId()
Get the ID of the current revision
|
Database |
getDatabase()
Get the document's owning database.
|
java.util.Date |
getExpirationDate()
A date/time after which this document will be automatically purged.
|
java.lang.String |
getId()
Get the document's ID
|
java.util.List<SavedRevision> |
getLeafRevisions()
Returns all the leaf revisions in the document's revision tree,
including deleted revisions (i.e.
|
protected java.util.List<SavedRevision> |
getLeafRevisions(boolean includeDeleted) |
java.util.Map<java.lang.String,java.lang.Object> |
getProperties()
The contents of the current revision of the document.
|
java.lang.Object |
getProperty(java.lang.String key)
Shorthand for getProperties().get(key)
|
SavedRevision |
getRevision(java.lang.String revID)
The revision with the specified ID.
|
protected SavedRevision |
getRevisionFromRev(RevisionInternal internalRevision) |
java.util.List<SavedRevision> |
getRevisionHistory()
Returns the document's history as an array of CBLRevisions.
|
java.util.Map<java.lang.String,java.lang.Object> |
getUserProperties()
The user-defined properties, without the ones reserved by CouchDB.
|
boolean |
isDeleted()
Is this document deleted? (That is, does its current revision have the '_deleted' property?)
|
static boolean |
isValidDocumentId(java.lang.String id)
in CBLDatabase+Insertion.m
+ (BOOL) isValidDocumentID: (NSString*)str
|
protected void |
loadCurrentRevisionFrom(QueryRow row) |
protected java.util.Map<java.lang.String,java.lang.Object> |
propertiesToInsert(java.util.Map<java.lang.String,java.lang.Object> properties) |
void |
purge()
Purges this document from the database;
this is more than deletion, it forgets entirely about it.
|
boolean |
putExistingRevision(java.util.Map<java.lang.String,java.lang.Object> properties,
java.util.Map<java.lang.String,java.lang.Object> attachments,
java.util.List<java.lang.String> revIDs,
java.net.URL sourceURL)
Adds an existing revision copied from another database.
|
SavedRevision |
putProperties(java.util.Map<java.lang.String,java.lang.Object> properties)
Saves a new revision.
|
protected SavedRevision |
putProperties(java.util.Map<java.lang.String,java.lang.Object> properties,
java.lang.String prevID,
boolean allowConflict) |
void |
removeChangeListener(Document.ChangeListener changeListener) |
protected void |
revisionAdded(DocumentChange change,
boolean notify)
Notification from the CBLDatabase that a (current, winning) revision has been added
|
void |
setExpirationDate(java.util.Date date) |
SavedRevision |
update(Document.DocumentUpdater updater)
Saves a new revision by letting the caller update the existing properties.
|
public static final java.lang.String TAG
public Document(Database database, java.lang.String documentId)
database - The document's owning databasedocumentId - The document's IDpublic Database getDatabase()
public java.lang.String getId()
public java.util.Date getExpirationDate()
public void setExpirationDate(java.util.Date date)
public void addChangeListener(Document.ChangeListener changeListener)
public void removeChangeListener(Document.ChangeListener changeListener)
public boolean isDeleted()
public java.lang.String getCurrentRevisionId()
public SavedRevision getCurrentRevision()
public java.util.List<SavedRevision> getRevisionHistory() throws CouchbaseLiteException
CouchbaseLiteExceptionpublic java.util.List<SavedRevision> getConflictingRevisions() throws CouchbaseLiteException
CouchbaseLiteExceptionpublic java.util.List<SavedRevision> getLeafRevisions() throws CouchbaseLiteException
CouchbaseLiteExceptionpublic java.util.Map<java.lang.String,java.lang.Object> getProperties()
public java.util.Map<java.lang.String,java.lang.Object> getUserProperties()
public boolean delete()
throws CouchbaseLiteException
CouchbaseLiteExceptionpublic void purge()
throws CouchbaseLiteException
CouchbaseLiteExceptionpublic SavedRevision getRevision(java.lang.String revID)
revID - the revision IDpublic UnsavedRevision createRevision()
public java.lang.Object getProperty(java.lang.String key)
public SavedRevision putProperties(java.util.Map<java.lang.String,java.lang.Object> properties) throws CouchbaseLiteException
properties - the contents to be saved in the new revisionCouchbaseLiteExceptionpublic SavedRevision update(Document.DocumentUpdater updater) throws CouchbaseLiteException
updater - the callback DocumentUpdater implementation. Will be called on each
attempt to save. Should update the given revision's properties and then
return YES, or just return NO to cancel.CouchbaseLiteExceptionpublic boolean putExistingRevision(java.util.Map<java.lang.String,java.lang.Object> properties,
java.util.Map<java.lang.String,java.lang.Object> attachments,
java.util.List<java.lang.String> revIDs,
java.net.URL sourceURL)
throws CouchbaseLiteException
properties - The properties of the revision (_id and _rev will be ignored, but _deleted
and _attachments are recognized.)attachments - A dictionary providing attachment bodies. The keys are the attachment
names (matching the keys in the properties' `_attachments` dictionary) and
the values are the attachment bodies as NSData or NSURL.revIDs - The revision history in the form of an array of revision-ID strings, in
reverse chronological order. The first item must be the new revision's ID.
Following items are its parent's ID, etc.sourceURL - The URL of the database this revision came from, if any. (This value shows
up in the CBLDatabaseChange triggered by this insertion, and can help clients
decide whether the change is local or not.)CouchbaseLiteException - Error information will be thrown if the insertion fails.public static boolean isValidDocumentId(java.lang.String id)
protected java.util.List<SavedRevision> getLeafRevisions(boolean includeDeleted) throws CouchbaseLiteException
CouchbaseLiteExceptionprotected java.util.Map<java.lang.String,java.lang.Object> propertiesToInsert(java.util.Map<java.lang.String,java.lang.Object> properties)
throws CouchbaseLiteException
CouchbaseLiteExceptionprotected SavedRevision putProperties(java.util.Map<java.lang.String,java.lang.Object> properties, java.lang.String prevID, boolean allowConflict) throws CouchbaseLiteException
CouchbaseLiteExceptionprotected SavedRevision getRevisionFromRev(RevisionInternal internalRevision)
protected void loadCurrentRevisionFrom(QueryRow row)
protected void revisionAdded(DocumentChange change, boolean notify)
protected void forgetCurrentRevision()