Package com.couchbase.lite
Class Document
java.lang.Object
com.couchbase.lite.Document
- All Implemented Interfaces:
 DictionaryInterface,Iterable<String>
- Direct Known Subclasses:
 MutableDocument
Readonly version of the Document.
- 
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDocument(Collection collection, String id, com.couchbase.lite.internal.core.C4Document c4doc, boolean mutable)  - 
Method Summary
Modifier and TypeMethodDescriptionbooleanTests whether a property exists or not.intcount()Gets the number of the entries in the document.booleanGet a property's value as an Array.Gets a property's value as a Blob.booleangetBoolean(String key) Gets a property's value as a boolean.return the collection to which the document belongs.protected final DictionaryGets a property's value as a Date.getDictionary(String key) Get a property's value as a Dictionary.doubleGets a property's value as a double.floatGets a property's value as a float.getId()return the document's ID.intGets a property's value as an int.getKeys()Get a List containing all keys, or an empty List if the document has no properties.longGets a property's value as a long.Gets a property's value as a Number.Get the document's revision id.longReturn the sequence number of the document in the database.Gets a property's value as a String.longGet the document's timestamp.Gets a property's value as an object.inthashCode()iterator()Gets an iterator over the keys of the document's propertiesprotected final voidsetContent(Dictionary content) toJSON()toMap()Gets content of the current object as a Map.Return a mutable copy of the documenttoString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator 
- 
Constructor Details
- 
Document
protected Document(@Nullable Collection collection, @NonNull String id, @Nullable com.couchbase.lite.internal.core.C4Document c4doc, boolean mutable)  
 - 
 - 
Method Details
- 
getCollection
return the collection to which the document belongs.- Returns:
 - the document's collection
 
 - 
getId
return the document's ID.- Returns:
 - the document's ID
 
 - 
getRevisionID
Get the document's revision id. The revision id in the Document class is a constant while the revision id in the MutableDocument class is not. A newly created Document will have a null revision id. The revision id in a MutableDocument will be updated on save. The revision id format is opaque, which means its format has no meaning and shouldn't be parsed to get information.- Returns:
 - the document's revision id
 
 - 
getTimestamp
@Volatile public long getTimestamp()Get the document's timestamp. The values returned by this method are, actually, just the document's generation number. This is a increasing number but not, until future releases, an actual timestamp.- Returns:
 - the document's timestamp
 
 - 
getSequence
public long getSequence()Return the sequence number of the document in the database. The sequence number indicates how recently the document has been changed. Every time a document is updated, the database assigns it the next sequential sequence number. Thus, when a document's sequence number changes it means that the document been updated (on-disk). If one document's sequence is different from another's, the document with the larger sequence number was changed more recently. Sequence numbers are not available for documents obtained from a replication filter. This method will always return 0 for such documents.- Returns:
 - the sequence number of the document in the database.
 
 - 
toMutable
Return a mutable copy of the document- Returns:
 - the MutableDocument instance
 
 - 
count
public int count()Gets the number of the entries in the document.- Specified by:
 countin interfaceDictionaryInterface- Returns:
 - the number of entries in the document.
 
 - 
getKeys
Get a List containing all keys, or an empty List if the document has no properties.- Specified by:
 getKeysin interfaceDictionaryInterface- Returns:
 - all keys
 
 - 
getValue
Gets a property's value as an object. The object types are Blob, Array, Dictionary, Number, or String based on the underlying data type; or nil if the property value is null or the property doesn't exist.- Specified by:
 getValuein interfaceDictionaryInterface- Parameters:
 key- the key.- Returns:
 - the object value or null.
 
 - 
getString
Gets a property's value as a String. Returns null if the value doesn't exist, or its value is not a String.- Specified by:
 getStringin interfaceDictionaryInterface- Parameters:
 key- the key- Returns:
 - the String or null.
 
 - 
