Class Document
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.document.Document
-
- All Implemented Interfaces:
CacheValue
- Direct Known Subclasses:
ClusterNodeInfoDocument
,JournalEntry
,NodeDocument
public class Document extends Object implements CacheValue
A document corresponds to a node stored in the DocumentNodeStore. A document contains all the revisions of a node stored in theDocumentStore
.
-
-
Constructor Summary
Constructors Constructor Description Document()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deepCopy(Document target)
Performs a deep copy of the data within this document to the given target.Set<Map.Entry<String,Object>>
entrySet()
String
format()
Formats this document for use in a log message.@Nullable Object
get(String key)
Gets the data for the givenkey
.@Nullable String
getId()
Get the id (the primary key) of this document.int
getMemory()
The estimated amount of memory used by this object, in bytes.@Nullable Long
getModCount()
Get the modification count of this document.boolean
isSealed()
Determines if this document is sealed or notSet<String>
keySet()
@Nullable Object
put(String key, Object value)
Sets the data for the givenkey
.@Nullable Object
remove(String key)
Removes the givenkey
.void
seal()
Seals this document and turns it into an immutable object.String
toString()
protected @NotNull Map<?,?>
transformAndSeal(@NotNull Map<Object,Object> map, @Nullable String key, int level)
Transform and seal the data of this document.
-
-
-
Field Detail
-
ID
public static final String 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:
- Constant Field Values
-
MOD_COUNT
public static final String 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:
- Constant Field Values
-
-
Method Detail
-
getId
@Nullable public @Nullable String getId()
Get the id (the primary key) of this document.- Returns:
- the id or
null
if none is set.
-
getModCount
@Nullable public @Nullable Long getModCount()
Get the modification count of this document.- Returns:
- the count or
null
if none is set.
-
get
@Nullable public @Nullable Object get(String key)
Gets the data for the givenkey
.- Parameters:
key
- the key.- Returns:
- the data or
null
.
-
put
@Nullable public @Nullable Object put(String key, Object value)
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
@Nullable public @Nullable Object remove(String key)
Removes the givenkey
.- Parameters:
key
- the key.- Returns:
- the previous value or
null
if there was none.
-
entrySet
public Set<Map.Entry<String,Object>> 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
public void deepCopy(Document target)
Performs a deep copy of the data within this document to the given target.- Parameters:
target
- the target document.
-
format
public String 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.
-
-