Class Document

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.String,​java.lang.Object> data
      The data of this document.
      static java.lang.String ID
      The name of the field that contains the document id (the primary key / the key).
      static java.lang.String MOD_COUNT
      The modification count on the document.
    • 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.
      java.util.Set<java.util.Map.Entry<java.lang.String,​java.lang.Object>> entrySet()  
      java.lang.String format()
      Formats this document for use in a log message.
      @Nullable java.lang.Object get​(java.lang.String key)
      Gets the data for the given key.
      @Nullable java.lang.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 java.lang.Long getModCount()
      Get the modification count of this document.
      boolean isSealed()
      Determines if this document is sealed or not
      java.util.Set<java.lang.String> keySet()  
      @Nullable java.lang.Object put​(java.lang.String key, java.lang.Object value)
      Sets the data for the given key.
      @Nullable java.lang.Object remove​(java.lang.String key)
      Removes the given key.
      void seal()
      Seals this document and turns it into an immutable object.
      java.lang.String toString()  
      protected @NotNull java.util.Map<?,​?> transformAndSeal​(@NotNull java.util.Map<java.lang.Object,​java.lang.Object> map, @Nullable java.lang.String key, int level)
      Transform and seal the data of this document.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • ID

        public static final java.lang.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 java.lang.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
      • data

        protected java.util.Map<java.lang.String,​java.lang.Object> data
        The data of this document.
    • Constructor Detail

      • Document

        public Document()
    • Method Detail

      • getId

        @Nullable
        public @Nullable java.lang.String getId()
        Get the id (the primary key) of this document.
        Returns:
        the id or null if none is set.
      • getModCount

        @Nullable
        public @Nullable java.lang.Long getModCount()
        Get the modification count of this document.
        Returns:
        the count or null if none is set.
      • get

        @Nullable
        public @Nullable java.lang.Object get​(java.lang.String key)
        Gets the data for the given key.
        Parameters:
        key - the key.
        Returns:
        the data or null.
      • put

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

        public java.util.Set<java.lang.String> keySet()
        Returns:
        a Set view of the keys contained in this document.
      • entrySet

        public java.util.Set<java.util.Map.Entry<java.lang.String,​java.lang.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 java.lang.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 java.util.Map<?,​?> transformAndSeal​(@NotNull
                                                                     @NotNull java.util.Map<java.lang.Object,​java.lang.Object> map,
                                                                     @Nullable
                                                                     @Nullable java.lang.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object