Package org.apache.mina.common.support
Class BaseByteBuffer
- java.lang.Object
-
- org.apache.mina.common.ByteBuffer
-
- org.apache.mina.common.support.BaseByteBuffer
-
- All Implemented Interfaces:
java.lang.Comparable<ByteBuffer>
public abstract class BaseByteBuffer extends ByteBuffer
A base implementation ofByteBuffer. This implementation assumes thatByteBuffer.buf()always returns a correct NIOByteBufferinstance. Most implementations could extend this class and implement their own buffer management mechanism.- See Also:
ByteBufferAllocator
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseByteBuffer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.nio.CharBufferasCharBuffer()java.nio.DoubleBufferasDoubleBuffer()java.nio.FloatBufferasFloatBuffer()java.nio.IntBufferasIntBuffer()java.nio.LongBufferasLongBuffer()java.nio.ShortBufferasShortBuffer()intcapacity()ByteBuffercapacity(int newCapacity)Changes the capacity of this buffer.protected abstract voidcapacity0(int newCapacity)Implement this method to increase the capacity of this buffer.ByteBufferclear()ByteBuffercompact()ByteBufferexpand(int pos, int expectedRemaining)Changes the capacity and limit of this buffer so this buffer get the specified expectedRemaining room from the specified pos.ByteBufferflip()byteget()ByteBufferget(byte[] dst, int offset, int length)byteget(int index)chargetChar()chargetChar(int index)doublegetDouble()doublegetDouble(int index)floatgetFloat()floatgetFloat(int index)intgetInt()intgetInt(int index)longgetLong()longgetLong(int index)shortgetShort()shortgetShort(int index)booleanisAutoExpand()Returns true if and only if autoExpand is turned on.booleanisDirect()booleanisReadOnly()intlimit()ByteBufferlimit(int newLimit)ByteBuffermark()intmarkValue()Returns the position of the current mark.java.nio.ByteOrderorder()ByteBufferorder(java.nio.ByteOrder bo)intposition()ByteBufferposition(int newPosition)ByteBufferput(byte b)ByteBufferput(byte[] src, int offset, int length)ByteBufferput(int index, byte b)ByteBufferput(java.nio.ByteBuffer src)Writes the content of the specified src into this buffer.ByteBufferputChar(char value)ByteBufferputChar(int index, char value)ByteBufferputDouble(double value)ByteBufferputDouble(int index, double value)ByteBufferputFloat(float value)ByteBufferputFloat(int index, float value)ByteBufferputInt(int value)ByteBufferputInt(int index, int value)ByteBufferputLong(int index, long value)ByteBufferputLong(long value)ByteBufferputShort(int index, short value)ByteBufferputShort(short value)ByteBufferreset()ByteBufferrewind()ByteBuffersetAutoExpand(boolean autoExpand)Turns on or off autoExpand.-
Methods inherited from class org.apache.mina.common.ByteBuffer
acquire, allocate, allocate, array, arrayOffset, asInputStream, asOutputStream, asReadOnlyBuffer, autoExpand, autoExpand, buf, compareTo, duplicate, equals, expand, fill, fill, fillAndReset, fillAndReset, get, getAllocator, getHexDump, getObject, getObject, getPrefixedString, getPrefixedString, getString, getString, getUnsigned, getUnsigned, getUnsignedInt, getUnsignedInt, getUnsignedShort, getUnsignedShort, hashCode, hasRemaining, isPooled, isUseDirectBuffers, prefixedDataAvailable, prefixedDataAvailable, put, put, putObject, putPrefixedString, putPrefixedString, putPrefixedString, putPrefixedString, putString, putString, release, remaining, setAllocator, setPooled, setUseDirectBuffers, skip, slice, sweep, sweep, toString, wrap, wrap, wrap
-
-
-
-
Method Detail
-
isDirect
public boolean isDirect()
- Specified by:
isDirectin classByteBuffer- See Also:
ByteBuffer.isDirect()
-
isReadOnly
public boolean isReadOnly()
- Specified by:
isReadOnlyin classByteBuffer- See Also:
Buffer.isReadOnly()
-
capacity
public int capacity()
- Specified by:
capacityin classByteBuffer- See Also:
Buffer.capacity()
-
capacity
public ByteBuffer capacity(int newCapacity)
Description copied from class:ByteBufferChanges the capacity of this buffer.- Specified by:
capacityin classByteBuffer
-
capacity0
protected abstract void capacity0(int newCapacity)
Implement this method to increase the capacity of this buffer. newCapacity is always greater than the current capacity.
-
isAutoExpand
public boolean isAutoExpand()
Description copied from class:ByteBufferReturns true if and only if autoExpand is turned on.- Specified by:
isAutoExpandin classByteBuffer
-
setAutoExpand
public ByteBuffer setAutoExpand(boolean autoExpand)
Description copied from class:ByteBufferTurns on or off autoExpand.- Specified by:
setAutoExpandin classByteBuffer
-
expand
public ByteBuffer expand(int pos, int expectedRemaining)
Description copied from class:ByteBufferChanges the capacity and limit of this buffer so this buffer get the specified expectedRemaining room from the specified pos. This method works even if you didn't set autoExpand to true.- Specified by:
expandin classByteBuffer
-
position
public int position()
- Specified by:
positionin classByteBuffer- See Also:
Buffer.position()
-
position
public ByteBuffer position(int newPosition)
- Specified by:
positionin classByteBuffer- See Also:
Buffer.position(int)
-
limit
public int limit()
- Specified by:
limitin classByteBuffer- See Also:
Buffer.limit()
-
limit
public ByteBuffer limit(int newLimit)
- Specified by:
limitin classByteBuffer- See Also:
Buffer.limit(int)
-
mark
public ByteBuffer mark()
- Specified by:
markin classByteBuffer- See Also:
Buffer.mark()
-
markValue
public int markValue()
Description copied from class:ByteBufferReturns the position of the current mark. This method returns -1 if no mark is set.- Specified by:
markValuein classByteBuffer
-
reset
public ByteBuffer reset()
- Specified by:
resetin classByteBuffer- See Also:
Buffer.reset()
-
clear
public ByteBuffer clear()
- Specified by:
clearin classByteBuffer- See Also:
Buffer.clear()
-
flip
public ByteBuffer flip()
- Specified by:
flipin classByteBuffer- See Also:
Buffer.flip()
-
rewind
public ByteBuffer rewind()
- Specified by:
rewindin classByteBuffer- See Also:
Buffer.rewind()
-
get
public byte get()
- Specified by:
getin classByteBuffer- See Also:
ByteBuffer.get()
-
put
public ByteBuffer put(byte b)
- Specified by:
putin classByteBuffer- See Also:
ByteBuffer.put(byte)
-
get
public byte get(int index)
- Specified by:
getin classByteBuffer- See Also:
ByteBuffer.get(int)
-
put
public ByteBuffer put(int index, byte b)
- Specified by:
putin classByteBuffer- See Also:
ByteBuffer.put(int, byte)
-
get
public ByteBuffer get(byte[] dst, int offset, int length)
- Specified by:
getin classByteBuffer- See Also:
ByteBuffer.get(byte[], int, int)
-
put
public ByteBuffer put(java.nio.ByteBuffer src)
Description copied from class:ByteBufferWrites the content of the specified src into this buffer.- Specified by:
putin classByteBuffer
-
put
public ByteBuffer put(byte[] src, int offset, int length)
- Specified by:
putin classByteBuffer- See Also:
ByteBuffer.put(byte[], int, int)
-
compact
public ByteBuffer compact()
- Specified by:
compactin classByteBuffer- See Also:
ByteBuffer.compact()
-
order
public java.nio.ByteOrder order()
- Specified by:
orderin classByteBuffer- See Also:
ByteBuffer.order()
-
order
public ByteBuffer order(java.nio.ByteOrder bo)
- Specified by:
orderin classByteBuffer- See Also:
ByteBuffer.order(ByteOrder)
-
getChar
public char getChar()
- Specified by:
getCharin classByteBuffer- See Also:
ByteBuffer.getChar()
-
putChar
public ByteBuffer putChar(char value)
- Specified by:
putCharin classByteBuffer- See Also:
ByteBuffer.putChar(char)
-
getChar
public char getChar(int index)
- Specified by:
getCharin classByteBuffer- See Also:
ByteBuffer.getChar(int)
-
putChar
public ByteBuffer putChar(int index, char value)
- Specified by:
putCharin classByteBuffer- See Also:
ByteBuffer.putChar(int, char)
-
asCharBuffer
public java.nio.CharBuffer asCharBuffer()
- Specified by:
asCharBufferin classByteBuffer- See Also:
ByteBuffer.asCharBuffer()
-
getShort
public short getShort()
- Specified by:
getShortin classByteBuffer- See Also:
ByteBuffer.getShort()
-
putShort
public ByteBuffer putShort(short value)
- Specified by:
putShortin classByteBuffer- See Also:
ByteBuffer.putShort(short)
-
getShort
public short getShort(int index)
- Specified by:
getShortin classByteBuffer- See Also:
ByteBuffer.getShort()
-
putShort
public ByteBuffer putShort(int index, short value)
- Specified by:
putShortin classByteBuffer- See Also:
ByteBuffer.putShort(int, short)
-
asShortBuffer
public java.nio.ShortBuffer asShortBuffer()
- Specified by:
asShortBufferin classByteBuffer- See Also:
ByteBuffer.asShortBuffer()
-
getInt
public int getInt()
- Specified by:
getIntin classByteBuffer- See Also:
ByteBuffer.getInt()
-
putInt
public ByteBuffer putInt(int value)
- Specified by:
putIntin classByteBuffer- See Also:
ByteBuffer.putInt(int)
-
getInt
public int getInt(int index)
- Specified by:
getIntin classByteBuffer- See Also:
ByteBuffer.getInt(int)
-
putInt
public ByteBuffer putInt(int index, int value)
- Specified by:
putIntin classByteBuffer- See Also:
ByteBuffer.putInt(int, int)
-
asIntBuffer
public java.nio.IntBuffer asIntBuffer()
- Specified by:
asIntBufferin classByteBuffer- See Also:
ByteBuffer.asIntBuffer()
-
getLong
public long getLong()
- Specified by:
getLongin classByteBuffer- See Also:
ByteBuffer.getLong()
-
putLong
public ByteBuffer putLong(long value)
- Specified by:
putLongin classByteBuffer- See Also:
ByteBuffer.putLong(int, long)
-
getLong
public long getLong(int index)
- Specified by:
getLongin classByteBuffer- See Also:
ByteBuffer.getLong(int)
-
putLong
public ByteBuffer putLong(int index, long value)
- Specified by:
putLongin classByteBuffer- See Also:
ByteBuffer.putLong(int, long)
-
asLongBuffer
public java.nio.LongBuffer asLongBuffer()
- Specified by:
asLongBufferin classByteBuffer- See Also:
ByteBuffer.asLongBuffer()
-
getFloat
public float getFloat()
- Specified by:
getFloatin classByteBuffer- See Also:
ByteBuffer.getFloat()
-
putFloat
public ByteBuffer putFloat(float value)
- Specified by:
putFloatin classByteBuffer- See Also:
ByteBuffer.putFloat(float)
-
getFloat
public float getFloat(int index)
- Specified by:
getFloatin classByteBuffer- See Also:
ByteBuffer.getFloat(int)
-
putFloat
public ByteBuffer putFloat(int index, float value)
- Specified by:
putFloatin classByteBuffer- See Also:
ByteBuffer.putFloat(int, float)
-
asFloatBuffer
public java.nio.FloatBuffer asFloatBuffer()
- Specified by:
asFloatBufferin classByteBuffer- See Also:
ByteBuffer.asFloatBuffer()
-
getDouble
public double getDouble()
- Specified by:
getDoublein classByteBuffer- See Also:
ByteBuffer.getDouble()
-
putDouble
public ByteBuffer putDouble(double value)
- Specified by:
putDoublein classByteBuffer- See Also:
ByteBuffer.putDouble(double)
-
getDouble
public double getDouble(int index)
- Specified by:
getDoublein classByteBuffer- See Also:
ByteBuffer.getDouble(int)
-
putDouble
public ByteBuffer putDouble(int index, double value)
- Specified by:
putDoublein classByteBuffer- See Also:
ByteBuffer.putDouble(int, double)
-
asDoubleBuffer
public java.nio.DoubleBuffer asDoubleBuffer()
- Specified by:
asDoubleBufferin classByteBuffer- See Also:
ByteBuffer.asDoubleBuffer()
-
-