Class LongBlob

All Implemented Interfaces:
IValidated, IWriteable, Comparable<ABlob>

public final class LongBlob extends ALongBlob
Wrapper for an 8-byte long blob We use this for efficient management of indexes using longs in BlobMaps.
  • Field Details

  • Method Details

    • create

      public static LongBlob create(String string)
    • create

      public static LongBlob create(long value)
    • isCVMValue

      public final boolean isCVMValue()
      Description copied from class: ACell
      Returns true if this object represents a first class CVM Value. Sub-structural cells that are not themselves first class values should return false. CVM values might not be in a canonical format, e.g. temporary data structures
      Overrides:
      isCVMValue in class ALongBlob
      Returns:
      true if the object is a CVM Value, false otherwise
    • getBytes

      public void getBytes(byte[] dest, int destOffset)
      Description copied from class: ABlob
      Copies the bytes from this blob to a given destination
      Specified by:
      getBytes in class ABlob
      Parameters:
      dest - Destination array
      destOffset - Offset into destination array
    • slice

      public ABlob slice(long start, long length)
      Description copied from class: ABlob
      Gets a contiguous slice of this blob, as a new Blob. Shares underlying backing data where possible
      Specified by:
      slice in class ALongBlob
      Parameters:
      start - Start position for the created slice
      length - Length of the slice
      Returns:
      A blob of the specified length, representing a slice of this blob.
    • toBlob

      public Blob toBlob()
      Description copied from class: ABlob
      Converts this object to a Blob instance
      Specified by:
      toBlob in class ALongBlob
      Returns:
      A Blob instance containing the same data as this Blob.
    • updateDigest

      protected void updateDigest(MessageDigest digest)
      Specified by:
      updateDigest in class ABlob
    • getHexDigit

      public int getHexDigit(long i)
      Description copied from class: ABlob
      Gets the specified hex digit from this data object. Result is undefined if index is out of bounds.
      Overrides:
      getHexDigit in class ABlob
      Parameters:
      i - The position of the hex digit
      Returns:
      The value of the hex digit, in the range 0-15 inclusive
    • commonHexPrefixLength

      public long commonHexPrefixLength(ABlob b)
      Description copied from class: ABlob
      Computes the length of the longest common hex prefix between two blobs
      Overrides:
      commonHexPrefixLength in class ALongBlob
      Parameters:
      b - Blob to compare with
      Returns:
      The length of the longest common prefix in hex digits
    • equals

      public boolean equals(ABlob a)
      Description copied from class: ABlob
      Determines if this Blob is equal to another Blob. Blobs are defined to be equal if they have the same on-chain representation, i.e. if and only if all of the following are true: - Blob is of the same general type - Blobs are of the same length - All byte values are equal
      Specified by:
      equals in class ALongBlob
      Parameters:
      a - Blob to compare with
      Returns:
      true if Blobs are equal, false otherwise
    • encode

      public int encode(byte[] bs, int pos)
      Description copied from class: ACell
      Writes this Cell's encoding to a byte array, including a tag byte which will be written first
      Specified by:
      encode in interface IWriteable
      Specified by:
      encode in class ACell
      Parameters:
      bs - A byte array to which to write the encoding
      pos - The offset into the byte array
      Returns:
      New position after writing
    • encodeRaw

      public int encodeRaw(byte[] bs, int pos)
      Description copied from class: ACell
      Writes this Cell's encoding to a byte array, excluding the tag byte
      Specified by:
      encodeRaw in class ACell
      Parameters:
      bs - A byte array to which to write the encoding
      pos - The offset into the byte array
      Returns:
      New position after writing
    • estimatedEncodingSize

      public int estimatedEncodingSize()
      Description copied from interface: IWriteable
      Estimate the encoded data size for this Cell. Used for quickly sizing buffers. Implementations should try to return a size that is likely to contain the entire object when represented in binary format, including the tag byte.
      Returns:
      The estimated size for the binary representation of this object.
    • longValue

      public long longValue()
      Description copied from class: ABlob
      Gets the long value of this Blob if the length is exactly 8 bytes, otherwise throws an Exception
      Overrides:
      longValue in class ALongBlob
      Returns:
      The long value represented by the Blob
    • hexMatchLength

      public long hexMatchLength(ABlob b, long start, long length)
      Description copied from class: ABlob
      Returns the number of matching hex digits in the given hex range of another blob. Assumes range is valid for both blobs. Returns length if this Blob is exactly equal to the specified hex range.
      Overrides:
      hexMatchLength in class ALongBlob
      Parameters:
      b - Blob to compare with
      start - Start position (in hex digits)
      length - Length to compare (in hex digits)
      Returns:
      The number of matching hex characters
    • isRegularBlob

      public boolean isRegularBlob()
      Description copied from class: ABlob
      Returns true if this object is a regular blob (i.e. not a special blob type like Address)
      Overrides:
      isRegularBlob in class ABlob
      Returns:
      True if a regular blob
    • getTag

      public byte getTag()
      Description copied from class: ACell
      Gets the tag byte for this cell. The tag byte is always written as the first byte of the Cell's Encoding
      Specified by:
      getTag in class ALongBlob
      Returns:
      Tag byte for this Cell
    • equalsBytes

      public boolean equalsBytes(byte[] bytes, int byteOffset)
      Description copied from class: ABlob
      Tests if this Blob is equal to a subset of a byte array
      Specified by:
      equalsBytes in class ABlob
      Parameters:
      bytes - Byte array to compare with
      byteOffset - Offset into byte array
      Returns:
      true if exactly equal, false otherwise
    • isCanonical

      public boolean isCanonical()
      Description copied from class: ACell
      Returns true if this Cell is in a canonical representation for message writing. Non-canonical objects may be used on a temporary internal basis, they must always be converted to canonical representations for external use (e.g. Encoding).
      Overrides:
      isCanonical in class ALongBlob
      Returns:
      true if the object is in canonical format, false otherwise
    • toCanonical

      public Blob toCanonical()
      Description copied from class: ACell
      Converts this Cell to its canonical version. Returns this Cell if already canonical.
      Specified by:
      toCanonical in class ABlob
      Returns:
      Canonical version of Cell