|
XNIO API 3.0.4.GA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xnio.Buffers
public final class Buffers
Buffer utility methods.
Field Summary | |
---|---|
static ByteBuffer |
EMPTY_BYTE_BUFFER
The empty byte buffer. |
static Pooled<ByteBuffer> |
EMPTY_POOLED_BYTE_BUFFER
The empty pooled byte buffer. |
Method Summary | ||
---|---|---|
static void |
addRandom(ByteBuffer target)
Add a random amount of random data to the target buffer using the thread-local RNG. |
|
static void |
addRandom(ByteBuffer target,
int count)
Add count bytes of random data to the target buffer using the thread-local RNG. |
|
static void |
addRandom(ByteBuffer target,
Random random)
Add a random amount of random data to the target buffer. |
|
static void |
addRandom(ByteBuffer target,
Random random,
int count)
Add count bytes of random data to the target buffer. |
|
static
|
allocatedBufferPool(BufferAllocator<B> allocator,
int size)
A buffer pool which allocates a new buffer on every allocate request, and discards buffers on free. |
|
static void |
assertWritable(Buffer... buffers)
Assert the writability of the given buffers. |
|
static void |
assertWritable(Buffer[] buffers,
int offs,
int len)
Assert the writability of the given buffers. |
|
static
|
clear(T buffer)
Clear a buffer. |
|
static int |
copy(ByteBuffer[] destinations,
int offset,
int length,
ByteBuffer source)
Copy as many bytes as possible from sources into destinations in a "scatter" fashion. |
|
static long |
copy(ByteBuffer[] destinations,
int destOffset,
int destLength,
ByteBuffer[] sources,
int srcOffset,
int srcLength)
Copy as many bytes as possible from sources into destinations by a combined "scatter"/"gather" operation. |
|
static int |
copy(ByteBuffer destination,
ByteBuffer source)
Copy as many bytes as possible from source into destination . |
|
static int |
copy(ByteBuffer destination,
ByteBuffer[] sources,
int offset,
int length)
Copy as many bytes as possible from sources into destination in a "gather" fashion. |
|
static ByteBuffer |
copy(ByteBuffer buffer,
int sliceSize,
BufferAllocator<ByteBuffer> allocator)
Copy a portion of the buffer into a newly allocated buffer. |
|
static int |
copy(int count,
ByteBuffer[] destinations,
int offset,
int length,
ByteBuffer source)
Copy at most count bytes from sources into destinations in a "scatter" fashion. |
|
static int |
copy(int count,
ByteBuffer destination,
ByteBuffer source)
Copy at most count bytes from source into destination . |
|
static int |
copy(int count,
ByteBuffer destination,
ByteBuffer[] sources,
int offset,
int length)
Copy at most count bytes from sources into destination in a "gather" fashion. |
|
static long |
copy(long count,
ByteBuffer[] destinations,
int destOffset,
int destLength,
ByteBuffer[] sources,
int srcOffset,
int srcLength)
Copy at most count bytes from sources into destinations by a combined "scatter"/"gather" operation. |
|
static Object |
createDumper(ByteBuffer buffer,
int indent,
int columns)
Create an object that returns the dumped form of the given byte buffer when its toString() method is called. |
|
static Object |
createDumper(CharBuffer buffer,
int indent,
int columns)
Create an object that returns the dumped form of the given character buffer when its toString() method is called. |
|
static void |
dump(ByteBuffer buffer,
Appendable dest,
int indent,
int columns)
Dump a byte buffer to the given target. |
|
static void |
dump(CharBuffer buffer,
Appendable dest,
int indent,
int columns)
Dump a character buffer to the given target. |
|
static ByteBuffer |
fill(ByteBuffer buffer,
int value,
int count)
Fill a buffer with a repeated value. |
|
static CharBuffer |
fill(CharBuffer buffer,
int value,
int count)
Fill a buffer with a repeated value. |
|
static IntBuffer |
fill(IntBuffer buffer,
int value,
int count)
Fill a buffer with a repeated value. |
|
static LongBuffer |
fill(LongBuffer buffer,
long value,
int count)
Fill a buffer with a repeated value. |
|
static ShortBuffer |
fill(ShortBuffer buffer,
int value,
int count)
Fill a buffer with a repeated value. |
|
static
|
flip(T buffer)
Flip a buffer. |
|
static String |
getModifiedUtf8(ByteBuffer src)
Get a modified UTF-8 string from the remainder of the buffer. |
|
static String |
getModifiedUtf8Z(ByteBuffer src)
Get a 0-terminated string from the byte buffer, decoding it using "modified UTF-8" encoding. |
|
static boolean |
hasRemaining(Buffer[] buffers)
Determine whether any of the buffers has remaining data. |
|
static boolean |
hasRemaining(Buffer[] buffers,
int offs,
int len)
Determine whether any of the buffers has remaining data. |
|
static boolean |
isDirect(Buffer... buffers)
Determine whether the given buffers list is comprised solely of direct buffers or solely of heap buffers. |
|
static boolean |
isDirect(Buffer[] buffers,
int offset,
int length)
Determine whether the given buffers list is comprised solely of direct buffers or solely of heap buffers. |
|
static boolean |
isSecureBufferPool(Pool<?> pool)
Determine whether the given pool is a secure pool. |
|
static
|
limit(T buffer,
int limit)
Set the buffer limit. |
|
static
|
mark(T buffer)
Set the buffer mark. |
|
static
|
pooledWrapper(B buffer)
Create a pooled wrapper around a buffer. |
|
static
|
position(T buffer,
int position)
Set the buffer position. |
|
static ByteBuffer |
putModifiedUtf8(ByteBuffer dest,
String orig)
Put the string into the byte buffer, encoding it using "modified UTF-8" encoding. |
|
static void |
readAscii(ByteBuffer src,
StringBuilder builder)
Read the remainder of a buffer as ASCII text, appending the results to the given string builder. |
|
static void |
readAscii(ByteBuffer src,
StringBuilder builder,
char replacement)
Read the remainder of a buffer as ASCII text, appending the results to the given string builder. |
|
static void |
readAscii(ByteBuffer src,
StringBuilder builder,
int limit,
char replacement)
Read the remainder of a buffer as ASCII text, up to a certain limit, appending the results to the given string builder. |
|
static boolean |
readAsciiLine(ByteBuffer src,
StringBuilder builder)
Read a single line of ASCII text from a byte buffer, appending the results to the given string builder. |
|
static boolean |
readAsciiLine(ByteBuffer src,
StringBuilder builder,
char replacement)
Read a single line of ASCII text from a byte buffer, appending the results to the given string builder. |
|
static boolean |
readAsciiLine(ByteBuffer src,
StringBuilder builder,
char replacement,
char delimiter)
Read a single line of ASCII text from a byte buffer, appending the results to the given string builder, using the given delimiter character instead of EOL . |
|
static boolean |
readAsciiZ(ByteBuffer src,
StringBuilder builder)
Read an ASCIIZ ( NUL -terminated) string from a byte buffer, appending the results to the given string
builder. |
|
static boolean |
readAsciiZ(ByteBuffer src,
StringBuilder builder,
char replacement)
Read an ASCIIZ ( NUL -terminated) string from a byte buffer, appending the results to the given string
builder. |
|
static void |
readLatin1(ByteBuffer src,
StringBuilder builder)
Read the remainder of a buffer as Latin-1 text, appending the results to the given string builder. |
|
static boolean |
readLatin1Line(ByteBuffer src,
StringBuilder builder)
Read a single line of Latin-1 text from a byte buffer, appending the results to the given string builder. |
|
static boolean |
readLatin1Line(ByteBuffer src,
StringBuilder builder,
char delimiter)
Read a single line of Latin-1 text from a byte buffer, appending the results to the given string builder. |
|
static boolean |
readLatin1Z(ByteBuffer src,
StringBuilder builder)
Read a NUL -terminated Latin-1 string from a byte buffer, appending the results to the given string
builder. |
|
static boolean |
readLine(ByteBuffer src,
StringBuilder builder,
CharsetDecoder decoder)
Read a single line of text from a byte buffer, appending the results to the given string builder. |
|
static boolean |
readLine(ByteBuffer src,
StringBuilder builder,
CharsetDecoder decoder,
char delimiter)
Read a single line of text from a byte buffer, appending the results to the given string builder. |
|
static boolean |
readModifiedUtf8Line(ByteBuffer src,
StringBuilder builder)
Read a single line of modified UTF-8 text from a byte buffer, appending the results to the given string
builder. |
|
static boolean |
readModifiedUtf8Line(ByteBuffer src,
StringBuilder builder,
char replacement)
Read a single line of modified UTF-8 text from a byte buffer, appending the results to the given string
builder. |
|
static boolean |
readModifiedUtf8Line(ByteBuffer src,
StringBuilder builder,
char replacement,
char delimiter)
Read a single line of modified UTF-8 text from a byte buffer, appending the results to the given string
builder. |
|
static boolean |
readModifiedUtf8Z(ByteBuffer src,
StringBuilder builder)
Read a NUL -terminated modified UTF-8 string from a byte buffer, appending the results to the given string
builder. |
|
static boolean |
readModifiedUtf8Z(ByteBuffer src,
StringBuilder builder,
char replacement)
Read a NUL -terminated modified UTF-8 string from a byte buffer, appending the results to the given string
builder. |
|
static long |
remaining(Buffer[] buffers)
Get the total remaining size of all the given buffers. |
|
static long |
remaining(Buffer[] buffers,
int offs,
int len)
Get the total remaining size of all the given buffers. |
|
static
|
reset(T buffer)
Reset the buffer. |
|
static
|
rewind(T buffer)
Rewind the buffer. |
|
static Pool<ByteBuffer> |
secureBufferPool(Pool<ByteBuffer> delegate)
A byte buffer pool which zeroes the content of the buffer before re-pooling it. |
|
static
|
skip(T buffer,
int cnt)
Advance a buffer's position relative to its current position. |
|
static ByteBuffer |
slice(ByteBuffer buffer,
int sliceSize)
Slice the buffer. |
|
static CharBuffer |
slice(CharBuffer buffer,
int sliceSize)
Slice the buffer. |
|
static IntBuffer |
slice(IntBuffer buffer,
int sliceSize)
Slice the buffer. |
|
static LongBuffer |
slice(LongBuffer buffer,
int sliceSize)
Slice the buffer. |
|
static ShortBuffer |
slice(ShortBuffer buffer,
int sliceSize)
Slice the buffer. |
|
static BufferAllocator<ByteBuffer> |
sliceAllocator(ByteBuffer buffer)
A buffer allocator which allocates slices off of the given buffer. |
|
static byte[] |
take(ByteBuffer buffer)
Take all of the remaining bytes from the buffer and return them in an array. |
|
static byte[] |
take(ByteBuffer buffer,
int cnt)
Take a certain number of bytes from the buffer and return them in an array. |
|
static char[] |
take(CharBuffer buffer)
Take all of the remaining chars from the buffer and return them in an array. |
|
static char[] |
take(CharBuffer buffer,
int cnt)
Take a certain number of chars from the buffer and return them in an array. |
|
static int[] |
take(IntBuffer buffer)
Take all of the remaining ints from the buffer and return them in an array. |
|
static int[] |
take(IntBuffer buffer,
int cnt)
Take a certain number of ints from the buffer and return them in an array. |
|
static long[] |
take(LongBuffer buffer)
Take all of the remaining longs from the buffer and return them in an array. |
|
static long[] |
take(LongBuffer buffer,
int cnt)
Take a certain number of longs from the buffer and return them in an array. |
|
static short[] |
take(ShortBuffer buffer)
Take all of the remaining shorts from the buffer and return them in an array. |
|
static short[] |
take(ShortBuffer buffer,
int cnt)
Take a certain number of shorts from the buffer and return them in an array. |
|
static long |
trySkip(Buffer[] buffers,
int offs,
int len,
long cnt)
Attempt to advance a series of buffers' overall position relative to its current position. |
|
static int |
trySkip(Buffer buffer,
int cnt)
Attempt to advance a buffer's position relative to its current position. |
|
static
|
unget(T buffer,
int cnt)
Rewind a buffer's position relative to its current position. |
|
static void |
zero(ByteBuffer buffer)
Zero a buffer. |
|
static void |
zero(CharBuffer buffer)
Zero a buffer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final ByteBuffer EMPTY_BYTE_BUFFER
public static final Pooled<ByteBuffer> EMPTY_POOLED_BYTE_BUFFER
Method Detail |
---|
public static <T extends Buffer> T flip(T buffer)
T
- the buffer typebuffer
- the buffer to flip
Buffer.flip()
public static <T extends Buffer> T clear(T buffer)
T
- the buffer typebuffer
- the buffer to clear
Buffer.clear()
public static <T extends Buffer> T limit(T buffer, int limit)
T
- the buffer typebuffer
- the buffer to setlimit
- the new limit
Buffer.limit(int)
public static <T extends Buffer> T mark(T buffer)
T
- the buffer typebuffer
- the buffer to mark
Buffer.mark()
public static <T extends Buffer> T position(T buffer, int position)
T
- the buffer typebuffer
- the buffer to setposition
- the new position
Buffer.position(int)
public static <T extends Buffer> T reset(T buffer)
T
- the buffer typebuffer
- the buffer to reset
Buffer.reset()
public static <T extends Buffer> T rewind(T buffer)
T
- the buffer typebuffer
- the buffer to rewind
Buffer.rewind()
public static ByteBuffer slice(ByteBuffer buffer, int sliceSize)
buffer
- the buffer to slicesliceSize
- the size of the slice
ByteBuffer.slice()
public static ByteBuffer copy(ByteBuffer buffer, int sliceSize, BufferAllocator<ByteBuffer> allocator)
buffer
- the buffer to slicesliceSize
- the size of the copyallocator
- the buffer allocator to use
public static int copy(ByteBuffer destination, ByteBuffer source)
source
into destination
.
destination
- the destination buffersource
- the source buffer
public static int copy(ByteBuffer[] destinations, int offset, int length, ByteBuffer source)
sources
into destinations
in a "scatter" fashion.
destinations
- the destination buffersoffset
- the offset into the destination buffers arraylength
- the number of buffers to updatesource
- the source buffer
public static int copy(ByteBuffer destination, ByteBuffer[] sources, int offset, int length)
sources
into destination
in a "gather" fashion.
destination
- the destination buffersources
- the source buffersoffset
- the offset into the source buffers arraylength
- the number of buffers to read from
public static long copy(ByteBuffer[] destinations, int destOffset, int destLength, ByteBuffer[] sources, int srcOffset, int srcLength)
sources
into destinations
by a combined "scatter"/"gather" operation.
destinations
- the destination buffersdestOffset
- the offset into the destination buffers arraydestLength
- the number of buffers to write tosources
- the source bufferssrcOffset
- the offset into the source buffers arraysrcLength
- the number of buffers to read from
public static int copy(int count, ByteBuffer destination, ByteBuffer source)
count
bytes from source
into destination
.
count
- the maximum number of bytes to copydestination
- the destination buffersource
- the source buffer
public static int copy(int count, ByteBuffer[] destinations, int offset, int length, ByteBuffer source)
count
bytes from sources
into destinations
in a "scatter" fashion.
count
- the maximum number of bytes to copydestinations
- the destination buffersoffset
- the offset into the destination buffers arraylength
- the number of buffers to updatesource
- the source buffer
public static int copy(int count, ByteBuffer destination, ByteBuffer[] sources, int offset, int length)
count
bytes from sources
into destination
in a "gather" fashion.
count
- the maximum number of bytes to copydestination
- the destination buffersources
- the source buffersoffset
- the offset into the source buffers arraylength
- the number of buffers to read from
public static long copy(long count, ByteBuffer[] destinations, int destOffset, int destLength, ByteBuffer[] sources, int srcOffset, int srcLength)
count
bytes from sources
into destinations
by a combined "scatter"/"gather" operation.
count
- the maximum number of bytes to copydestinations
- the destination buffersdestOffset
- the offset into the destination buffers arraydestLength
- the number of buffers to write tosources
- the source bufferssrcOffset
- the offset into the source buffers arraysrcLength
- the number of buffers to read from
public static ByteBuffer fill(ByteBuffer buffer, int value, int count)
buffer
- the buffer to fillvalue
- the value to fillcount
- the number of bytes to fill
public static CharBuffer slice(CharBuffer buffer, int sliceSize)
buffer
- the buffer to slicesliceSize
- the size of the slice
CharBuffer.slice()
public static CharBuffer fill(CharBuffer buffer, int value, int count)
buffer
- the buffer to fillvalue
- the value to fillcount
- the number of chars to fill
public static ShortBuffer slice(ShortBuffer buffer, int sliceSize)
buffer
- the buffer to slicesliceSize
- the size of the slice
ShortBuffer.slice()
public static ShortBuffer fill(ShortBuffer buffer, int value, int count)
buffer
- the buffer to fillvalue
- the value to fillcount
- the number of shorts to fill
public static IntBuffer slice(IntBuffer buffer, int sliceSize)
buffer
- the buffer to slicesliceSize
- the size of the slice
IntBuffer.slice()
public static IntBuffer fill(IntBuffer buffer, int value, int count)
buffer
- the buffer to fillvalue
- the value to fillcount
- the number of ints to fill
public static LongBuffer slice(LongBuffer buffer, int sliceSize)
buffer
- the buffer to slicesliceSize
- the size of the slice
LongBuffer.slice()
public static LongBuffer fill(LongBuffer buffer, long value, int count)
buffer
- the buffer to fillvalue
- the value to fillcount
- the number of longs to fill
public static <T extends Buffer> T skip(T buffer, int cnt) throws BufferUnderflowException
T
- the buffer typebuffer
- the buffer to setcnt
- the distance to skip
BufferUnderflowException
- if there are fewer than cnt
bytes remainingBuffer.position(int)
public static int trySkip(Buffer buffer, int cnt)
buffer
- the buffer to setcnt
- the distance to skip
Buffer.position(int)
public static long trySkip(Buffer[] buffers, int offs, int len, long cnt)
buffers
- the buffers to setoffs
- the offset into the buffers arraylen
- the number of buffers to considercnt
- the distance to skip
Buffer.position(int)
public static <T extends Buffer> T unget(T buffer, int cnt)
T
- the buffer typebuffer
- the buffer to setcnt
- the distance to skip backwards
Buffer.position(int)
public static byte[] take(ByteBuffer buffer, int cnt)
buffer
- the buffer to readcnt
- the number of bytes to take
public static char[] take(CharBuffer buffer, int cnt)
buffer
- the buffer to readcnt
- the number of chars to take
public static short[] take(ShortBuffer buffer, int cnt)
buffer
- the buffer to readcnt
- the number of shorts to take
public static int[] take(IntBuffer buffer, int cnt)
buffer
- the buffer to readcnt
- the number of ints to take
public static long[] take(LongBuffer buffer, int cnt)
buffer
- the buffer to readcnt
- the number of longs to take
public static byte[] take(ByteBuffer buffer)
buffer
- the buffer to read
public static char[] take(CharBuffer buffer)
buffer
- the buffer to read
public static short[] take(ShortBuffer buffer)
buffer
- the buffer to read
public static int[] take(IntBuffer buffer)
buffer
- the buffer to read
public static long[] take(LongBuffer buffer)
buffer
- the buffer to read
public static Object createDumper(ByteBuffer buffer, int indent, int columns)
toString()
method is called.
Useful for logging byte buffers; if the toString()
method is never called, the process of dumping the
buffer is never performed.
buffer
- the bufferindent
- the indentation to usecolumns
- the number of 8-byte columns
public static void dump(ByteBuffer buffer, Appendable dest, int indent, int columns) throws IOException
buffer
- the bufferdest
- the targetindent
- the indentation to usecolumns
- the number of 8-byte columns
IOException
- if an error occurs during appendpublic static Object createDumper(CharBuffer buffer, int indent, int columns)
toString()
method is called.
Useful for logging character buffers; if the toString()
method is never called, the process of dumping the
buffer is never performed.
buffer
- the bufferindent
- the indentation to usecolumns
- the number of 8-byte columns
public static void dump(CharBuffer buffer, Appendable dest, int indent, int columns) throws IOException
buffer
- the bufferdest
- the targetindent
- the indentation to usecolumns
- the number of 8-byte columns
IOException
- if an error occurs during appendpublic static boolean hasRemaining(Buffer[] buffers, int offs, int len)
buffers
- the buffersoffs
- the offset into the buffers arraylen
- the number of buffers to check
true
if any of the selected buffers has remaining datapublic static boolean hasRemaining(Buffer[] buffers)
buffers
- the buffers
true
if any of the selected buffers has remaining datapublic static long remaining(Buffer[] buffers, int offs, int len)
buffers
- the buffersoffs
- the offset into the buffers arraylen
- the number of buffers to check
public static long remaining(Buffer[] buffers)
buffers
- the buffers
public static ByteBuffer putModifiedUtf8(ByteBuffer dest, String orig) throws BufferOverflowException
dest
- the byte bufferorig
- the source bytes
BufferOverflowException
- if there is not enough space in the buffer for the complete stringDataOutput.writeUTF(String)
public static String getModifiedUtf8Z(ByteBuffer src) throws BufferUnderflowException
src
- the source buffer
BufferUnderflowException
- if the end of the buffer was reached before encountering a 0
public static String getModifiedUtf8(ByteBuffer src) throws BufferUnderflowException
src
- the buffer
BufferUnderflowException
- if the buffer ends abruptly in the midst of a single characterpublic static boolean readAsciiZ(ByteBuffer src, StringBuilder builder)
NUL
-terminated) string from a byte buffer, appending the results to the given string
builder. If no NUL
character is encountered, false
is returned, indicating that more data needs
to be acquired before the operation can be complete. On return, there may be data remaining
in the source buffer. If an invalid byte is read, the character '?'
is written
to the string builder in its place.
src
- the source bufferbuilder
- the destination builder
true
if the entire string was read, false
if more data is neededpublic static boolean readAsciiZ(ByteBuffer src, StringBuilder builder, char replacement)
NUL
-terminated) string from a byte buffer, appending the results to the given string
builder. If no NUL
character is encountered, false
is returned, indicating that more data needs
to be acquired before the operation can be complete. On return, there may be data remaining
in the source buffer. If an invalid byte is read, the character designated by replacement
is written
to the string builder in its place.
src
- the source bufferbuilder
- the destination builderreplacement
- the replacement character for invalid bytes
true
if the entire string was read, false
if more data is neededpublic static boolean readAsciiLine(ByteBuffer src, StringBuilder builder)
EOL
character is encountered, false
is returned, indicating that more data needs
to be acquired before the operation can be complete. On return, there may be data remaining
in the source buffer. If an invalid byte is read, the character '?'
is written
to the string builder in its place. The EOL
character will be included in the resultant string.
src
- the source bufferbuilder
- the destination builder
true
if the entire string was read, false
if more data is neededpublic static boolean readAsciiLine(ByteBuffer src, StringBuilder builder, char replacement)
EOL
character is encountered, false
is returned, indicating that more data needs
to be acquired before the operation can be complete. On return, there may be data remaining
in the source buffer. If an invalid byte is read, the character designated by replacement
is written
to the string builder in its place. The EOL
character will be included in the resultant string.
src
- the source bufferbuilder
- the destination builderreplacement
- the replacement character for invalid bytes
true
if the entire string was read, false
if more data is neededpublic static boolean readAsciiLine(ByteBuffer src, StringBuilder builder, char replacement, char delimiter)
EOL
. If no delimiter character is encountered,
false
is returned, indicating that more data needs
to be acquired before the operation can be complete. On return, there may be data remaining
in the source buffer. If an invalid byte is read, the character designated by replacement
is written
to the string builder in its place. The delimiter character will be included in the resultant string.
src
- the source bufferbuilder
- the destination builderreplacement
- the replacement character for invalid bytesdelimiter
- the character which marks the end of the line
true
if the entire string was read, false
if more data is neededpublic static void readAscii(ByteBuffer src, StringBuilder builder)
'?'
is written
to the string builder in its place.
src
- the source bufferbuilder
- the destination builderpublic static void readAscii(ByteBuffer src, StringBuilder builder, char replacement)
replacement
is written
to the string builder in its place.
src
- the source bufferbuilder
- the destination builderreplacement
- the replacement character for invalid bytespublic static void readAscii(ByteBuffer src, StringBuilder builder, int limit, char replacement)
replacement
is written
to the string builder in its place.
src
- the source bufferbuilder
- the destination builderlimit
- the maximum number of characters to writereplacement
- the replacement character for invalid bytespublic static boolean readLatin1Z(ByteBuffer src, StringBuilder builder)
NUL
-terminated Latin-1 string from a byte buffer, appending the results to the given string
builder. If no NUL
character is encountered, false
is returned, indicating that more data needs
to be acquired before the operation can be complete. On return, there may be data remaining
in the source buffer.
src
- the source bufferbuilder
- the destination builder
true
if the entire string was read, false
if more data is neededpublic static boolean readLatin1Line(ByteBuffer src, StringBuilder builder)
EOL
character is encountered, false
is returned, indicating that more data needs
to be acquired before the operation can be complete. On return, there may be data remaining
in the source buffer. The EOL
character will be included in the resultant string.
src
- the source bufferbuilder
- the destination builder
true
if the entire string was read, false
if more data is neededpublic static boolean readLatin1Line(ByteBuffer src, StringBuilder builder, char delimiter)
false
is returned, indicating that more data needs
to be acquired before the operation can be complete. On return, there may be data remaining
in the source buffer. The delimiter character will be included in the resultant string.
src
- the source bufferbuilder
- the destination builderdelimiter
- the character which marks the end of the line
true
if the entire string was read, false
if more data is neededpublic static void readLatin1(ByteBuffer src, StringBuilder builder)
src
- the source bufferbuilder
- the destination builderpublic static boolean readModifiedUtf8Z(ByteBuffer src, StringBuilder builder)
NUL
-terminated modified UTF-8
string from a byte buffer, appending the results to the given string
builder. If no NUL
byte is encountered, false
is returned, indicating that more data needs
to be acquired before the operation can be complete. On return, there may be data remaining
in the source buffer. If an invalid byte sequence is read, the character '?'
is written
to the string builder in its place.
src
- the source bufferbuilder
- the destination builder
true
if the entire string was read, false
if more data is neededpublic static boolean readModifiedUtf8Z(ByteBuffer src, StringBuilder builder, char replacement)
NUL
-terminated modified UTF-8
string from a byte buffer, appending the results to the given string
builder. If no NUL
byte is encountered, false
is returned, indicating that more data needs
to be acquired before the operation can be complete. On return, there may be data remaining
in the source buffer. If an invalid byte sequence is read, the character designated by replacement
is written
to the string builder in its place.
src
- the source bufferbuilder
- the destination builderreplacement
- the replacement character to use
true
if the entire string was read, false
if more data is neededpublic static boolean readModifiedUtf8Line(ByteBuffer src, StringBuilder builder)
modified UTF-8
text from a byte buffer, appending the results to the given string
builder. If no EOL
character is encountered, false
is returned, indicating that more data needs
to be acquired before the operation can be complete. On return, there may be data remaining
in the source buffer. If an invalid byte is read, the character '?'
is written
to the string builder in its place. The EOL
character will be included in the resultant string.
src
- the source bufferbuilder
- the destination builder
true
if the entire string was read, false
if more data is neededpublic static boolean readModifiedUtf8Line(ByteBuffer src, StringBuilder builder, char replacement)
modified UTF-8
text from a byte buffer, appending the results to the given string
builder. If no EOL
character is encountered, false
is returned, indicating that more data needs
to be acquired before the operation can be complete. On return, there may be data remaining
in the source buffer. If an invalid byte is read, the character designated by replacement
is written
to the string builder in its place. The EOL
character will be included in the resultant string.
src
- the source bufferbuilder
- the destination builderreplacement
- the replacement character for invalid bytes
true
if the entire string was read, false
if more data is neededpublic static boolean readModifiedUtf8Line(ByteBuffer src, StringBuilder builder, char replacement, char delimiter)
modified UTF-8
text from a byte buffer, appending the results to the given string
builder. If no EOL
character is encountered, false
is returned, indicating that more data needs
to be acquired before the operation can be complete. On return, there may be data remaining
in the source buffer. If an invalid byte is read, the character designated by replacement
is written
to the string builder in its place. The delimiter character will be included in the resultant string.
src
- the source bufferbuilder
- the destination builderreplacement
- the replacement character for invalid bytesdelimiter
- the character which marks the end of the line
true
if the entire string was read, false
if more data is neededpublic static boolean readLine(ByteBuffer src, StringBuilder builder, CharsetDecoder decoder)
EOL
character is encountered, false
is returned, indicating that more data needs
to be acquired before the operation can be complete. On return, there may be data remaining
in the source buffer. Invalid bytes are handled according to the policy specified by the decoder
instance.
Since this method decodes only one character at a time, it should not be expected to have the same performance
as the other optimized, character set-specific methods specified in this class.
The EOL
character will be included in the resultant string.
src
- the source bufferbuilder
- the destination builderdecoder
- the decoder to use
true
if the entire string was read, false
if more data is neededpublic static boolean readLine(ByteBuffer src, StringBuilder builder, CharsetDecoder decoder, char delimiter)
false
is returned, indicating that more data needs
to be acquired before the operation can be complete. On return, there may be data remaining
in the source buffer. Invalid bytes are handled according to the policy specified by the decoder
instance.
Since this method decodes only one character at a time, it should not be expected to have the same performance
as the other optimized, character set-specific methods specified in this class. The delimiter character will be
included in the resultant string.
src
- the source bufferbuilder
- the destination builderdecoder
- the decoder to usedelimiter
- the character which marks the end of the line
true
if the entire string was read, false
if more data is neededpublic static <B extends Buffer> Pooled<B> pooledWrapper(B buffer)
B
- the buffer typebuffer
- the buffer to wrap
public static BufferAllocator<ByteBuffer> sliceAllocator(ByteBuffer buffer)
BufferUnderflowException
.
buffer
- the source buffer
public static <B extends Buffer> Pool<B> allocatedBufferPool(BufferAllocator<B> allocator, int size)
B
- the buffer typeallocator
- the buffer allocatorsize
- the buffer size
public static Pool<ByteBuffer> secureBufferPool(Pool<ByteBuffer> delegate)
delegate
- the delegate pool
public static boolean isSecureBufferPool(Pool<?> pool)
pool
- the pool to test
true
if it is a secure pool instancepublic static void zero(ByteBuffer buffer)
buffer
- the bufferpublic static void zero(CharBuffer buffer)
buffer
- the bufferpublic static boolean isDirect(Buffer... buffers) throws IllegalArgumentException
buffers
- the buffers
true
if all the buffers are direct, false
if they are all heap buffers
IllegalArgumentException
- if both direct and heap buffers were found, or if a buffer is null
public static boolean isDirect(Buffer[] buffers, int offset, int length)
buffers
- the buffers
true
if all the buffers are direct, false
if they are all heap buffers
IllegalArgumentException
- if both direct and heap buffers were found, or if a buffer is null
public static void assertWritable(Buffer[] buffers, int offs, int len) throws ReadOnlyBufferException
buffers
- the buffers arrayoffs
- the offset in the array to start searchinglen
- the number of buffers to check
ReadOnlyBufferException
- if any of the buffers are read-onlypublic static void assertWritable(Buffer... buffers) throws ReadOnlyBufferException
buffers
- the buffers array
ReadOnlyBufferException
- if any of the buffers are read-onlypublic static void addRandom(ByteBuffer target, Random random, int count)
count
bytes of random data to the target buffer.
target
- the target bufferrandom
- the RNGcount
- the number of bytes to addpublic static void addRandom(ByteBuffer target, int count)
count
bytes of random data to the target buffer using the thread-local RNG.
target
- the target buffercount
- the number of bytes to addpublic static void addRandom(ByteBuffer target, Random random)
target
- the target bufferrandom
- the RNGpublic static void addRandom(ByteBuffer target)
target
- the target buffer
|
XNIO API 3.0.4.GA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |