Class AbstractBlob

  • All Implemented Interfaces:
    Blob
    Direct Known Subclasses:
    ArrayBasedBlob, StringBasedBlob

    public abstract class AbstractBlob
    extends java.lang.Object
    implements Blob
    Abstract base class for Blob implementations. This base class provides default implementations for hashCode and equals.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractBlob()  
      protected AbstractBlob​(org.apache.jackrabbit.guava.common.hash.HashCode hashCode)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static org.apache.jackrabbit.guava.common.hash.HashCode calculateSha256​(Blob blob)  
      static boolean equal​(Blob a, Blob b)  
      boolean equals​(java.lang.Object other)
      To Blob instances are considered equal iff they have the same SHA-256 hash code are equal.
      java.lang.String getContentIdentity()
      A unique identifier of the content of this value.
      @Nullable java.lang.String getReference()
      Returns a secure reference to this blob, or null if such a reference is not available.
      int hashCode()  
      protected byte[] sha256()
      This hash code implementation returns the hash code of the underlying stream
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AbstractBlob

        protected AbstractBlob​(org.apache.jackrabbit.guava.common.hash.HashCode hashCode)
      • AbstractBlob

        protected AbstractBlob()
    • Method Detail

      • equal

        public static boolean equal​(Blob a,
                                    Blob b)
      • calculateSha256

        public static org.apache.jackrabbit.guava.common.hash.HashCode calculateSha256​(Blob blob)
      • sha256

        protected byte[] sha256()
        This hash code implementation returns the hash code of the underlying stream
        Returns:
        a byte array of the hash
      • getReference

        @Nullable
        public @Nullable java.lang.String getReference()
        Description copied from interface: Blob
        Returns a secure reference to this blob, or null if such a reference is not available.
        Specified by:
        getReference in interface Blob
        Returns:
        binary reference, or null
        See Also:
        OAK-834
      • getContentIdentity

        public java.lang.String getContentIdentity()
        Description copied from interface: Blob
        A unique identifier of the content of this value. Usually this is a message digest of the content (a cryptographically secure one-way hash). This allows to avoid processing large binary values multiple times.

        This method returns null if the identifier is unknown. The identifier may not always be available, for example if the value has not yet been saved or processed. Once an identifier is available, it will never change because values are immutable.

        If two values have the same identifier, the content of the value is guaranteed to be the same. However it is not guaranteed that two values with the same content will return the same identifier.

        The identifier is opaque, meaning it can have any format and size.

        Specified by:
        getContentIdentity in interface Blob
        Returns:
        the unique identifier or null
      • equals

        public boolean equals​(java.lang.Object other)
        To Blob instances are considered equal iff they have the same SHA-256 hash code are equal.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        other -
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object