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 the DocumentStore.
  • Field Details

    • 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 the DocumentStore 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

      public static final String MOD_COUNT
      The modification count on the document. This field is optional and a DocumentStore implementation may use it to keep track of how many times a document is modified. See also getModCount().
      See Also:
    • data

      protected Map<String,Object> data
      The data of this document.
  • Constructor Details

    • Document

      public Document()
  • Method Details

    • 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 given key.
      Parameters:
      key - the key.
      Returns:
      the data or null.
    • put

      @Nullable public @Nullable Object put(String key, Object value)
      Sets the data for the given key.
      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 given key.
      Parameters:
      key - the key.
      Returns:
      the previous value or null if there was none.
    • keySet

      public Set<String> keySet()
      Returns:
      a Set view of the keys contained in this document.
    • 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 an UnsupportedOperationException.
    • 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 interface CacheValue
      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 or null 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

      public String toString()
      Overrides:
      toString in class Object