org.apache.mina.common.support

Class BaseByteBuffer

Implemented Interfaces:
Comparable

public abstract class BaseByteBuffer
extends ByteBuffer

A base implementation of ByteBuffer. This implementation assumes that ByteBuffer.buf() always returns a correct NIO java.nio.ByteBuffer instance. Most implementations could extend this class and implement their own buffer management mechanism.
See Also:
ByteBufferAllocator

Constructor Summary

BaseByteBuffer()

Method Summary

CharBuffer
asCharBuffer()
DoubleBuffer
asDoubleBuffer()
FloatBuffer
asFloatBuffer()
IntBuffer
asIntBuffer()
LongBuffer
asLongBuffer()
ShortBuffer
asShortBuffer()
int
capacity()
ByteBuffer
capacity(int newCapacity)
Changes the capacity of this buffer.
protected abstract void
capacity0(int newCapacity)
Implement this method to increase the capacity of this buffer.
ByteBuffer
clear()
ByteBuffer
compact()
ByteBuffer
expand(int pos, int expectedRemaining)
Changes the capacity and limit of this buffer so this buffer get the specified expectedRemaining room from the specified pos.
ByteBuffer
flip()
byte
get()
ByteBuffer
get(byte[] dst, int offset, int length)
byte
get(int index)
char
getChar()
char
getChar(int index)
double
getDouble()
double
getDouble(int index)
float
getFloat()
float
getFloat(int index)
int
getInt()
int
getInt(int index)
long
getLong()
long
getLong(int index)
short
getShort()
short
getShort(int index)
boolean
isAutoExpand()
Returns true if and only if autoExpand is turned on.
boolean
isDirect()
boolean
isReadOnly()
int
limit()
ByteBuffer
limit(int newLimit)
ByteBuffer
mark()
int
markValue()
Returns the position of the current mark.
ByteOrder
order()
ByteBuffer
order(ByteOrder bo)
int
position()
ByteBuffer
position(int newPosition)
ByteBuffer
put(byte b)
ByteBuffer
put(byte[] src, int offset, int length)
ByteBuffer
put(int index, byte b)
ByteBuffer
put(java.nio.ByteBuffer src)
Writes the content of the specified src into this buffer.
ByteBuffer
putChar(char value)
ByteBuffer
putChar(int index, char value)
ByteBuffer
putDouble(double value)
ByteBuffer
putDouble(int index, double value)
ByteBuffer
putFloat(float value)
ByteBuffer
putFloat(int index, float value)
ByteBuffer
putInt(int value)
ByteBuffer
putInt(int index, int value)
ByteBuffer
putLong(int index, long value)
ByteBuffer
putLong(long value)
ByteBuffer
putShort(int index, short value)
ByteBuffer
putShort(short value)
ByteBuffer
reset()
ByteBuffer
rewind()
ByteBuffer
setAutoExpand(boolean autoExpand)
Turns on or off autoExpand.

Methods inherited from class org.apache.mina.common.ByteBuffer

String toString, acquire, allocate, allocate, array, arrayOffset, asCharBuffer, asDoubleBuffer, asFloatBuffer, asInputStream, asIntBuffer, asLongBuffer, asOutputStream, asReadOnlyBuffer, asShortBuffer, autoExpand, autoExpand, boolean equals, buf, capacity, capacity, clear, compact, compareTo, duplicate, expand, expand, fill, fill, fillAndReset, fillAndReset, flip, get, get, get, get, getAllocator, getChar, getChar, getDouble, getDouble, getFloat, getFloat, getHexDump, getInt, getInt, getLong, getLong, getObject, getObject, getPrefixedString, getPrefixedString, getShort, getShort, getString, getString, getUnsigned, getUnsigned, getUnsignedInt, getUnsignedInt, getUnsignedShort, getUnsignedShort, hasRemaining, int hashCode, isAutoExpand, isDirect, isPooled, isReadOnly, isUseDirectBuffers, limit, limit, mark, markValue, order, order, position, position, prefixedDataAvailable, prefixedDataAvailable, put, put, put, put, put, put, putChar, putChar, putDouble, putDouble, putFloat, putFloat, putInt, putInt, putLong, putLong, putObject, putPrefixedString, putPrefixedString, putPrefixedString, putPrefixedString, putShort, putShort, putString, putString, release, remaining, reset, rewind, setAllocator, setAutoExpand, setPooled, setUseDirectBuffers, skip, slice, sweep, sweep, wrap, wrap, wrap

