Package convex.core.data
Class BlobBuilder
java.lang.Object
convex.core.data.BlobBuilder
Similar to Java StringBuilder designed for concatenating multiple small Blobs to produce a larger
Blob.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ABlob
Accumulator Blob, always a canonical Blob with filled chunksprotected long
Total count of bytes in this BlobBuilderprotected byte[]
Accumulator array for up to a single chunk worth of bytes may be appended to, but never mutated below current position to allow safe wrapping in Blobs -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappend
(byte b) void
append
(byte[] bs) void
append
(byte[] bs, int offset, int length) append
(char c) Append a character to this Blob.Append a CVM character to this Blobvoid
void
append
(ByteBuffer bb) Appends remaining bytes from a ByteBuffer to this BlobBuilderboolean
check
(long limit) Checks if this BlobBuilder is less than or equal to the specified limitvoid
clear()
Clears this BlobBuilder, preparing for new appends to an empty Bloblong
count()
slice
(long start, long end) Takes a slice of the Blob currently under construction.toBlob()
-
Field Details
-
acc
Accumulator Blob, always a canonical Blob with filled chunks -
tail
protected byte[] tailAccumulator array for up to a single chunk worth of bytes may be appended to, but never mutated below current position to allow safe wrapping in Blobs -
count
protected long countTotal count of bytes in this BlobBuilder
-
-
Constructor Details
-
BlobBuilder
public BlobBuilder() -
BlobBuilder
-
-
Method Details
-
append
-
append
-
toBlob
-
slice
Takes a slice of the Blob currently under construction. May be more efficient than toBLob().slice(...).- Parameters:
start
- Start index of slicelength
- Length of slice- Returns:
- Slice of Blob under construction
-
getCVMString
-
count
public long count() -
append
-
append
-
append
public void append(byte[] bs) -
append
public void append(byte[] bs, int offset, int length) -
append
Append a character to this Blob. Converts to UTF=8- Parameters:
c
- Java character (UTF-16)- Returns:
- This BlobBuilder
-
append
Append a CVM character to this Blob- Parameters:
c
- CVM Character- Returns:
- This BlobBuilder
-
check
public boolean check(long limit) Checks if this BlobBuilder is less than or equal to the specified limit- Parameters:
limit
- Maximum allowable length of BlobBuilder- Returns:
- true if within limit, false if exceeded
-
append
Appends remaining bytes from a ByteBuffer to this BlobBuilder- Parameters:
bb
- ByteBuffer to append
-
clear
public void clear()Clears this BlobBuilder, preparing for new appends to an empty Blob
-