public class ByteArrayPrimitiveBuilder extends BuilderBase
ALLOCATION_BOUNDARY, allocationSize, DEFAULT_ASCII_ALLOCATION, DEFAULT_OTHER_ALLOCATION, defaultCharset, NULL| Constructor and Description |
|---|
ByteArrayPrimitiveBuilder()
Construct the ByteArrayPrimitiveBuilder with
the initial size and allocation size of
and the character set
StandardCharsets.US_ASCII |
ByteArrayPrimitiveBuilder(byte[] bytes)
Construct the ByteArrayPrimitiveBuilder copying all the bytes
using the character set
StandardCharsets.US_ASCII
Then initializes the buffer with the supplied bytes |
ByteArrayPrimitiveBuilder(byte[] bytes,
int len)
Construct the ByteArrayPrimitiveBuilder copying the specified number of bytes;
and the character set
StandardCharsets.US_ASCII
Then initializes the buffer with the supplied bytes |
ByteArrayPrimitiveBuilder(java.nio.charset.Charset defaultCharset)
Construct the ByteArrayPrimitiveBuilder with the supplied character set
with the default initial size and allocation size determined by that character set
|
ByteArrayPrimitiveBuilder(int initialSize)
Construct the ByteArrayPrimitiveBuilder with the supplied initial size,
allocation size of
and the character set
StandardCharsets.US_ASCII |
ByteArrayPrimitiveBuilder(int initialSize,
java.nio.charset.Charset defaultCharset)
Construct the ByteArrayPrimitiveBuilder with the supplied initial size and character set
with the allocation size determined by that character set.
|
ByteArrayPrimitiveBuilder(int initialSize,
int allocationSizeSuggestion,
java.nio.charset.Charset defaultCharset)
Construct the ByteArrayPrimitiveBuilder with the supplied initial size,
allocation size and character set
|
| Modifier and Type | Method and Description |
|---|---|
ByteArrayPrimitiveBuilder |
append(byte b)
Append a byte as is
|
ByteArrayPrimitiveBuilder |
append(byte[] src)
Append an entire byte array
|
ByteArrayPrimitiveBuilder |
append(byte[] src,
int len)
Append len bytes from the start of byte array
|
ByteArrayPrimitiveBuilder |
append(byte[] src,
int index,
int len)
Append a byte array
|
ByteArrayPrimitiveBuilder |
append(ByteArrayPrimitiveBuilder bab)
Appends the data bytes from an existing byte array primitive builder
|
ByteArrayPrimitiveBuilder |
append(java.nio.CharBuffer src)
Append a CharBuffer with default charset.
|
ByteArrayPrimitiveBuilder |
append(java.nio.CharBuffer src,
java.nio.charset.Charset charset)
Append a CharBuffer with specified charset.
|
ByteArrayPrimitiveBuilder |
append(int i)
Append a String representation of the number.
|
ByteArrayPrimitiveBuilder |
append(java.lang.String src)
Append a String with the default charset.
|
ByteArrayPrimitiveBuilder |
append(java.lang.String src,
java.nio.charset.Charset charset)
Append a String with specified charset.
|
int |
appendUnchecked(byte b)
Append a single byte without checking that the builder has the capacity
|
int |
appendUnchecked(byte[] src)
Append the entire byte array without checking that the builder has the capacity
|
int |
appendUnchecked(byte[] src,
int srcPos,
int len)
Append the entire byte array without checking that the builder has the capacity
|
int |
capacity()
Get the number of bytes currently allocated (available) without resizing
|
ByteArrayPrimitiveBuilder |
clear()
Clear the buffer, resetting its length but not capacity
|
int |
copyTo(byte[] dest,
int destPos)
Copy the contents of the buffer to the byte array starting at the destination
positions supplied.
|
void |
copyTo(java.io.OutputStream out)
Copy the contents of the buffer to the output stream
|
void |
ensureCapacity(int bytesNeeded)
Ensures that the buffer can accept the number of bytes needed by resizing if necessary.
|
boolean |
equals(byte[] bytes)
Determine if a byte array contains the same bytes as this builder
|
byte[] |
internalArray()
Access the internal byte array of this buffer.
|
int |
length()
Get the length of the data in the buffer
|
void |
setAllocationSize(int allocationSizeSuggestion)
Change the allocation size
|
byte[] |
toByteArray()
Copy the value in the buffer to a new byte array
|
java.lang.String |
toString() |
_setAllocationSize, bufferAllocSize, getAllocationSizepublic ByteArrayPrimitiveBuilder(int initialSize,
int allocationSizeSuggestion,
java.nio.charset.Charset defaultCharset)
initialSize - the initial sizeallocationSizeSuggestion - the allocationSize size suggestiondefaultCharset - the default character setpublic ByteArrayPrimitiveBuilder()
StandardCharsets.US_ASCIIpublic ByteArrayPrimitiveBuilder(int initialSize)
StandardCharsets.US_ASCIIinitialSize - the initial sizepublic ByteArrayPrimitiveBuilder(java.nio.charset.Charset defaultCharset)
defaultCharset - the default character setpublic ByteArrayPrimitiveBuilder(int initialSize,
java.nio.charset.Charset defaultCharset)
initialSize - the initial sizedefaultCharset - the default character setpublic ByteArrayPrimitiveBuilder(byte[] bytes)
StandardCharsets.US_ASCII
Then initializes the buffer with the supplied bytesbytes - the bytespublic ByteArrayPrimitiveBuilder(byte[] bytes,
int len)
StandardCharsets.US_ASCII
Then initializes the buffer with the supplied bytesbytes - the byteslen - the number of bytes to copypublic int length()
length in class BuilderBasepublic int capacity()
capacity in class BuilderBasepublic boolean equals(byte[] bytes)
equals in class BuilderBasebytes - the bytespublic int copyTo(byte[] dest,
int destPos)
position method has been called
and the destination byte array has enough space allocateddest - the destination byte arraydestPos - the starting position in the destination byte arraypublic void copyTo(java.io.OutputStream out)
throws java.io.IOException
out - the output streamjava.io.IOException - if an I/O error occurspublic byte[] toByteArray()
toByteArray in class BuilderBasepublic byte[] internalArray()
length()internalArray in class BuilderBasepublic void ensureCapacity(int bytesNeeded)
bytesNeeded - the number of bytes neededpublic ByteArrayPrimitiveBuilder clear()
public void setAllocationSize(int allocationSizeSuggestion)
allocationSizeSuggestion - the new allocation size suggestionpublic ByteArrayPrimitiveBuilder append(int i)
i - the numberpublic ByteArrayPrimitiveBuilder append(java.lang.String src)
src - The String from which bytes are to be readpublic ByteArrayPrimitiveBuilder append(java.lang.String src, java.nio.charset.Charset charset)
src - The String from which bytes are to be readcharset - the charset for encodingpublic ByteArrayPrimitiveBuilder append(java.nio.CharBuffer src)
src - The CharBuffer from which bytes are to be readpublic ByteArrayPrimitiveBuilder append(java.nio.CharBuffer src, java.nio.charset.Charset charset)
src - The CharBuffer from which bytes are to be readcharset - the charset for encodingpublic ByteArrayPrimitiveBuilder append(byte b)
b - the bytepublic ByteArrayPrimitiveBuilder append(byte[] src)
src - The array from which bytes are to be readpublic ByteArrayPrimitiveBuilder append(byte[] src, int len)
src - The array from which bytes are to be readlen - The number of bytes to be read from the given arraypublic ByteArrayPrimitiveBuilder append(byte[] src, int index, int len)
src - The array from which bytes are to be readindex - The index in the array of the first byte to be read;len - The number of bytes to be read from the given array;public ByteArrayPrimitiveBuilder append(ByteArrayPrimitiveBuilder bab)
bab - an existing builderpublic int appendUnchecked(byte b)
appendUnchecked in class BuilderBaseb - the bytepublic int appendUnchecked(byte[] src)
appendUnchecked in class BuilderBasesrc - the source byte arraypublic int appendUnchecked(byte[] src,
int srcPos,
int len)
appendUnchecked in class BuilderBasesrc - the source byte arraysrcPos - starting position in the source array.len - the number of array elements to be copied.public java.lang.String toString()
toString in class java.lang.Object