Package convex.core.data
Class Blobs
java.lang.Object
convex.core.data.Blobs
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ABlob
createFilled
(int value, long length) Create a Blob entirely filled with a given valuestatic <T extends ABlob>
TcreateRandom
(long length) static <T extends ABlob>
TcreateRandom
(Random r, long length) static ABlob
createZero
(long length) Create a Blob entirely filled with zerosstatic Blob
empty()
static byte[]
Gets a zero-based array containing the contents of the given Blob.static ABlob
Creates a blob from a hex stringstatic ABlob
Creates a blob from a hex stringstatic ABlob
Best effort attempt to parse a Blob.static ABlob
Best effort attempt to parse a Blob.static <T extends ABlob>
TReads a canonical Blob from a Blob sourcestatic ABlob
toCanonical
(ABlob a) Converts any blob to a correct canonical Blob format
-
Field Details
-
MAX_ENCODING_LENGTH
public static final int MAX_ENCODING_LENGTH
-
-
Constructor Details
-
Blobs
public Blobs()
-
-
Method Details
-
createRandom
-
createRandom
-
toCanonical
-
fromHex
-
fromHex
-
parse
-
parse
-
read
Reads a canonical Blob from a Blob source- Type Parameters:
T
- Type of Blob result- Parameters:
source
- Source blob, containing tagpos
- position to read from source, assumed to be tag- Returns:
- Canonical Blob
- Throws:
BadFormatException
- if the Blob encoding format is invalid
-
createFilled
Create a Blob entirely filled with a given value- Parameters:
value
- Byte value to fill with (low 8 bits used)length
- Length of Blob to create- Returns:
- Blob filled with given value
-
createZero
Create a Blob entirely filled with zeros- Parameters:
length
- Length of Blob to create- Returns:
- Blob filled with zeros
-
empty
-
ensureZeroBasedArray
Gets a zero-based array containing the contents of the given Blob. MAY use current internal array if possible. WARNING: may return underlying array, should never be mutated- Parameters:
b
- Blob to get array for- Returns:
- byte array containing the blob contents starting at offset zero
-