Class ALongBlob

All Implemented Interfaces:
IValidated, IWriteable, Comparable<ABlob>
Direct Known Subclasses:
Address, LongBlob

public abstract class ALongBlob extends ABlob
  • Field Details

  • Constructor Details

    • ALongBlob

      protected ALongBlob(long value)
  • Method Details

    • count

      public final long count()
      Description copied from class: ABlob
      Gets the length of this Blob
      Specified by:
      count in class ABlob
      Returns:
      The length in bytes of this data object
    • createRef

      protected <R extends ACell> Ref<R> createRef()
      Description copied from class: ACell
      Creates a new Ref for this Cell
      Overrides:
      createRef in class ACell
      Type Parameters:
      R - Type of Cell
      Returns:
      New Ref instance
    • appendHex

      public boolean appendHex(BlobBuilder bb, long length)
      Description copied from class: ABlob
      Append hex string up to the given length in hex digits (a multiple of two)
      Specified by:
      appendHex in class ABlob
      Parameters:
      bb - BlobBuilder instance to append to
      length - Length in Hex digits to append
      Returns:
      true if Blob fully appended, false if more more hex digits remain
    • getHexDigit

      public int getHexDigit(long i)
      Description copied from class: ABlob
      Gets the specified hex digit from this data object. WARNING: Result is undefined if index is out of bounds, but probably an IndexOutOfBoundsException.
      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
    • slice

      public abstract ABlob slice(long start, long end)
      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 ABlob
      Parameters:
      start - Start position for the created slice (inclusive)
      end - End of the slice (exclusive)
      Returns:
      A blob of the specified length, representing a slice of this blob.
    • toFlatBlob

      public abstract Blob toFlatBlob()
      Description copied from class: ABlob
      Converts this object to a flat array-backed Blob instance. Warning: might be O(n) in size of Blob, may not be canonical etc.
      Specified by:
      toFlatBlob in class ABlob
      Returns:
      A Blob instance containing the same data as this Blob.
    • commonHexPrefixLength

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

      public final byte byteAt(long i)
      Description copied from class: ABlob
      Gets the byte at the specified position
      Overrides:
      byteAt in class ABlob
      Parameters:
      i - Index of the byte to get
      Returns:
      The byte at the specified position
    • byteAtUnchecked

      public final byte byteAtUnchecked(long i)
      Description copied from class: ABlob
      Gets the byte at the specified position in this data object, without bounds checking. Only safe if index is known to be in bounds, otherwise result is undefined.
      Specified by:
      byteAtUnchecked in class ABlob
      Parameters:
      i - Index of the byte to get
      Returns:
      The byte at the specified position
    • append

      public final ABlob append(ABlob d)
      Description copied from class: ABlob
      Append an additional Blob to this, creating a new Blob as needed. New Blob will be canonical.
      Specified by:
      append in class ABlob
      Parameters:
      d - Blob to append
      Returns:
      A new Blob, containing the additional data appended to this blob.
    • equals

      public abstract boolean equals(ABlob o)
      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 ABlob
      Parameters:
      o - Blob to compare with
      Returns:
      true if Blobs are equal, false otherwise
    • getBytes

      public final int getBytes(byte[] bs, int pos)
      Description copied from class: ABlobLike
      Copies the bytes from this instance to a given destination
      Specified by:
      getBytes in class ABlobLike<CVMLong>
      Parameters:
      bs - Destination array
      pos - Offset into destination array
      Returns:
      End position in destination array after writing
    • getChunk

      public final Blob getChunk(long i)
      Description copied from class: ABlob
      Gets a chunk of this Blob, as a canonical Blob up to the maximum chunk size. Returns empty Blob if and only if referencing the end of a Blob with fully packed chunks
      Specified by:
      getChunk in class ABlob
      Parameters:
      i - Index of chunk
      Returns:
      A Blob containing the specified chunk data.
    • getByteBuffer

      public final ByteBuffer getByteBuffer()
      Description copied from class: ABlob
      Gets a byte buffer containing this Blob's raw data. Will have remaining bytes equal to this Blob's size.
      Specified by:
      getByteBuffer in class ABlob
      Returns:
      A ByteBuffer containing the Blob's data.
    • calcMemorySize

      protected final long calcMemorySize()
      Description copied from class: ACell
      Calculates the Memory Size for this Cell. Requires any child Refs to be either Direct or of persisted status at minimum, or you might get a MissingDataException
      Overrides:
      calcMemorySize in class ACell
      Returns:
      Memory Size of this Cell
    • 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.
      Specified by:
      hexMatchLength in class ABlob
      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
    • longValue

      public final long longValue()
      Description copied from class: ABlob
      Converts this Blob to the corresponding long value. Assumes big-endian format, as if the entire blob is interpreted as an unsigned big integer. Higher bytes outside the Long range will be ignored, i.e. the lowest 64 bits are taken
      Specified by:
      longValue in class ABlob
      Returns:
      long value of this blob
    • toExactLong

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

      public int compareTo(ABlob b)
      Description copied from class: ABlob
      Compares this Blob to another Blob, in lexicographic order sorting by first bytes (unsigned). Note: This means that compareTo does not precisely match equality, because specialised Blob types may be lexicographically equal but represent different values.
      Specified by:
      compareTo in interface Comparable<ABlob>
      Overrides:
      compareTo in class ABlob
    • compareTo

      protected int compareTo(long bvalue)
    • equalsBytes

      public final boolean equalsBytes(ABlob b)
      Description copied from class: ABlob
      Tests if this Blob has exactly the same bytes as another Blob
      Specified by:
      equalsBytes in class ABlob
      Parameters:
      b - Blob to compare with
      Returns:
      True if byte content is exactly equal, false otherwise
    • getTag

      public abstract byte getTag()
      Description copied from class: ACell
      Gets the tag byte for this cell. The tag byte is always equal to the first byte of the Cell's canonical Encoding, and is sufficient to distinguish how to read the rest of the encoding.
      Specified by:
      getTag in class ACell
      Returns:
      Tag byte for this Cell
    • 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).
      Specified by:
      isCanonical in class ACell
      Returns:
      true if the object is in canonical format, false otherwise
    • getRefCount

      public final int getRefCount()
      Description copied from class: ACell
      Gets the number of Refs contained within this Cell. This number is final / immutable for any given instance and is defined by the Cell encoding rules. WARNING: may not be valid id Cell is not canonical Contained Refs may be either external or embedded.
      Specified by:
      getRefCount in class ACell
      Returns:
      The number of Refs in this Cell
    • isEmbedded

      public final boolean isEmbedded()
      Description copied from class: ACell
      Determines if this Cell Represents an embedded object. Embedded objects are encoded directly into the encoding of the containing Cell (avoiding the need for a hashed reference). Subclasses should override this if they have a cheap O(1) way to determine if they are embedded or otherwise.
      Overrides:
      isEmbedded in class ACell
      Returns:
      true if Cell is embedded, false otherwise