getNumber
Gets a property's value as a Number. Returns null if the value doesn't exist, or its value is not a Number.- Specified by:
 getNumberin interfaceDictionaryInterface- Parameters:
 key- the key- Returns:
 - the Number or nil.
 
 - 
getInt
Gets a property's value as an int. Floating point values will be rounded. The value `true` is returned as 1, `false` as 0. Returns 0 if the value doesn't exist or does not have a numeric value.- Specified by:
 getIntin interfaceDictionaryInterface- Parameters:
 key- the key- Returns:
 - the int value.
 
 - 
getLong
Gets a property's value as a long. Floating point values will be rounded. The value `true` is returned as 1, `false` as 0. Returns 0 if the value doesn't exist or does not have a numeric value.- Specified by:
 getLongin interfaceDictionaryInterface- Parameters:
 key- the key- Returns:
 - the long value.
 
 - 
getFloat
Gets a property's value as a float. Integers will be converted to float. The value `true` is returned as 1.0, `false` as 0.0. Returns 0.0 if the value doesn't exist or does not have a numeric value.- Specified by:
 getFloatin interfaceDictionaryInterface- Parameters:
 key- the key- Returns:
 - the float value.
 
 - 
getDouble
Gets a property's value as a double. Integers will be converted to double. The value `true` is returned as 1.0, `false` as 0.0. Returns 0.0 if the property doesn't exist or does not have a numeric value.- Specified by:
 getDoublein interfaceDictionaryInterface- Parameters:
 key- the key- Returns:
 - the double value.
 
 - 
getBoolean
Gets a property's value as a boolean. Returns true if the value exists, and is either `true` or a nonzero number.- Specified by:
 getBooleanin interfaceDictionaryInterface- Parameters:
 key- the key- Returns:
 - the boolean value.
 
 - 
getBlob
Gets a property's value as a Blob. Returns null if the value doesn't exist, or its value is not a Blob.- Specified by:
 getBlobin interfaceDictionaryInterface- Parameters:
 key- the key- Returns:
 - the Blob value or null.
 
 - 
getDate
Gets a property's value as a Date. JSON does not directly support dates, so the actual property value must be a string, which is then parsed according to the ISO-8601 date format (the default used in JSON.) Returns null if the value doesn't exist, is not a string, or is not parsable as a date. NOTE: This is not a generic date parser! It only recognizes the ISO-8601 format, with or without milliseconds.- Specified by:
 getDatein interfaceDictionaryInterface- Parameters:
 key- the key- Returns:
 - the Date value or null.
 
 - 
getArray
Get a property's value as an Array. Returns null if the property doesn't exist, or its value is not an Array.- Specified by:
 getArrayin interfaceDictionaryInterface- Parameters:
 key- the key- Returns:
 - The Array object or null.
 
 - 
getDictionary
Get a property's value as a Dictionary. Returns null if the property doesn't exist, or its value is not a Dictionary.- Specified by:
 getDictionaryin interfaceDictionaryInterface- Parameters:
 key- the key- Returns:
 - The Dictionary object or null.
 
 - 
toMap
Gets content of the current object as a Map. The values contained in the returned Map object are all JSON based values.- Specified by:
 toMapin interfaceDictionaryInterface- Returns:
 - the Map object representing the content of the current object in the JSON format.
 
 - 
toJSON
- Specified by:
 toJSONin interfaceDictionaryInterface
 - 
contains
Tests whether a property exists or not. This can be less expensive than getValue(String), because it does not have to allocate an Object for the property value.- Specified by:
 containsin interfaceDictionaryInterface- Parameters:
 key- the key- Returns:
 - the boolean value representing whether a property exists or not.
 
 - 
getRevisionHistory
@Internal("This method is not part of the public API") @Nullable public String getRevisionHistory() throws CouchbaseLiteException- Throws:
 CouchbaseLiteException
 - 
iterator
Gets an iterator over the keys of the document's properties - 
equals
 - 
hashCode
public int hashCode() - 
toString
 - 
getContent
 - 
setContent
 
 -