Constructor Details

BaseByteBuffer

protected BaseByteBuffer()

Method Details

asCharBuffer

public CharBuffer asCharBuffer()
Overrides:
asCharBuffer in interface ByteBuffer
See Also:
java.nio.ByteBuffer.asCharBuffer()

asDoubleBuffer

public DoubleBuffer asDoubleBuffer()
Overrides:
asDoubleBuffer in interface ByteBuffer
See Also:
java.nio.ByteBuffer.asDoubleBuffer()

asFloatBuffer

public FloatBuffer asFloatBuffer()
Overrides:
asFloatBuffer in interface ByteBuffer
See Also:
java.nio.ByteBuffer.asFloatBuffer()

asIntBuffer

public IntBuffer asIntBuffer()
Overrides:
asIntBuffer in interface ByteBuffer
See Also:
java.nio.ByteBuffer.asIntBuffer()

asLongBuffer

public LongBuffer asLongBuffer()
Overrides:
asLongBuffer in interface ByteBuffer
See Also:
java.nio.ByteBuffer.asLongBuffer()

asShortBuffer

public ShortBuffer asShortBuffer()
Overrides:
asShortBuffer in interface ByteBuffer
See Also:
java.nio.ByteBuffer.asShortBuffer()

capacity

public int capacity()
Overrides:
capacity in interface ByteBuffer
See Also:
java.nio.ByteBuffer.capacity()

capacity

public ByteBuffer capacity(int newCapacity)
Changes the capacity of this buffer.
Overrides:
capacity in interface ByteBuffer

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.

clear

public ByteBuffer clear()
Overrides:
clear in interface ByteBuffer
See Also:
java.nio.Buffer.clear()

compact

public ByteBuffer compact()
Overrides:
compact in interface ByteBuffer
See Also:
java.nio.ByteBuffer.compact()

expand

public ByteBuffer expand(int pos,
                         int expectedRemaining)
Changes 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.
Overrides:
expand in interface ByteBuffer

flip

public ByteBuffer flip()
Overrides:
flip in interface ByteBuffer
See Also:
java.nio.Buffer.flip()

get

public byte get()
Overrides:
get in interface ByteBuffer
See Also:
java.nio.ByteBuffer.get()

get

public ByteBuffer get(byte[] dst,
                      int offset,
                      int length)
Overrides:
get in interface ByteBuffer
See Also:
java.nio.ByteBuffer.get(byte[], int, int)

get

public byte get(int index)
Overrides:
get in interface ByteBuffer
See Also:
java.nio.ByteBuffer.get(int)

getChar

public char getChar()
Overrides:
getChar in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getChar()

getChar

public char getChar(int index)
Overrides:
getChar in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getChar(int)

getDouble

public double getDouble()
Overrides:
getDouble in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getDouble()

getDouble

public double getDouble(int index)
Overrides:
getDouble in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getDouble(int)

getFloat

public float getFloat()
Overrides:
getFloat in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getFloat()

getFloat

public float getFloat(int index)
Overrides:
getFloat in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getFloat(int)

getInt

public int getInt()
Overrides:
getInt in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getInt()

getInt

public int getInt(int index)
Overrides:
getInt in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getInt(int)

getLong

public long getLong()
Overrides:
getLong in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getLong()

getLong

public long getLong(int index)
Overrides:
getLong in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getLong(int)

getShort

public short getShort()
Overrides:
getShort in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getShort()

getShort

public short getShort(int index)
Overrides:
getShort in interface ByteBuffer
See Also:
java.nio.ByteBuffer.getShort()

isAutoExpand

