Class Document

  • All Implemented Interfaces:
    org.apache.jackrabbit.oak.cache.CacheValue
    Direct Known Subclasses:
    ClusterNodeInfoDocument, JournalEntry, NodeDocument

    public class Document
    extends Object
    implements org.apache.jackrabbit.oak.cache.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 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 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:
        Constant Field Values
      • 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:
        Constant Field Values
    • Constructor Detail

      • Document

        public Document()
    • 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 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()
        Specified by:
        getMemory in interface org.apache.jackrabbit.oak.cache.CacheValue
      • 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.