Class IoBufferWrapper
- java.lang.Object
-
- com.google.code.yanf4j.buffer.IoBuffer
-
- com.google.code.yanf4j.buffer.IoBufferWrapper
-
- All Implemented Interfaces:
Comparable<IoBuffer>
public class IoBufferWrapper extends IoBuffer
AIoBufferthat wraps a buffer and proxies any operations to it.You can think this class like a
FilterOutputStream. All operations are proxied by default so that you can extend this class and override existing operations selectively. You can introduce new operations, too.- Version:
- $Rev: 671827 $, $Date: 2008-06-26 10:49:48 +0200 (Thu, 26 Jun 2008) $
- Author:
- The Apache MINA Project (dev@mina.apache.org)
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedIoBufferWrapper(IoBuffer buf)Create a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]array()intarrayOffset()CharBufferasCharBuffer()DoubleBufferasDoubleBuffer()FloatBufferasFloatBuffer()InputStreamasInputStream()Returns anInputStreamthat reads the data from this buffer.IntBufferasIntBuffer()LongBufferasLongBuffer()OutputStreamasOutputStream()Returns anOutputStreamthat appends the data into this buffer.IoBufferasReadOnlyBuffer()ShortBufferasShortBuffer()ByteBufferbuf()Returns the underlying NIO buffer instance.intcapacity()IoBuffercapacity(int newCapacity)Increases the capacity of this buffer.IoBufferclear()IoBuffercompact()intcompareTo(IoBuffer that)IoBufferduplicate()booleanequals(Object ob)IoBufferexpand(int expectedRemaining)Changes the capacity and limit of this buffer so this buffer get the specified expectedRemaining room from the current position.IoBufferexpand(int pos, int expectedRemaining)Changes the capacity and limit of this buffer so this buffer get the specified expectedRemaining room from the specified position.IoBufferfill(byte value, int size)Fills this buffer with the specified value.IoBufferfill(int size)Fills this buffer withNUL (0x00).IoBufferfillAndReset(byte value, int size)Fills this buffer with the specified value.IoBufferfillAndReset(int size)Fills this buffer withNUL (0x00).IoBufferflip()voidfree()Declares this buffer and all its derived buffers are not used anymore so that it can be reused by someIoBufferAllocatorimplementations.byteget()IoBufferget(byte[] dst)IoBufferget(byte[] dst, int offset, int length)byteget(int index)chargetChar()chargetChar(int index)doublegetDouble()doublegetDouble(int index)<E extends Enum<E>>
EgetEnum(int index, Class<E> enumClass)Reads a byte from the buffer and returns the correlating enum constant defined by the specified enum type.<E extends Enum<E>>
EgetEnum(Class<E> enumClass)Reads a byte from the buffer and returns the correlating enum constant defined by the specified enum type.<E extends Enum<E>>
EgetEnumInt(int index, Class<E> enumClass)Reads an int from the buffer and returns the correlating enum constant defined by the specified enum type.<E extends Enum<E>>
EgetEnumInt(Class<E> enumClass)Reads an int from the buffer and returns the correlating enum constant defined by the specified enum type.<E extends Enum<E>>
EnumSet<E>getEnumSet(int index, Class<E> enumClass)Reads a byte sized bit vector and converts it to anEnumSet.<E extends Enum<E>>
EnumSet<E>getEnumSet(Class<E> enumClass)Reads a byte sized bit vector and converts it to anEnumSet.<E extends Enum<E>>
EnumSet<E>getEnumSetInt(int index, Class<E> enumClass)Reads an int sized bit vector and converts it to anEnumSet.<E extends Enum<E>>
EnumSet<E>getEnumSetInt(Class<E> enumClass)Reads an int sized bit vector and converts it to anEnumSet.<E extends Enum<E>>
EnumSet<E>getEnumSetLong(int index, Class<E> enumClass)Reads a long sized bit vector and converts it to anEnumSet.<E extends Enum<E>>
EnumSet<E>getEnumSetLong(Class<E> enumClass)Reads a long sized bit vector and converts it to anEnumSet.<E extends Enum<E>>
EnumSet<E>getEnumSetShort(int index, Class<E> enumClass)Reads a short sized bit vector and converts it to anEnumSet.<E extends Enum<E>>
EnumSet<E>getEnumSetShort(Class<E> enumClass)Reads a short sized bit vector and converts it to anEnumSet.<E extends Enum<E>>
EgetEnumShort(int index, Class<E> enumClass)Reads a short from the buffer and returns the correlating enum constant defined by the specified enum type.<E extends Enum<E>>
EgetEnumShort(Class<E> enumClass)Reads a short from the buffer and returns the correlating enum constant defined by the specified enum type.floatgetFloat()floatgetFloat(int index)StringgetHexDump()Returns hexdump of this buffer.StringgetHexDump(int lengthLimit)Return hexdump of this buffer with limited length.intgetInt()intgetInt(int index)longgetLong()longgetLong(int index)intgetMediumInt()Relative get method for reading a medium int value.intgetMediumInt(int index)Absolute get method for reading a medium int value.ObjectgetObject()Reads a Java object from the buffer using the contextClassLoaderof the current thread.ObjectgetObject(ClassLoader classLoader)Reads a Java object from the buffer using the specified classLoader.IoBuffergetParentBuffer()Returns the parent buffer that this buffer wrapped.StringgetPrefixedString(int prefixLength, CharsetDecoder decoder)Reads a string which has a length field before the actual encoded string, using the specifieddecoderand returns it.StringgetPrefixedString(CharsetDecoder decoder)Reads a string which has a 16-bit length field before the actual encoded string, using the specifieddecoderand returns it.shortgetShort()shortgetShort(int index)IoBuffergetSlice(int length)TODO document me.IoBuffergetSlice(int index, int length)TODO document me.StringgetString(int fieldSize, CharsetDecoder decoder)Reads aNUL-terminated string from this buffer using the specifieddecoderand returns it.StringgetString(CharsetDecoder decoder)Reads aNUL-terminated string from this buffer using the specifieddecoderand returns it.shortgetUnsigned()Reads one unsigned byte as a short integer.shortgetUnsigned(int index)Reads one byte as an unsigned short integer.longgetUnsignedInt()Reads four bytes unsigned integer.longgetUnsignedInt(int index)Reads four bytes unsigned integer.intgetUnsignedMediumInt()Relative get method for reading an unsigned medium int value.intgetUnsignedMediumInt(int index)Absolute get method for reading an unsigned medium int value.intgetUnsignedShort()Reads two bytes unsigned integer.intgetUnsignedShort(int index)Reads two bytes unsigned integer.booleanhasArray()inthashCode()booleanhasRemaining()intindexOf(byte b)Returns the first occurence position of the specified byte from the current position to the current limit.booleanisAutoExpand()Returns true if and only if autoExpand is turned on.booleanisAutoShrink()Returns true if and only if autoShrink is turned on.booleanisDerived()returns true if and only if this buffer is derived from other buffer viaIoBuffer.duplicate(),IoBuffer.slice()orIoBuffer.asReadOnlyBuffer().booleanisDirect()booleanisReadOnly()intlimit()IoBufferlimit(int newLimit)IoBuffermark()intmarkValue()Returns the position of the current mark.intminimumCapacity()Returns the minimum capacity of this buffer which is used to determine the new capacity of the buffer shrunk byIoBuffer.compact()andIoBuffer.shrink()operation.IoBufferminimumCapacity(int minimumCapacity)Sets the minimum capacity of this buffer which is used to determine the new capacity of the buffer shrunk byIoBuffer.compact()andIoBuffer.shrink()operation.ByteOrderorder()IoBufferorder(ByteOrder bo)intposition()IoBufferposition(int newPosition)booleanprefixedDataAvailable(int prefixLength)Returns true if this buffer contains a data which has a data length as a prefix and the buffer has remaining data as enough as specified in the data length field.booleanprefixedDataAvailable(int prefixLength, int maxDataLength)Returns true if this buffer contains a data which has a data length as a prefix and the buffer has remaining data as enough as specified in the data length field.IoBufferput(byte b)IoBufferput(byte[] src)IoBufferput(byte[] src, int offset, int length)IoBufferput(int index, byte b)IoBufferput(IoBuffer src)Writes the content of the specified src into this buffer.IoBufferput(ByteBuffer src)Writes the content of the specified src into this buffer.IoBufferputChar(char value)IoBufferputChar(int index, char value)IoBufferputDouble(double value)IoBufferputDouble(int index, double value)IoBufferputEnum(int index, Enum<?> e)Writes an enum's ordinal value to the buffer as a byte.IoBufferputEnum(Enum<?> e)Writes an enum's ordinal value to the buffer as a byte.IoBufferputEnumInt(int index, Enum<?> e)Writes an enum's ordinal value to the buffer as an integer.IoBufferputEnumInt(Enum<?> e)Writes an enum's ordinal value to the buffer as an integer.<E extends Enum<E>>
IoBufferputEnumSet(int index, Set<E> set)Writes the specifiedSetto the buffer as a byte sized bit vector.<E extends Enum<E>>
IoBufferputEnumSet(Set<E> set)Writes the specifiedSetto the buffer as a byte sized bit vector.<E extends Enum<E>>
IoBufferputEnumSetInt(int index, Set<E> set)Writes the specifiedSetto the buffer as an int sized bit vector.<E extends Enum<E>>
IoBufferputEnumSetInt(Set<E> set)Writes the specifiedSetto the buffer as an int sized bit vector.<E extends Enum<E>>
IoBufferputEnumSetLong(int index, Set<E> set)Writes the specifiedSetto the buffer as a long sized bit vector.<E extends Enum<E>>
IoBufferputEnumSetLong(Set<E> set)Writes the specifiedSetto the buffer as a long sized bit vector.<E extends Enum<E>>
IoBufferputEnumSetShort(int index, Set<E> set)Writes the specifiedSetto the buffer as a short sized bit vector.<E extends Enum<E>>
IoBufferputEnumSetShort(Set<E> set)Writes the specifiedSetto the buffer as a short sized bit vector.IoBufferputEnumShort(int index, Enum<?> e)Writes an enum's ordinal value to the buffer as a short.IoBufferputEnumShort(Enum<?> e)Writes an enum's ordinal value to the buffer as a short.IoBufferputFloat(float value)IoBufferputFloat(int index, float value)IoBufferputInt(int value)IoBufferputInt(int index, int value)IoBufferputLong(int index, long value)IoBufferputLong(long value)IoBufferputMediumInt(int value)Relative put method for writing a medium int value.IoBufferputMediumInt(int index, int value)Absolute put method for writing a medium int value.IoBufferputObject(Object o)Writes the specified Java object to the buffer.IoBufferputPrefixedString(CharSequence in, int prefixLength, int padding, byte padValue, CharsetEncoder encoder)Writes the content ofininto this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder.IoBufferputPrefixedString(CharSequence in, int prefixLength, int padding, CharsetEncoder encoder)Writes the content ofininto this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder.IoBufferputPrefixedString(CharSequence in, int prefixLength, CharsetEncoder encoder)Writes the content ofininto this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder.IoBufferputPrefixedString(CharSequence in, CharsetEncoder encoder)Writes the content ofininto this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder.IoBufferputShort(int index, short value)IoBufferputShort(short value)IoBufferputString(CharSequence in, int fieldSize, CharsetEncoder encoder)Writes the content ofininto this buffer as aNUL-terminated string using the specifiedencoder.IoBufferputString(CharSequence in, CharsetEncoder encoder)Writes the content ofininto this buffer using the specifiedencoder.intremaining()IoBufferreset()IoBufferrewind()IoBuffersetAutoExpand(boolean autoExpand)Turns on or off autoExpand.IoBuffersetAutoShrink(boolean autoShrink)Turns on or off autoShrink.IoBuffershrink()Changes the capacity of this buffer so this buffer occupies as less memory as possible while retaining the position, limit and the buffer content between the position and limit.IoBufferskip(int size)Forwards the position of this buffer as the specifiedsizebytes.IoBufferslice()IoBuffersweep()Clears this buffer and fills its content with NUL.IoBuffersweep(byte value)double Clears this buffer and fills its content with value.StringtoString()-
Methods inherited from class com.google.code.yanf4j.buffer.IoBuffer
allocate, allocate, getAllocator, isUseDirectBuffer, normalizeCapacity, setAllocator, setUseDirectBuffer, wrap, wrap, wrap
-
-
-
-
Constructor Detail
-
IoBufferWrapper
protected IoBufferWrapper(IoBuffer buf)
Create a new instance.- Parameters:
buf- the buffer to be proxied
-
-
Method Detail
-
getParentBuffer
public IoBuffer getParentBuffer()
Returns the parent buffer that this buffer wrapped.
-
isDirect
public boolean isDirect()
- Specified by:
isDirectin classIoBuffer- See Also:
ByteBuffer.isDirect()
-
buf
public ByteBuffer buf()
Description copied from class:IoBufferReturns the underlying NIO buffer instance.
-
capacity
public int capacity()
- Specified by:
capacityin classIoBuffer- See Also:
Buffer.capacity()
-
position
public int position()
- Specified by:
positionin classIoBuffer- See Also:
Buffer.position()
-
position
public IoBuffer position(int newPosition)
- Specified by:
positionin classIoBuffer- See Also:
Buffer.position(int)
-
limit
public int limit()
- Specified by:
limitin classIoBuffer- See Also:
Buffer.limit()
-
limit
public IoBuffer limit(int newLimit)
- Specified by:
limitin classIoBuffer- See Also:
Buffer.limit(int)
-
mark
public IoBuffer mark()
- Specified by:
markin classIoBuffer- See Also:
Buffer.mark()
-
reset
public IoBuffer reset()
- Specified by:
resetin classIoBuffer- See Also:
Buffer.reset()
-
clear
public IoBuffer clear()
- Specified by:
clearin classIoBuffer- See Also:
Buffer.clear()
-
sweep
public IoBuffer sweep()
Description copied from class:IoBufferClears this buffer and fills its content with NUL. The position is set to zero, the limit is set to the capacity, and the mark is discarded.
-
sweep
public IoBuffer sweep(byte value)
Description copied from class:IoBufferdouble Clears this buffer and fills its content with value. The position is set to zero, the limit is set to the capacity, and the mark is discarded.
-
flip
public IoBuffer flip()
- Specified by:
flipin classIoBuffer- See Also:
Buffer.flip()
-
rewind
public IoBuffer rewind()
- Specified by:
rewindin classIoBuffer- See Also:
Buffer.rewind()
-
remaining
public int remaining()
- Specified by:
remainingin classIoBuffer- See Also:
Buffer.remaining()
-
hasRemaining
public boolean hasRemaining()
- Specified by:
hasRemainingin classIoBuffer- See Also:
Buffer.hasRemaining()
-
get
public byte get()
- Specified by:
getin classIoBuffer- See Also:
ByteBuffer.get()
-
getUnsigned
public short getUnsigned()
Description copied from class:IoBufferReads one unsigned byte as a short integer.- Specified by:
getUnsignedin classIoBuffer
-
put
public IoBuffer put(byte b)
- Specified by:
putin classIoBuffer- See Also:
ByteBuffer.put(byte)
-
get
public byte get(int index)
- Specified by:
getin classIoBuffer- See Also:
ByteBuffer.get(int)
-
getUnsigned
public short getUnsigned(int index)
Description copied from class:IoBufferReads one byte as an unsigned short integer.- Specified by:
getUnsignedin classIoBuffer
-
put
public IoBuffer put(int index, byte b)
- Specified by:
putin classIoBuffer- See Also:
ByteBuffer.put(int, byte)
-
get
public IoBuffer get(byte[] dst, int offset, int length)
- Specified by:
getin classIoBuffer- See Also:
ByteBuffer.get(byte[], int, int)
-
getSlice
public IoBuffer getSlice(int index, int length)
Description copied from class:IoBufferTODO document me.
-
getSlice
public IoBuffer getSlice(int length)
Description copied from class:IoBufferTODO document me.
-
get
public IoBuffer get(byte[] dst)
- Specified by:
getin classIoBuffer- See Also:
ByteBuffer.get(byte[])
-
put
public IoBuffer put(IoBuffer src)
Description copied from class:IoBufferWrites the content of the specified src into this buffer.
-
put
public IoBuffer put(ByteBuffer src)
Description copied from class:IoBufferWrites the content of the specified src into this buffer.
-
put
public IoBuffer put(byte[] src, int offset, int length)
- Specified by:
putin classIoBuffer- See Also:
ByteBuffer.put(byte[], int, int)
-
put
public IoBuffer put(byte[] src)
- Specified by:
putin classIoBuffer- See Also:
ByteBuffer.put(byte[])
-
compact
public IoBuffer compact()
- Specified by:
compactin classIoBuffer- See Also:
ByteBuffer.compact()
-
compareTo
public int compareTo(IoBuffer that)
-
order
public ByteOrder order()
- Specified by:
orderin classIoBuffer- See Also:
ByteBuffer.order()
-
order
public IoBuffer order(ByteOrder bo)
- Specified by:
orderin classIoBuffer- See Also:
ByteBuffer.order(ByteOrder)
-
getChar
public char getChar()
- Specified by:
getCharin classIoBuffer- See Also:
ByteBuffer.getChar()
-
putChar
public IoBuffer putChar(char value)
- Specified by:
putCharin classIoBuffer- See Also:
ByteBuffer.putChar(char)
-
getChar
public char getChar(int index)
- Specified by:
getCharin classIoBuffer- See Also:
ByteBuffer.getChar(int)
-
putChar
public IoBuffer putChar(int index, char value)
- Specified by:
putCharin classIoBuffer- See Also:
ByteBuffer.putChar(int, char)
-
asCharBuffer
public CharBuffer asCharBuffer()
- Specified by:
asCharBufferin classIoBuffer- See Also:
ByteBuffer.asCharBuffer()
-
getShort
public short getShort()
- Specified by:
getShortin classIoBuffer- See Also:
ByteBuffer.getShort()
-
getUnsignedShort
public int getUnsignedShort()
Description copied from class:IoBufferReads two bytes unsigned integer.- Specified by:
getUnsignedShortin classIoBuffer
-
putShort
public IoBuffer putShort(short value)
- Specified by:
putShortin classIoBuffer- See Also:
ByteBuffer.putShort(short)
-
getShort
public short getShort(int index)
- Specified by:
getShortin classIoBuffer- See Also:
ByteBuffer.getShort()
-
getUnsignedShort
public int getUnsignedShort(int index)
Description copied from class:IoBufferReads two bytes unsigned integer.- Specified by:
getUnsignedShortin classIoBuffer
-
putShort
public IoBuffer putShort(int index, short value)
- Specified by:
putShortin classIoBuffer- See Also:
ByteBuffer.putShort(int, short)
-
asShortBuffer
public ShortBuffer asShortBuffer()
- Specified by:
asShortBufferin classIoBuffer- See Also:
ByteBuffer.asShortBuffer()
-
getInt
public int getInt()
- Specified by:
getIntin classIoBuffer- See Also:
ByteBuffer.getInt()
-
getUnsignedInt
public long getUnsignedInt()
Description copied from class:IoBufferReads four bytes unsigned integer.- Specified by:
getUnsignedIntin classIoBuffer
-
putInt
public IoBuffer putInt(int value)
- Specified by:
putIntin classIoBuffer- See Also:
ByteBuffer.putInt(int)
-
getInt
public int getInt(int index)
- Specified by:
getIntin classIoBuffer- See Also:
ByteBuffer.getInt(int)
-
getUnsignedInt
public long getUnsignedInt(int index)
Description copied from class:IoBufferReads four bytes unsigned integer.- Specified by:
getUnsignedIntin classIoBuffer
-
putInt
public IoBuffer putInt(int index, int value)
- Specified by:
putIntin classIoBuffer- See Also:
ByteBuffer.putInt(int, int)
-
asIntBuffer
public IntBuffer asIntBuffer()
- Specified by:
asIntBufferin classIoBuffer- See Also:
ByteBuffer.asIntBuffer()
-
getLong
public long getLong()
- Specified by:
getLongin classIoBuffer- See Also:
ByteBuffer.getLong()
-
putLong
public IoBuffer putLong(long value)
- Specified by:
putLongin classIoBuffer- See Also:
ByteBuffer.putLong(int, long)
-
getLong
public long getLong(int index)
- Specified by:
getLongin classIoBuffer- See Also:
ByteBuffer.getLong(int)
-
putLong
public IoBuffer putLong(int index, long value)
- Specified by:
putLongin classIoBuffer- See Also:
ByteBuffer.putLong(int, long)
-
asLongBuffer
public LongBuffer asLongBuffer()
- Specified by:
asLongBufferin classIoBuffer- See Also:
ByteBuffer.asLongBuffer()
-
getFloat
public float getFloat()
- Specified by:
getFloatin classIoBuffer- See Also:
ByteBuffer.getFloat()
-
putFloat
public IoBuffer putFloat(float value)
- Specified by:
putFloatin classIoBuffer- See Also:
ByteBuffer.putFloat(float)
-
getFloat
public float getFloat(int index)
- Specified by:
getFloatin classIoBuffer- See Also:
ByteBuffer.getFloat(int)
-
putFloat
public IoBuffer putFloat(int index, float value)
- Specified by:
putFloatin classIoBuffer- See Also:
ByteBuffer.putFloat(int, float)
-
asFloatBuffer
public FloatBuffer asFloatBuffer()
- Specified by:
asFloatBufferin classIoBuffer- See Also:
ByteBuffer.asFloatBuffer()
-
getDouble
public double getDouble()
- Specified by:
getDoublein classIoBuffer- See Also:
ByteBuffer.getDouble()
-
putDouble
public IoBuffer putDouble(double value)
- Specified by:
putDoublein classIoBuffer- See Also:
ByteBuffer.putDouble(double)
-
getDouble
public double getDouble(int index)
- Specified by:
getDoublein classIoBuffer- See Also:
ByteBuffer.getDouble(int)
-
putDouble
public IoBuffer putDouble(int index, double value)
- Specified by:
putDoublein classIoBuffer- See Also:
ByteBuffer.putDouble(int, double)
-
asDoubleBuffer
public DoubleBuffer asDoubleBuffer()
- Specified by:
asDoubleBufferin classIoBuffer- See Also:
ByteBuffer.asDoubleBuffer()
-
getHexDump
public String getHexDump()
Description copied from class:IoBufferReturns hexdump of this buffer. The data and pointer are not changed as a result of this method call.- Specified by:
getHexDumpin classIoBuffer- Returns:
- hexidecimal representation of this buffer
-
getString
public String getString(int fieldSize, CharsetDecoder decoder) throws CharacterCodingException
Description copied from class:IoBufferReads aNUL-terminated string from this buffer using the specifieddecoderand returns it.- Specified by:
getStringin classIoBuffer- Parameters:
fieldSize- the maximum number of bytes to read- Throws:
CharacterCodingException
-
getString
public String getString(CharsetDecoder decoder) throws CharacterCodingException
Description copied from class:IoBufferReads aNUL-terminated string from this buffer using the specifieddecoderand returns it. This method reads until the limit of this buffer if no NUL is found.- Specified by:
getStringin classIoBuffer- Throws:
CharacterCodingException
-
getPrefixedString
public String getPrefixedString(CharsetDecoder decoder) throws CharacterCodingException
Description copied from class:IoBufferReads a string which has a 16-bit length field before the actual encoded string, using the specifieddecoderand returns it. This method is a shortcut for getPrefixedString(2, decoder).- Specified by:
getPrefixedStringin classIoBuffer- Throws:
CharacterCodingException
-
getPrefixedString
public String getPrefixedString(int prefixLength, CharsetDecoder decoder) throws CharacterCodingException
Description copied from class:IoBufferReads a string which has a length field before the actual encoded string, using the specifieddecoderand returns it.- Specified by:
getPrefixedStringin classIoBuffer- Parameters:
prefixLength- the length of the length field (1, 2, or 4)- Throws:
CharacterCodingException
-
putString
public IoBuffer putString(CharSequence in, int fieldSize, CharsetEncoder encoder) throws CharacterCodingException
Description copied from class:IoBufferWrites the content ofininto this buffer as aNUL-terminated string using the specifiedencoder.If the charset name of the encoder is UTF-16, you cannot specify odd
fieldSize, and this method will append twoNULs as a terminator.Please note that this method doesn't terminate with
NULif the input string is longer than fieldSize.- Specified by:
putStringin classIoBufferfieldSize- the maximum number of bytes to write- Throws:
CharacterCodingException
-
putString
public IoBuffer putString(CharSequence in, CharsetEncoder encoder) throws CharacterCodingException
Description copied from class:IoBufferWrites the content ofininto this buffer using the specifiedencoder. This method doesn't terminate string with NUL. You have to do it by yourself.- Specified by:
putStringin classIoBuffer- Throws:
CharacterCodingException
-
putPrefixedString
public IoBuffer putPrefixedString(CharSequence in, CharsetEncoder encoder) throws CharacterCodingException
Description copied from class:IoBufferWrites the content ofininto this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder. This method is a shortcut for putPrefixedString(in, 2, 0, encoder).- Specified by:
putPrefixedStringin classIoBuffer- Throws:
CharacterCodingException
-
putPrefixedString
public IoBuffer putPrefixedString(CharSequence in, int prefixLength, CharsetEncoder encoder) throws CharacterCodingException
Description copied from class:IoBufferWrites the content ofininto this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder. This method is a shortcut for putPrefixedString(in, prefixLength, 0, encoder).- Specified by:
putPrefixedStringin classIoBufferprefixLength- the length of the length field (1, 2, or 4)- Throws:
CharacterCodingException
-
putPrefixedString
public IoBuffer putPrefixedString(CharSequence in, int prefixLength, int padding, CharsetEncoder encoder) throws CharacterCodingException
Description copied from class:IoBufferWrites the content ofininto this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder. This method is a shortcut for putPrefixedString(in, prefixLength, padding, ( byte ) 0, encoder) .- Specified by:
putPrefixedStringin classIoBufferprefixLength- the length of the length field (1, 2, or 4)padding- the number of padded NULs (1 (or 0), 2, or 4)- Throws:
CharacterCodingException
-
putPrefixedString
public IoBuffer putPrefixedString(CharSequence in, int prefixLength, int padding, byte padValue, CharsetEncoder encoder) throws CharacterCodingException
Description copied from class:IoBufferWrites the content ofininto this buffer as a string which has a 16-bit length field before the actual encoded string, using the specifiedencoder.- Specified by:
putPrefixedStringin classIoBufferprefixLength- the length of the length field (1, 2, or 4)padding- the number of padded bytes (1 (or 0), 2, or 4)padValue- the value of padded bytes- Throws:
CharacterCodingException
-
skip
public IoBuffer skip(int size)
Description copied from class:IoBufferForwards the position of this buffer as the specifiedsizebytes.
-
fill
public IoBuffer fill(byte value, int size)
Description copied from class:IoBufferFills this buffer with the specified value. This method moves buffer position forward.
-
fillAndReset
public IoBuffer fillAndReset(byte value, int size)
Description copied from class:IoBufferFills this buffer with the specified value. This method does not change buffer position.- Specified by:
fillAndResetin classIoBuffer
-
fill
public IoBuffer fill(int size)
Description copied from class:IoBufferFills this buffer withNUL (0x00). This method moves buffer position forward.
-
fillAndReset
public IoBuffer fillAndReset(int size)
Description copied from class:IoBufferFills this buffer withNUL (0x00). This method does not change buffer position.- Specified by:
fillAndResetin classIoBuffer
-
isAutoExpand
public boolean isAutoExpand()
Description copied from class:IoBufferReturns true if and only if autoExpand is turned on.- Specified by:
isAutoExpandin classIoBuffer
-
setAutoExpand
public IoBuffer setAutoExpand(boolean autoExpand)
Description copied from class:IoBufferTurns on or off autoExpand.- Specified by:
setAutoExpandin classIoBuffer
-
expand
public IoBuffer expand(int pos, int expectedRemaining)
Description copied from class:IoBufferChanges the capacity and limit of this buffer so this buffer get the specified expectedRemaining room from the specified position. This method works even if you didn't set autoExpand to true.
-
expand
public IoBuffer expand(int expectedRemaining)
Description copied from class:IoBufferChanges the capacity and limit of this buffer so this buffer get the specified expectedRemaining room from the current position. This method works even if you didn't set autoExpand to true.
-
getObject
public Object getObject() throws ClassNotFoundException
Description copied from class:IoBufferReads a Java object from the buffer using the contextClassLoaderof the current thread.- Specified by:
getObjectin classIoBuffer- Throws:
ClassNotFoundException
-
getObject
public Object getObject(ClassLoader classLoader) throws ClassNotFoundException
Description copied from class:IoBufferReads a Java object from the buffer using the specified classLoader.- Specified by:
getObjectin classIoBuffer- Throws:
ClassNotFoundException
-
putObject
public IoBuffer putObject(Object o)
Description copied from class:IoBufferWrites the specified Java object to the buffer.
-
asInputStream
public InputStream asInputStream()
Description copied from class:IoBufferReturns anInputStreamthat reads the data from this buffer.InputStream.read()returns -1 if the buffer position reaches to the limit.- Specified by:
asInputStreamin classIoBuffer
-
asOutputStream
public OutputStream asOutputStream()
Description copied from class:IoBufferReturns anOutputStreamthat appends the data into this buffer. Please note that theOutputStream.write(int)will throw aBufferOverflowExceptioninstead of anIOExceptionin case of buffer overflow. Please set autoExpand property by callingIoBuffer.setAutoExpand(boolean)to prevent the unexpected runtime exception.- Specified by:
asOutputStreamin classIoBuffer
-
duplicate
public IoBuffer duplicate()
- Specified by:
duplicatein classIoBuffer- See Also:
ByteBuffer.duplicate()
-
slice
public IoBuffer slice()
- Specified by:
slicein classIoBuffer- See Also:
ByteBuffer.slice()
-
asReadOnlyBuffer
public IoBuffer asReadOnlyBuffer()
- Specified by:
asReadOnlyBufferin classIoBuffer- See Also:
ByteBuffer.asReadOnlyBuffer()
-
array
public byte[] array()
- Specified by:
arrayin classIoBuffer- See Also:
ByteBuffer.array()
-
arrayOffset
public int arrayOffset()
- Specified by:
arrayOffsetin classIoBuffer- See Also:
ByteBuffer.arrayOffset()
-
minimumCapacity
public int minimumCapacity()
Description copied from class:IoBufferReturns the minimum capacity of this buffer which is used to determine the new capacity of the buffer shrunk byIoBuffer.compact()andIoBuffer.shrink()operation. The default value is the initial capacity of the buffer.- Specified by:
minimumCapacityin classIoBuffer
-
minimumCapacity
public IoBuffer minimumCapacity(int minimumCapacity)
Description copied from class:IoBufferSets the minimum capacity of this buffer which is used to determine the new capacity of the buffer shrunk byIoBuffer.compact()andIoBuffer.shrink()operation. The default value is the initial capacity of the buffer.- Specified by:
minimumCapacityin classIoBuffer
-
capacity
public IoBuffer capacity(int newCapacity)
Description copied from class:IoBufferIncreases the capacity of this buffer. If the new capacity is less than or equal to the current capacity, this method returns silently. If the new capacity is greater than the current capacity, the buffer is reallocated while retaining the position, limit, mark and the content of the buffer.
-
isReadOnly
public boolean isReadOnly()
- Specified by:
isReadOnlyin classIoBuffer- See Also:
Buffer.isReadOnly()
-
markValue
public int markValue()
Description copied from class:IoBufferReturns the position of the current mark. This method returns -1 if no mark is set.
-
hasArray
public boolean hasArray()
- Specified by:
hasArrayin classIoBuffer- See Also:
ByteBuffer.hasArray()
-
free
public void free()
Description copied from class:IoBufferDeclares this buffer and all its derived buffers are not used anymore so that it can be reused by someIoBufferAllocatorimplementations. It is not mandatory to call this method, but you might want to invoke this method for maximum performance.
-
isDerived
public boolean isDerived()
Description copied from class:IoBufferreturns true if and only if this buffer is derived from other buffer viaIoBuffer.duplicate(),IoBuffer.slice()orIoBuffer.asReadOnlyBuffer().
-
isAutoShrink
public boolean isAutoShrink()
Description copied from class:IoBufferReturns true if and only if autoShrink is turned on.- Specified by:
isAutoShrinkin classIoBuffer
-
setAutoShrink
public IoBuffer setAutoShrink(boolean autoShrink)
Description copied from class:IoBufferTurns on or off autoShrink.- Specified by:
setAutoShrinkin classIoBuffer
-
shrink
public IoBuffer shrink()
Description copied from class:IoBufferChanges the capacity of this buffer so this buffer occupies as less memory as possible while retaining the position, limit and the buffer content between the position and limit. The capacity of the buffer never becomes less thanIoBuffer.minimumCapacity(). The mark is discarded once the capacity changes.
-
getMediumInt
public int getMediumInt()
Description copied from class:IoBufferRelative get method for reading a medium int value.Reads the next three bytes at this buffer's current position, composing them into an int value according to the current byte order, and then increments the position by three.
- Specified by:
getMediumIntin classIoBuffer- Returns:
- The medium int value at the buffer's current position
-
getUnsignedMediumInt
public int getUnsignedMediumInt()
Description copied from class:IoBufferRelative get method for reading an unsigned medium int value.Reads the next three bytes at this buffer's current position, composing them into an int value according to the current byte order, and then increments the position by three.
- Specified by:
getUnsignedMediumIntin classIoBuffer- Returns:
- The unsigned medium int value at the buffer's current position
-
getMediumInt
public int getMediumInt(int index)
Description copied from class:IoBufferAbsolute get method for reading a medium int value.Reads the next three bytes at this buffer's current position, composing them into an int value according to the current byte order.
- Specified by:
getMediumIntin classIoBuffer- Parameters:
index- The index from which the medium int will be read- Returns:
- The medium int value at the given index
-
getUnsignedMediumInt
public int getUnsignedMediumInt(int index)
Description copied from class:IoBufferAbsolute get method for reading an unsigned medium int value.Reads the next three bytes at this buffer's current position, composing them into an int value according to the current byte order.
- Specified by:
getUnsignedMediumIntin classIoBuffer- Parameters:
index- The index from which the unsigned medium int will be read- Returns:
- The unsigned medium int value at the given index
-
putMediumInt
public IoBuffer putMediumInt(int value)
Description copied from class:IoBufferRelative put method for writing a medium int value.Writes three bytes containing the given int value, in the current byte order, into this buffer at the current position, and then increments the position by three.
- Specified by:
putMediumIntin classIoBuffer- Parameters:
value- The medium int value to be written- Returns:
- This buffer
-
putMediumInt
public IoBuffer putMediumInt(int index, int value)
Description copied from class:IoBufferAbsolute put method for writing a medium int value.Writes three bytes containing the given int value, in the current byte order, into this buffer at the given index.
- Specified by:
putMediumIntin classIoBuffer- Parameters:
index- The index at which the bytes will be writtenvalue- The medium int value to be written- Returns:
- This buffer
-
getHexDump
public String getHexDump(int lengthLimit)
Description copied from class:IoBufferReturn hexdump of this buffer with limited length.- Specified by:
getHexDumpin classIoBuffer- Parameters:
lengthLimit- The maximum number of bytes to dump from the current buffer position.- Returns:
- hexidecimal representation of this buffer
-
prefixedDataAvailable
public boolean prefixedDataAvailable(int prefixLength)
Description copied from class:IoBufferReturns true if this buffer contains a data which has a data length as a prefix and the buffer has remaining data as enough as specified in the data length field. This method is identical with prefixedDataAvailable( prefixLength, Integer.MAX_VALUE ). Please not that using this method can allow DoS (Denial of Service) attack in case the remote peer sends too big data length value. It is recommended to useIoBuffer.prefixedDataAvailable(int, int)instead.- Specified by:
prefixedDataAvailablein classIoBuffer- Parameters:
prefixLength- the length of the prefix field (1, 2, or 4)
-
prefixedDataAvailable
public boolean prefixedDataAvailable(int prefixLength, int maxDataLength)Description copied from class:IoBufferReturns true if this buffer contains a data which has a data length as a prefix and the buffer has remaining data as enough as specified in the data length field.- Specified by:
prefixedDataAvailablein classIoBuffer- Parameters:
prefixLength- the length of the prefix field (1, 2, or 4)maxDataLength- the allowed maximum of the read data length
-
indexOf
public int indexOf(byte b)
Description copied from class:IoBufferReturns the first occurence position of the specified byte from the current position to the current limit.
-
getEnum
public <E extends Enum<E>> E getEnum(Class<E> enumClass)
Description copied from class:IoBufferReads a byte from the buffer and returns the correlating enum constant defined by the specified enum type.
-
getEnum
public <E extends Enum<E>> E getEnum(int index, Class<E> enumClass)
Description copied from class:IoBufferReads a byte from the buffer and returns the correlating enum constant defined by the specified enum type.
-
getEnumShort
public <E extends Enum<E>> E getEnumShort(Class<E> enumClass)
Description copied from class:IoBufferReads a short from the buffer and returns the correlating enum constant defined by the specified enum type.- Specified by:
getEnumShortin classIoBuffer- Type Parameters:
E- The enum type to return- Parameters:
enumClass- The enum's class object
-
getEnumShort
public <E extends Enum<E>> E getEnumShort(int index, Class<E> enumClass)
Description copied from class:IoBufferReads a short from the buffer and returns the correlating enum constant defined by the specified enum type.- Specified by:
getEnumShortin classIoBuffer- Type Parameters:
E- The enum type to return- Parameters:
index- the index from which the bytes will be readenumClass- The enum's class object
-
getEnumInt
public <E extends Enum<E>> E getEnumInt(Class<E> enumClass)
Description copied from class:IoBufferReads an int from the buffer and returns the correlating enum constant defined by the specified enum type.- Specified by:
getEnumIntin classIoBuffer- Type Parameters:
E- The enum type to return- Parameters:
enumClass- The enum's class object
-
getEnumInt
public <E extends Enum<E>> E getEnumInt(int index, Class<E> enumClass)
Description copied from class:IoBufferReads an int from the buffer and returns the correlating enum constant defined by the specified enum type.- Specified by:
getEnumIntin classIoBuffer- Type Parameters:
E- The enum type to return- Parameters:
index- the index from which the bytes will be readenumClass- The enum's class object
-
putEnum
public IoBuffer putEnum(Enum<?> e)
Description copied from class:IoBufferWrites an enum's ordinal value to the buffer as a byte.
-
putEnum
public IoBuffer putEnum(int index, Enum<?> e)
Description copied from class:IoBufferWrites an enum's ordinal value to the buffer as a byte.
-
putEnumShort
public IoBuffer putEnumShort(Enum<?> e)
Description copied from class:IoBufferWrites an enum's ordinal value to the buffer as a short.- Specified by:
putEnumShortin classIoBuffer- Parameters:
e- The enum to write to the buffer
-
putEnumShort
public IoBuffer putEnumShort(int index, Enum<?> e)
Description copied from class:IoBufferWrites an enum's ordinal value to the buffer as a short.- Specified by:
putEnumShortin classIoBuffer- Parameters:
index- The index at which the bytes will be writtene- The enum to write to the buffer
-
putEnumInt
public IoBuffer putEnumInt(Enum<?> e)
Description copied from class:IoBufferWrites an enum's ordinal value to the buffer as an integer.- Specified by:
putEnumIntin classIoBuffer- Parameters:
e- The enum to write to the buffer
-
putEnumInt
public IoBuffer putEnumInt(int index, Enum<?> e)
Description copied from class:IoBufferWrites an enum's ordinal value to the buffer as an integer.- Specified by:
putEnumIntin classIoBuffer- Parameters:
index- The index at which the bytes will be writtene- The enum to write to the buffer
-
getEnumSet
public <E extends Enum<E>> EnumSet<E> getEnumSet(Class<E> enumClass)
Description copied from class:IoBufferReads a byte sized bit vector and converts it to anEnumSet.Each bit is mapped to a value in the specified enum. The least significant bit maps to the first entry in the specified enum and each subsequent bit maps to each subsequent bit as mapped to the subsequent enum value.
- Specified by:
getEnumSetin classIoBuffer- Type Parameters:
E- the enum type- Parameters:
enumClass- the enum class used to create the EnumSet- Returns:
- the EnumSet representation of the bit vector
-
getEnumSet
public <E extends Enum<E>> EnumSet<E> getEnumSet(int index, Class<E> enumClass)
Description copied from class:IoBufferReads a byte sized bit vector and converts it to anEnumSet.- Specified by:
getEnumSetin classIoBuffer- Type Parameters:
E- the enum type- Parameters:
index- the index from which the byte will be readenumClass- the enum class used to create the EnumSet- Returns:
- the EnumSet representation of the bit vector
- See Also:
IoBuffer.getEnumSet(Class)
-
getEnumSetShort
public <E extends Enum<E>> EnumSet<E> getEnumSetShort(Class<E> enumClass)
Description copied from class:IoBufferReads a short sized bit vector and converts it to anEnumSet.- Specified by:
getEnumSetShortin classIoBuffer- Type Parameters:
E- the enum type- Parameters:
enumClass- the enum class used to create the EnumSet- Returns:
- the EnumSet representation of the bit vector
- See Also:
IoBuffer.getEnumSet(Class)
-
getEnumSetShort
public <E extends Enum<E>> EnumSet<E> getEnumSetShort(int index, Class<E> enumClass)
Description copied from class:IoBufferReads a short sized bit vector and converts it to anEnumSet.- Specified by:
getEnumSetShortin classIoBuffer- Type Parameters:
E- the enum type- Parameters:
index- the index from which the bytes will be readenumClass- the enum class used to create the EnumSet- Returns:
- the EnumSet representation of the bit vector
- See Also:
IoBuffer.getEnumSet(Class)
-
getEnumSetInt
public <E extends Enum<E>> EnumSet<E> getEnumSetInt(Class<E> enumClass)
Description copied from class:IoBufferReads an int sized bit vector and converts it to anEnumSet.- Specified by:
getEnumSetIntin classIoBuffer- Type Parameters:
E- the enum type- Parameters:
enumClass- the enum class used to create the EnumSet- Returns:
- the EnumSet representation of the bit vector
- See Also:
IoBuffer.getEnumSet(Class)
-
getEnumSetInt
public <E extends Enum<E>> EnumSet<E> getEnumSetInt(int index, Class<E> enumClass)
Description copied from class:IoBufferReads an int sized bit vector and converts it to anEnumSet.- Specified by:
getEnumSetIntin classIoBuffer- Type Parameters:
E- the enum type- Parameters:
index- the index from which the bytes will be readenumClass- the enum class used to create the EnumSet- Returns:
- the EnumSet representation of the bit vector
- See Also:
IoBuffer.getEnumSet(Class)
-
getEnumSetLong
public <E extends Enum<E>> EnumSet<E> getEnumSetLong(Class<E> enumClass)
Description copied from class:IoBufferReads a long sized bit vector and converts it to anEnumSet.- Specified by:
getEnumSetLongin classIoBuffer- Type Parameters:
E- the enum type- Parameters:
enumClass- the enum class used to create the EnumSet- Returns:
- the EnumSet representation of the bit vector
- See Also:
IoBuffer.getEnumSet(Class)
-
getEnumSetLong
public <E extends Enum<E>> EnumSet<E> getEnumSetLong(int index, Class<E> enumClass)
Description copied from class:IoBufferReads a long sized bit vector and converts it to anEnumSet.- Specified by:
getEnumSetLongin classIoBuffer- Type Parameters:
E- the enum type- Parameters:
index- the index from which the bytes will be readenumClass- the enum class used to create the EnumSet- Returns:
- the EnumSet representation of the bit vector
- See Also:
IoBuffer.getEnumSet(Class)
-
putEnumSet
public <E extends Enum<E>> IoBuffer putEnumSet(Set<E> set)
Description copied from class:IoBufferWrites the specifiedSetto the buffer as a byte sized bit vector.- Specified by:
putEnumSetin classIoBuffer- Type Parameters:
E- the enum type of the Set- Parameters:
set- the enum set to write to the buffer
-
putEnumSet
public <E extends Enum<E>> IoBuffer putEnumSet(int index, Set<E> set)
Description copied from class:IoBufferWrites the specifiedSetto the buffer as a byte sized bit vector.- Specified by:
putEnumSetin classIoBuffer- Type Parameters:
E- the enum type of the Set- Parameters:
index- the index at which the byte will be writtenset- the enum set to write to the buffer
-
putEnumSetShort
public <E extends Enum<E>> IoBuffer putEnumSetShort(Set<E> set)
Description copied from class:IoBufferWrites the specifiedSetto the buffer as a short sized bit vector.- Specified by:
putEnumSetShortin classIoBuffer- Type Parameters:
E- the enum type of the Set- Parameters:
set- the enum set to write to the buffer
-
putEnumSetShort
public <E extends Enum<E>> IoBuffer putEnumSetShort(int index, Set<E> set)
Description copied from class:IoBufferWrites the specifiedSetto the buffer as a short sized bit vector.- Specified by:
putEnumSetShortin classIoBuffer- Type Parameters:
E- the enum type of the Set- Parameters:
index- the index at which the bytes will be writtenset- the enum set to write to the buffer
-
putEnumSetInt
public <E extends Enum<E>> IoBuffer putEnumSetInt(Set<E> set)
Description copied from class:IoBufferWrites the specifiedSetto the buffer as an int sized bit vector.- Specified by:
putEnumSetIntin classIoBuffer- Type Parameters:
E- the enum type of the Set- Parameters:
set- the enum set to write to the buffer
-
putEnumSetInt
public <E extends Enum<E>> IoBuffer putEnumSetInt(int index, Set<E> set)
Description copied from class:IoBufferWrites the specifiedSetto the buffer as an int sized bit vector.- Specified by:
putEnumSetIntin classIoBuffer- Type Parameters:
E- the enum type of the Set- Parameters:
index- the index at which the bytes will be writtenset- the enum set to write to the buffer
-
putEnumSetLong
public <E extends Enum<E>> IoBuffer putEnumSetLong(Set<E> set)
Description copied from class:IoBufferWrites the specifiedSetto the buffer as a long sized bit vector.- Specified by:
putEnumSetLongin classIoBuffer- Type Parameters:
E- the enum type of the Set- Parameters:
set- the enum set to write to the buffer
-
putEnumSetLong
public <E extends Enum<E>> IoBuffer putEnumSetLong(int index, Set<E> set)
Description copied from class:IoBufferWrites the specifiedSetto the buffer as a long sized bit vector.- Specified by:
putEnumSetLongin classIoBuffer- Type Parameters:
E- the enum type of the Set- Parameters:
index- the index at which the bytes will be writtenset- the enum set to write to the buffer
-
-