public boolean isAutoExpand()
Returns true if and only if autoExpand is turned on.
Overrides:
isAutoExpand in interface ByteBuffer

isDirect

public boolean isDirect()
Overrides:
isDirect in interface ByteBuffer
See Also:
java.nio.ByteBuffer.isDirect()

isReadOnly

public boolean isReadOnly()
Overrides:
isReadOnly in interface ByteBuffer
See Also:
java.nio.ByteBuffer.isReadOnly()

limit

public int limit()
Overrides:
limit in interface ByteBuffer
See Also:
java.nio.Buffer.limit()

limit

public ByteBuffer limit(int newLimit)
Overrides:
limit in interface ByteBuffer
See Also:
java.nio.Buffer.limit(int)

mark

public ByteBuffer mark()
Overrides:
mark in interface ByteBuffer
See Also:
java.nio.Buffer.mark()

markValue

public int markValue()
Returns the position of the current mark. This method returns -1 if no mark is set.
Overrides:
markValue in interface ByteBuffer

order

public ByteOrder order()
Overrides:
order in interface ByteBuffer
See Also:
java.nio.ByteBuffer.order()

order

public ByteBuffer order(ByteOrder bo)
Overrides:
order in interface ByteBuffer
See Also:
java.nio.ByteBuffer.order(ByteOrder)

position

public int position()
Overrides:
position in interface ByteBuffer
See Also:
java.nio.Buffer.position()

position

public ByteBuffer position(int newPosition)
Overrides:
position in interface ByteBuffer
See Also:
java.nio.Buffer.position(int)

put

public ByteBuffer put(byte b)
Overrides:
put in interface ByteBuffer
See Also:
java.nio.ByteBuffer.put(byte)

put

public ByteBuffer put(byte[] src,
                      int offset,
                      int length)
Overrides:
put in interface ByteBuffer
See Also:
java.nio.ByteBuffer.put(byte[], int, int)

put

public ByteBuffer put(int index,
                      byte b)
Overrides:
put in interface ByteBuffer
See Also:
java.nio.ByteBuffer.put(int, byte)

put

public ByteBuffer put(java.nio.ByteBuffer src)
Writes the content of the specified src into this buffer.
Overrides:
put in interface ByteBuffer

putChar

public ByteBuffer putChar(char value)
Overrides:
putChar in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putChar(char)

putChar

public ByteBuffer putChar(int index,
                          char value)
Overrides:
putChar in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putChar(int, char)

putDouble

public ByteBuffer putDouble(double value)
Overrides:
putDouble in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putDouble(double)

putDouble

public ByteBuffer putDouble(int index,
                            double value)
Overrides:
putDouble in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putDouble(int, double)

putFloat

public ByteBuffer putFloat(float value)
Overrides:
putFloat in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putFloat(float)

putFloat

public ByteBuffer putFloat(int index,
                           float value)
Overrides:
putFloat in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putFloat(int, float)

putInt

public ByteBuffer putInt(int value)
Overrides:
putInt in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putInt(int)

putInt

public ByteBuffer putInt(int index,
                         int value)
Overrides:
putInt in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putInt(int, int)

putLong

public ByteBuffer putLong(int index,
                          long value)
Overrides:
putLong in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putLong(int, long)

putLong

public ByteBuffer putLong(long value)
Overrides:
putLong in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putLong(int, long)

putShort

public ByteBuffer putShort(int index,
                           short value)
Overrides:
putShort in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putShort(int, short)

putShort

public ByteBuffer putShort(short value)
Overrides:
putShort in interface ByteBuffer
See Also:
java.nio.ByteBuffer.putShort(short)

reset

public ByteBuffer reset()
Overrides:
reset in interface ByteBuffer
See Also:
java.nio.Buffer.reset()

rewind

public ByteBuffer rewind()
Overrides:
rewind in interface ByteBuffer
See Also:
java.nio.Buffer.rewind()

setAutoExpand

public ByteBuffer setAutoExpand(boolean autoExpand)
Turns on or off autoExpand.
Overrides:
setAutoExpand in interface ByteBuffer