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
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 ABlob
read
(ByteBuffer bb) Reads a Blob from an Encoding in a ByteBuffer.static <T extends ABlob>
TreadFromBlob
(Blob source) static ABlob
toCanonical
(ABlob a) Converts any blob to a the 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
Converts any blob to a the correct canonical Blob format- Parameters:
a
- Any Blob- Returns:
- Canonical version s a Blob or BlobTree
-
fromHex
Creates a blob from a hex string- Parameters:
a
- Hex String- Returns:
- Blob created, or null if String not valid hex
-
parse
Best effort attempt to parse a Blob. Must parse as a Blob of correct length- Parameters:
o
- Object expected to contain a Blob value- Returns:
- ABlob value, or null if not parseable
-
parse
Best effort attempt to parse a Blob. Must parse as a Blob of correct length- Parameters:
s
- String expected to contain a HasBlobh value- Returns:
- ABlob value, or null if not parseable
-
read
Reads a Blob from an Encoding in a ByteBuffer.- Parameters:
bb
- ByteBuffer starting with a blob encoding- Returns:
- Blob read from ByteBuffer
- Throws:
BadFormatException
- If format is invalid
-
readFromBlob
- Throws:
BadFormatException
-
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:
- BlobTree filled with given value
-