Class BufferUtils
- java.lang.Object
-
- com.sun.enterprise.mgmt.transport.buffers.BufferUtils
-
public class BufferUtils extends java.lang.Object- Author:
- Alexey Stashok
-
-
Field Summary
Fields Modifier and Type Field Description static java.nio.ByteBufferEMPTY_BYTE_BUFFERstatic java.nio.ByteBuffer[]EMPTY_BYTE_BUFFER_ARRAY
-
Constructor Summary
Constructors Constructor Description BufferUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidget(java.nio.ByteBuffer srcBuffer, byte[] dstBytes, int dstOffset, int length)static voidput(byte[] srcBytes, int srcOffset, int length, java.nio.ByteBuffer dstBuffer)static voidput(java.nio.ByteBuffer srcBuffer, int srcOffset, int length, java.nio.ByteBuffer dstBuffer)static voidsetPositionLimit(Buffer buffer, int position, int limit)static voidsetPositionLimit(java.nio.ByteBuffer buffer, int position, int limit)static java.nio.ByteBufferslice(java.nio.ByteBuffer chunk, int size)SliceByteBufferof required size from big chunk.static java.nio.ByteBufferslice(java.nio.ByteBuffer byteBuffer, int position, int limit)Get theByteBuffer's slice basing on its passed position and limit.static java.lang.StringtoStringContent(java.nio.ByteBuffer byteBuffer, java.nio.charset.Charset charset, int position, int limit)
-
-
-
Method Detail
-
slice
public static java.nio.ByteBuffer slice(java.nio.ByteBuffer chunk, int size)SliceByteBufferof required size from big chunk. Passed chunk position will be changed, after the slicing (chunk.position += size).- Parameters:
chunk- bigByteBufferpool.size- required slice size.- Returns:
- sliced
ByteBufferof required size.
-
slice
public static java.nio.ByteBuffer slice(java.nio.ByteBuffer byteBuffer, int position, int limit)Get theByteBuffer's slice basing on its passed position and limit. Position and limit values of the passedByteBufferwon't be changed. The resultByteBufferposition will be equal to 0, and limit equal to number of sliced bytes (limit - position).- Parameters:
byteBuffer-ByteBufferto slice/position- the position in the passed byteBuffer, the slice will start from.limit- the limit in the passed byteBuffer, the slice will be ended.- Returns:
- sliced
ByteBufferof required size.
-
toStringContent
public static java.lang.String toStringContent(java.nio.ByteBuffer byteBuffer, java.nio.charset.Charset charset, int position, int limit)
-
setPositionLimit
public static void setPositionLimit(java.nio.ByteBuffer buffer, int position, int limit)
-
setPositionLimit
public static void setPositionLimit(Buffer buffer, int position, int limit)
-
put
public static void put(java.nio.ByteBuffer srcBuffer, int srcOffset, int length, java.nio.ByteBuffer dstBuffer)
-
get
public static void get(java.nio.ByteBuffer srcBuffer, byte[] dstBytes, int dstOffset, int length)
-
put
public static void put(byte[] srcBytes, int srcOffset, int length, java.nio.ByteBuffer dstBuffer)
-
-