Class Document
java.lang.Object
org.apache.jackrabbit.oak.plugins.document.Document
- All Implemented Interfaces:
CacheValue
- Direct Known Subclasses:
ClusterNodeInfoDocument
,JournalEntry
,NodeDocument
A document corresponds to a node stored in the DocumentNodeStore. A document
contains all the revisions of a node stored in the
DocumentStore
.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Performs a deep copy of the data within this document to the given target.entrySet()
format()
Formats this document for use in a log message.@Nullable Object
Gets the data for the givenkey
.@Nullable String
getId()
Get the id (the primary key) of this document.int
The estimated amount of memory used by this object, in bytes.@Nullable Long
Get the modification count of this document.boolean
isSealed()
Determines if this document is sealed or notkeySet()
@Nullable Object
Sets the data for the givenkey
.@Nullable Object
Removes the givenkey
.void
seal()
Seals this document and turns it into an immutable object.toString()
protected @NotNull Map<?,
?> transformAndSeal
(@NotNull Map<Object, Object> map, @Nullable String key, int level) Transform and seal the data of this document.
-
Field Details
-
ID
The name of the field that contains the document id (the primary key / the key). The id uniquely identifies a document within a collection. The requirements and limits of the id are documented in theDocumentStore
class. For nodes, the document id contains the depth of the path (0 for root, 1 for children of the root), and then the path.- See Also:
-
MOD_COUNT
The modification count on the document. This field is optional and aDocumentStore
implementation may use it to keep track of how many times a document is modified. See alsogetModCount()
.- See Also:
-
data
The data of this document.
-
-
Constructor Details
-
Document
public Document()
-
-
Method Details
-
getId
Get the id (the primary key) of this document.- Returns:
- the id or
null
if none is set.
-
getModCount
Get the modification count of this document.- Returns:
- the count or
null
if none is set.
-
get
Gets the data for the givenkey
.- Parameters:
key
- the key.- Returns:
- the data or
null
.
-
put
Sets the data for the givenkey
.- Parameters:
key
- the key.value
- the value to set.- Returns:
- the previous value or
null
if there was none.
-
remove
Removes the givenkey
.- Parameters:
key
- the key.- Returns:
- the previous value or
null
if there was none.
-
keySet
- Returns:
- a Set view of the keys contained in this document.
-
entrySet
- Returns:
- a Set view of the entries contained in this document.
-
seal
public void seal()Seals this document and turns it into an immutable object. Any attempt to modify this document afterwards will result in anUnsupportedOperationException
. -
isSealed
public boolean isSealed()Determines if this document is sealed or not- Returns:
- true if document is sealed.
-
deepCopy
Performs a deep copy of the data within this document to the given target.- Parameters:
target
- the target document.
-
format
Formats this document for use in a log message.- Returns:
- the formatted string
-
getMemory
public int getMemory()Description copied from interface:CacheValue
The estimated amount of memory used by this object, in bytes.- Specified by:
getMemory
in interfaceCacheValue
- Returns:
- the estimated number of bytes
-
transformAndSeal
@NotNull protected @NotNull Map<?,?> transformAndSeal(@NotNull @NotNull Map<Object, Object> map, @Nullable @Nullable String key, int level) Transform and seal the data of this document. That is, the data becomes immutable and transformation may be performed on the data.- Parameters:
map
- the map to transform.key
- the key for the given map ornull
if the map is the top level data map.level
- the level. Zero for the top level map, one for an entry in the top level map, etc.- Returns:
- the transformed and sealed map.
-
toString
-