|
XNIO API 2.0.0.GA | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.xnio.Buffers
public final class Buffers

Buffer utility methods.
| Field Summary | |
|---|---|
static java.nio.ByteBuffer |
EMPTY_BYTE_BUFFER
The empty byte buffer. |
| Method Summary | ||
|---|---|---|
static
|
clear(T buffer)
Clear a buffer. |
|
static java.lang.Object |
createDumper(java.nio.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 java.lang.Object |
createDumper(java.nio.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 Pool<java.nio.ByteBuffer> |
createHeapByteBufferAllocator(int size)
Create a heap-based buffer allocator. |
|
static void |
dump(java.nio.ByteBuffer buffer,
java.lang.Appendable dest,
int indent,
int columns)
Dump a byte buffer to the given target. |
|
static void |
dump(java.nio.CharBuffer buffer,
java.lang.Appendable dest,
int indent,
int columns)
Dump a character buffer to the given target. |
|
static java.nio.ByteBuffer |
fill(java.nio.ByteBuffer buffer,
int value,
int count)
Fill a buffer with a repeated value. |
|
static java.nio.CharBuffer |
fill(java.nio.CharBuffer buffer,
int value,
int count)
Fill a buffer with a repeated value. |
|
static java.nio.IntBuffer |
fill(java.nio.IntBuffer buffer,
int value,
int count)
Fill a buffer with a repeated value. |
|
static java.nio.LongBuffer |
fill(java.nio.LongBuffer buffer,
long value,
int count)
Fill a buffer with a repeated value. |
|
static java.nio.ShortBuffer |
fill(java.nio.ShortBuffer buffer,
int value,
int count)
Fill a buffer with a repeated value. |
|
static
|
flip(T buffer)
Flip a buffer. |
|
static java.lang.String |
getModifiedUtf8(java.nio.ByteBuffer src)
Get a modified UTF-8 string from the remainder of the buffer. |
|
static java.lang.String |
getModifiedUtf8Z(java.nio.ByteBuffer src)
Get a 0-terminated string from the byte buffer, decoding it using "modified UTF-8" encoding. |
|
static boolean |
hasRemaining(java.nio.Buffer[] buffers)
Determine whether any of the buffers has remaining data. |
|
static boolean |
hasRemaining(java.nio.Buffer[] buffers,
int offs,
int len)
Determine whether any of the buffers has remaining data. |
|
static
|
limit(T buffer,
int limit)
Set the buffer limit. |
|
static
|
mark(T buffer)
Set the buffer mark. |
|
static
|
position(T buffer,
int position)
Set the buffer position. |
|
static long |
put(java.nio.ByteBuffer[] dsts,
int doffs,
int dlen,
java.nio.ByteBuffer src)
Put as many bytes as possible from src into the byte buffers in a scatter fashion. |
|
static java.nio.ByteBuffer |
putModifiedUtf8(java.nio.ByteBuffer dest,
java.lang.String orig)
Put the string into the byte buffer, encoding it using "modified UTF-8" encoding. |
|
static long |
remaining(java.nio.Buffer[] buffers)
Get the total remaining size of all the given buffers. |
|
static long |
remaining(java.nio.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
|
skip(T buffer,
int cnt)
Advance a buffer's position relative to its current position. |
|
static java.nio.ByteBuffer |
slice(java.nio.ByteBuffer buffer,
int sliceSize)
Slice the buffer. |
|
static java.nio.CharBuffer |
slice(java.nio.CharBuffer buffer,
int sliceSize)
Slice the buffer. |
|
static java.nio.IntBuffer |
slice(java.nio.IntBuffer buffer,
int sliceSize)
Slice the buffer. |
|
static java.nio.LongBuffer |
slice(java.nio.LongBuffer buffer,
int sliceSize)
Slice the buffer. |
|
static java.nio.ShortBuffer |
slice(java.nio.ShortBuffer buffer,
int sliceSize)
Slice the buffer. |
|
static byte[] |
take(java.nio.ByteBuffer buffer,
int cnt)
Take a certain number of bytes from the buffer and return them in an array. |
|
static char[] |
take(java.nio.CharBuffer buffer,
int cnt)
Take a certain number of chars from the buffer and return them in an array. |
|
static int[] |
take(java.nio.IntBuffer buffer,
int cnt)
Take a certain number of ints from the buffer and return them in an array. |
|
static long[] |
take(java.nio.LongBuffer buffer,
int cnt)
Take a certain number of longs from the buffer and return them in an array. |
|
static short[] |
take(java.nio.ShortBuffer buffer,
int cnt)
Take a certain number of shorts from the buffer and return them in an array. |
|
static
|
unget(T buffer,
int cnt)
Rewind a buffer's position relative to its current position. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.nio.ByteBuffer EMPTY_BYTE_BUFFER
| Method Detail |
|---|
public static <T extends java.nio.Buffer> T flip(T buffer)
T - the buffer typebuffer - the buffer to flip
Buffer.flip()public static <T extends java.nio.Buffer> T clear(T buffer)
T - the buffer typebuffer - the buffer to clear
Buffer.clear()
public static <T extends java.nio.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 java.nio.Buffer> T mark(T buffer)
T - the buffer typebuffer - the buffer to mark
Buffer.mark()
public static <T extends java.nio.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 java.nio.Buffer> T reset(T buffer)
T - the buffer typebuffer - the buffer to reset
Buffer.reset()public static <T extends java.nio.Buffer> T rewind(T buffer)
T - the buffer typebuffer - the buffer to rewind
Buffer.rewind()
public static java.nio.ByteBuffer slice(java.nio.ByteBuffer buffer,
int sliceSize)
buffer - the buffer to slicesliceSize - the size of the slice
ByteBuffer.slice()
public static java.nio.ByteBuffer fill(java.nio.ByteBuffer buffer,
int value,
int count)
buffer - the buffer to fillvalue - the value to fillcount - the number of bytes to fill
public static java.nio.CharBuffer slice(java.nio.CharBuffer buffer,
int sliceSize)
buffer - the buffer to slicesliceSize - the size of the slice
CharBuffer.slice()
public static java.nio.CharBuffer fill(java.nio.CharBuffer buffer,
int value,
int count)
buffer - the buffer to fillvalue - the value to fillcount - the number of chars to fill
public static java.nio.ShortBuffer slice(java.nio.ShortBuffer buffer,
int sliceSize)
buffer - the buffer to slicesliceSize - the size of the slice
ShortBuffer.slice()
public static java.nio.ShortBuffer fill(java.nio.ShortBuffer buffer,
int value,
int count)
buffer - the buffer to fillvalue - the value to fillcount - the number of shorts to fill
public static java.nio.IntBuffer slice(java.nio.IntBuffer buffer,
int sliceSize)
buffer - the buffer to slicesliceSize - the size of the slice
IntBuffer.slice()
public static java.nio.IntBuffer fill(java.nio.IntBuffer buffer,
int value,
int count)
buffer - the buffer to fillvalue - the value to fillcount - the number of ints to fill
public static java.nio.LongBuffer slice(java.nio.LongBuffer buffer,
int sliceSize)
buffer - the buffer to slicesliceSize - the size of the slice
LongBuffer.slice()
public static java.nio.LongBuffer fill(java.nio.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 java.nio.Buffer> T skip(T buffer,
int cnt)
T - the buffer typebuffer - the buffer to setcnt - the distantce to skip
Buffer.position(int)
public static <T extends java.nio.Buffer> T unget(T buffer,
int cnt)
T - the buffer typebuffer - the buffer to setcnt - the distantce to skip backwards
Buffer.position(int)
public static byte[] take(java.nio.ByteBuffer buffer,
int cnt)
buffer - the buffer to readcnt - the number of bytes to take
public static char[] take(java.nio.CharBuffer buffer,
int cnt)
buffer - the buffer to readcnt - the number of chars to take
public static short[] take(java.nio.ShortBuffer buffer,
int cnt)
buffer - the buffer to readcnt - the number of shorts to take
public static int[] take(java.nio.IntBuffer buffer,
int cnt)
buffer - the buffer to readcnt - the number of ints to take
public static long[] take(java.nio.LongBuffer buffer,
int cnt)
buffer - the buffer to readcnt - the number of longs to take
public static java.lang.Object createDumper(java.nio.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(java.nio.ByteBuffer buffer,
java.lang.Appendable dest,
int indent,
int columns)
throws java.io.IOException
buffer - the bufferdest - the targetindent - the indentation to usecolumns - the number of 8-byte columns
java.io.IOException - if an error occurs during append
public static java.lang.Object createDumper(java.nio.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(java.nio.CharBuffer buffer,
java.lang.Appendable dest,
int indent,
int columns)
throws java.io.IOException
buffer - the bufferdest - the targetindent - the indentation to usecolumns - the number of 8-byte columns
java.io.IOException - if an error occurs during appendpublic static Pool<java.nio.ByteBuffer> createHeapByteBufferAllocator(int size)
size - the size of the returned buffers
public static boolean hasRemaining(java.nio.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(java.nio.Buffer[] buffers)
buffers - the buffers
true if any of the selected buffers has remaining data
public static long remaining(java.nio.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(java.nio.Buffer[] buffers)
buffers - the buffers
public static long put(java.nio.ByteBuffer[] dsts,
int doffs,
int dlen,
java.nio.ByteBuffer src)
src into the byte buffers in a scatter fashion.
dsts - the destination buffersdoffs - the offset into the destination buffers arraydlen - the number of buffers to updatesrc - the source buffer
public static java.nio.ByteBuffer putModifiedUtf8(java.nio.ByteBuffer dest,
java.lang.String orig)
throws java.nio.BufferOverflowException
dest - the byte bufferorig - the source bytes
java.nio.BufferOverflowException - if there is not enough space in the buffer for the complete stringDataOutput.writeUTF(String)
public static java.lang.String getModifiedUtf8Z(java.nio.ByteBuffer src)
throws java.nio.BufferUnderflowException
src - the source buffer
java.nio.BufferUnderflowException - if the end of the buffer was reached before encountering a 0
public static java.lang.String getModifiedUtf8(java.nio.ByteBuffer src)
throws java.nio.BufferUnderflowException
src - the buffer
java.nio.BufferUnderflowException - if the buffer ends abruptly in the midst of a single character
|
XNIO API 2.0.0.GA | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||