Package convex.core.data
Class ALongBlob
- All Implemented Interfaces:
IValidated
,IWriteable
,Comparable<ABlob>
-
Field Summary
FieldsFields inherited from class convex.core.data.ABlob
contentHash
Fields inherited from class convex.core.data.ACell
cachedRef, EMPTY_ARRAY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAppend an additional data object to this, creating a new data object.byte
byteAt(long i)
Gets the byte at the specified position in this blobprotected long
Calculates the Memory Size for this Cell.long
Computes the length of the longest common hex prefix between two blobslong
count()
Gets the length of this BlobCreates a new Ref for this Cellabstract boolean
Determines if this Blob is equal to another Blob.boolean
equalsBytes(ABlob b)
Tests if this Blob has exactly the same bytes as another BlobGets a byte buffer containing this Blob's data.getChunk(long i)
Gets a chunk of this Blob, as a canonical Blob up to the maximum chunk sizeint
Gets the number of Refs contained within this Cell.abstract byte
getTag()
Gets the tag byte for this cell.byte
getUnchecked(long i)
Gets the byte at the specified position in this data object, without bounds checking.long
hexMatchLength(ABlob b, long start, long length)
Returns the number of matching hex digits in the given hex range of another blob.boolean
Returns true if this Cell is in a canonical format for message writing.boolean
Returns true if this object represents a first class CVM Value.boolean
Determines if this Cell Represents an embedded object.long
Gets the long value of this Blob if the length is exactly 8 bytes, otherwise throws an Exceptionabstract ABlob
slice(long start, long length)
Gets a contiguous slice of this blob, as a new Blob.abstract Blob
toBlob()
Converts this object to a Blob instanceConverts this data object to a lowercase hex string representationvoid
toHexString(StringBuilder sb)
long
toLong()
Converts this Blob to the corresponding long value.int
writeToBuffer(byte[] bs, int pos)
Writes the raw byte contents of this blob to a byte arraywriteToBuffer(ByteBuffer bb)
Writes the raw byte contents of this blob to a ByteBuffer.Methods inherited from class convex.core.data.ABlob
compareTo, computeHash, empty, equals, equalsBytes, get, getBytes, getBytes, getContentHash, getElementRef, getHexDigit, getType, hashCode, hexEquals, hexEquals, hexLength, isRegularBlob, print, slice, toByteBuffer, toCanonical, toHexString, updateDigest, validate, validateCell
Methods inherited from class convex.core.data.ACountable
isEmpty, size
Methods inherited from class convex.core.data.ACell
announce, announce, attachMemorySize, attachRef, cachedEncoding, cachedHash, createAnnounced, createEncoding, createPersisted, createPersisted, encode, encodeRaw, equals, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getRef, getRef, toString, updateRefs, write
Methods inherited from class convex.core.data.AObject
attachEncoding, print
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface convex.core.data.IWriteable
estimatedEncodingSize
-
Field Details
-
LENGTH
protected static final long LENGTH- See Also:
- Constant Field Values
-
value
protected final long value
-
-
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 -
createRef
Description copied from class:ACell
Creates a new Ref for this Cell -
toHexString
Description copied from class:ABlob
Converts this data object to a lowercase hex string representation- Specified by:
toHexString
in classABlob
- Returns:
- Hex String representation
-
slice
Description copied from class:ABlob
Gets a contiguous slice of this blob, as a new Blob. Shares underlying backing data where possible -
toBlob
Description copied from class:ABlob
Converts this object to a Blob instance -
commonHexPrefixLength
Description copied from class:ABlob
Computes the length of the longest common hex prefix between two blobs- Specified by:
commonHexPrefixLength
in classABlob
- 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 in this blob -
getUnchecked
public final byte getUnchecked(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:
getUnchecked
in classABlob
- Parameters:
i
- Index of the byte to get- Returns:
- The byte at the specified position
-
append
Description copied from class:ABlob
Append an additional data object to this, creating a new data object. -
equals
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 -
writeToBuffer
Description copied from class:ABlob
Writes the raw byte contents of this blob to a ByteBuffer.- Specified by:
writeToBuffer
in classABlob
- Parameters:
bb
- ByteBuffer to write to- Returns:
- The passed ByteBuffer, after writing byte content
-
writeToBuffer
public final int writeToBuffer(byte[] bs, int pos)Description copied from class:ABlob
Writes the raw byte contents of this blob to a byte array- Specified by:
writeToBuffer
in classABlob
- Parameters:
bs
- Byte array to write topos
- Starting position in byte array to write to- Returns:
- The position in the array after writing
-
getChunk
Description copied from class:ABlob
Gets a chunk of this Blob, as a canonical Blob up to the maximum chunk size -
getByteBuffer
Description copied from class:ABlob
Gets a byte buffer containing this Blob's data. Will have remaining bytes equal to this Blob's size.- Specified by:
getByteBuffer
in classABlob
- 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 classACell
- Returns:
- Memory Size of this Cell
-
toHexString
- Specified by:
toHexString
in classABlob
-
hexMatchLength
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 classABlob
- Parameters:
b
- Blob to compare withstart
- Start position (in hex digits)length
- Length to compare (in hex digits)- Returns:
- The number of matching hex characters
-
toLong
public final long toLong()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 a signed big integer. Higher bytes outside the Long range will be ignored. -
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 -
equalsBytes
Description copied from class:ABlob
Tests if this Blob has exactly the same bytes as another Blob- Specified by:
equalsBytes
in classABlob
- 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 will be the first byte of the encoding -
isCanonical
public boolean isCanonical()Description copied from class:ACell
Returns true if this Cell is in a canonical format for message writing. Reading or writing a non-canonical value should be considered illegal, but non-canonical objects may be used on a temporary internal basis.- Specified by:
isCanonical
in classACell
- Returns:
- true if the object is in canonical format, false otherwise
-
isCVMValue
public 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- Specified by:
isCVMValue
in classACell
- Returns:
- true if the object is a CVM Value, 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. Contained Refs may be either external or embedded.- Specified by:
getRefCount
in classACell
- 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 classACell
- Returns:
- true if Cell is embedded, false otherwise
-