org.apache.mina.common.support
Class BaseByteBuffer

java.lang.Object
  extended by org.apache.mina.common.ByteBuffer
      extended by org.apache.mina.common.support.BaseByteBuffer
All Implemented Interfaces:
java.lang.Comparable<ByteBuffer>

public abstract class BaseByteBuffer
extends ByteBuffer

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

See Also:
ByteBufferAllocator

Constructor Summary
protected BaseByteBuffer()
           
 
Method Summary
 java.nio.CharBuffer asCharBuffer()
           
 java.nio.DoubleBuffer asDoubleBuffer()
           
 java.nio.FloatBuffer asFloatBuffer()
           
 java.nio.IntBuffer asIntBuffer()
           
 java.nio.LongBuffer asLongBuffer()
           
 java.nio.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.
 java.nio.ByteOrder order()
           
 ByteBuffer order(java.nio.ByteOrder bo)
           
 int position()
           
 ByteBuffer position(int newPosition)
           
 ByteBuffer put(byte b)
           
 ByteBuffer put(byte[] src, int offset, int length)
           
 ByteBuffer put(java.nio.ByteBuffer src)
          Writes the content of the specified src into this buffer.
 ByteBuffer put(int index, byte b)
           
 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
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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BaseByteBuffer

protected BaseByteBuffer()
Method Detail

isDirect

public boolean isDirect()
Specified by:
isDirect in class ByteBuffer
See Also:
ByteBuffer.isDirect()

isReadOnly

public boolean isReadOnly()
Specified by:
isReadOnly in class ByteBuffer
See Also:
Buffer.isReadOnly()

capacity

public int capacity()
Specified by:
capacity in class ByteBuffer
See Also:
Buffer.capacity()

capacity

public ByteBuffer capacity(int newCapacity)
Description copied from class: ByteBuffer
Changes the capacity of this buffer.

Specified by:
capacity in class 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.


isAutoExpand

public boolean isAutoExpand()
Description copied from class: ByteBuffer
Returns true if and only if autoExpand is turned on.

Specified by:
isAutoExpand in class ByteBuffer

setAutoExpand

public ByteBuffer setAutoExpand(boolean autoExpand)
Description copied from class: ByteBuffer
Turns on or off autoExpand.

Specified by:
setAutoExpand in class ByteBuffer

expand

public ByteBuffer expand(int pos,
                         int expectedRemaining)
Description copied from class: ByteBuffer
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.

Specified by:
expand in class ByteBuffer

position

public int position()
Specified by:
position in class ByteBuffer
See Also:
Buffer.position()

position

public ByteBuffer position(int newPosition)
Specified by:
position in class ByteBuffer
See Also:
Buffer.position(int)

limit

public int limit()
Specified by:
limit in class ByteBuffer
See Also:
Buffer.limit()

limit

public ByteBuffer limit(int newLimit)
Specified by:
limit in class ByteBuffer
See Also:
Buffer.limit(int)

mark

public ByteBuffer mark()
Specified by:
mark in class ByteBuffer
See Also:
Buffer.mark()

markValue

public int markValue()
Description copied from class: ByteBuffer
Returns the position of the current mark. This method returns -1 if no mark is set.

Specified by:
markValue in class ByteBuffer

reset

public ByteBuffer reset()
Specified by:
reset in class ByteBuffer
See Also:
Buffer.reset()

clear

public ByteBuffer clear()
Specified by:
clear in class ByteBuffer
See Also:
Buffer.clear()

flip

public ByteBuffer flip()
Specified by:
flip in class ByteBuffer
See Also:
Buffer.flip()

rewind

public ByteBuffer rewind()
Specified by:
rewind in class ByteBuffer
See Also:
Buffer.rewind()

get

public byte get()
Specified by:
get in class ByteBuffer
See Also:
ByteBuffer.get()

put

public ByteBuffer put(byte b)
Specified by:
put in class ByteBuffer
See Also:
ByteBuffer.put(byte)

get

public byte get(int index)
Specified by:
get in class ByteBuffer
See Also:
ByteBuffer.get(int)

put

public ByteBuffer put(int index,
                      byte b)
Specified by:
put in class ByteBuffer
See Also:
ByteBuffer.put(int, byte)

get

public ByteBuffer get(byte[] dst,
                      int offset,
                      int length)
Specified by:
get in class ByteBuffer
See Also:
ByteBuffer.get(byte[], int, int)

put

public ByteBuffer put(java.nio.ByteBuffer src)
Description copied from class: ByteBuffer
Writes the content of the specified src into this buffer.

Specified by:
put in class ByteBuffer

put

public ByteBuffer put(byte[] src,
                      int offset,
                      int length)
Specified by:
put in class ByteBuffer
See Also:
ByteBuffer.put(byte[], int, int)

compact

public ByteBuffer compact()
Specified by:
compact in class ByteBuffer
See Also:
ByteBuffer.compact()

order

public java.nio.ByteOrder order()
Specified by:
order in class ByteBuffer
See Also:
ByteBuffer.order()

order

public ByteBuffer order(java.nio.ByteOrder bo)
Specified by:
order in class ByteBuffer
See Also:
ByteBuffer.order(ByteOrder)

getChar

public char getChar()
Specified by:
getChar in class ByteBuffer
See Also:
ByteBuffer.getChar()

putChar

public ByteBuffer putChar(char value)
Specified by:
putChar in class ByteBuffer
See Also:
ByteBuffer.putChar(char)

getChar

public char getChar(int index)
Specified by:
getChar in class ByteBuffer
See Also:
ByteBuffer.getChar(int)

putChar

public ByteBuffer putChar(int index,
                          char value)
Specified by:
putChar in class ByteBuffer
See Also:
ByteBuffer.putChar(int, char)

asCharBuffer

public java.nio.CharBuffer asCharBuffer()
Specified by:
asCharBuffer in class ByteBuffer
See Also:
ByteBuffer.asCharBuffer()

getShort

public short getShort()
Specified by:
getShort in class ByteBuffer
See Also:
ByteBuffer.getShort()

putShort

public ByteBuffer putShort(short value)
Specified by:
putShort in class ByteBuffer
See Also:
ByteBuffer.putShort(short)

getShort

public short getShort(int index)
Specified by:
getShort in class ByteBuffer
See Also:
ByteBuffer.getShort()

putShort

public ByteBuffer putShort(int index,
                           short value)
Specified by:
putShort in class ByteBuffer
See Also:
ByteBuffer.putShort(int, short)

asShortBuffer

public java.nio.ShortBuffer asShortBuffer()
Specified by:
asShortBuffer in class ByteBuffer
See Also:
ByteBuffer.asShortBuffer()

getInt

public int getInt()
Specified by:
getInt in class ByteBuffer
See Also:
ByteBuffer.getInt()

putInt

public ByteBuffer putInt(int value)
Specified by:
putInt in class ByteBuffer
See Also:
ByteBuffer.putInt(int)

getInt

public int getInt(int index)
Specified by:
getInt in class ByteBuffer
See Also:
ByteBuffer.getInt(int)

putInt

public ByteBuffer putInt(int index,
                         int value)
Specified by:
putInt in class ByteBuffer
See Also:
ByteBuffer.putInt(int, int)

asIntBuffer

public java.nio.IntBuffer asIntBuffer()
Specified by:
asIntBuffer in class ByteBuffer
See Also:
ByteBuffer.asIntBuffer()

getLong

public long getLong()
Specified by:
getLong in class ByteBuffer
See Also:
ByteBuffer.getLong()

putLong

public ByteBuffer putLong(long value)
Specified by:
putLong in class ByteBuffer
See Also:
ByteBuffer.putLong(int, long)

getLong

public long getLong(int index)
Specified by:
getLong in class ByteBuffer
See Also:
ByteBuffer.getLong(int)

putLong

public ByteBuffer putLong(int index,
                          long value)
Specified by:
putLong in class ByteBuffer
See Also:
ByteBuffer.putLong(int, long)

asLongBuffer

public java.nio.LongBuffer asLongBuffer()
Specified by:
asLongBuffer in class ByteBuffer
See Also:
ByteBuffer.asLongBuffer()

getFloat

public float getFloat()
Specified by:
getFloat in class ByteBuffer
See Also:
ByteBuffer.getFloat()

putFloat

public ByteBuffer putFloat(float value)
Specified by:
putFloat in class ByteBuffer
See Also:
ByteBuffer.putFloat(float)

getFloat

public float getFloat(int index)
Specified by:
getFloat in class ByteBuffer
See Also:
ByteBuffer.getFloat(int)

putFloat

public ByteBuffer putFloat(int index,
                           float value)
Specified by:
putFloat in class ByteBuffer
See Also:
ByteBuffer.putFloat(int, float)

asFloatBuffer

public java.nio.FloatBuffer asFloatBuffer()
Specified by:
asFloatBuffer in class ByteBuffer
See Also:
ByteBuffer.asFloatBuffer()

getDouble

public double getDouble()
Specified by:
getDouble in class ByteBuffer
See Also:
ByteBuffer.getDouble()

putDouble

public ByteBuffer putDouble(double value)
Specified by:
putDouble in class ByteBuffer
See Also:
ByteBuffer.putDouble(double)

getDouble

public double getDouble(int index)
Specified by:
getDouble in class ByteBuffer
See Also:
ByteBuffer.getDouble(int)

putDouble

public ByteBuffer putDouble(int index,
                            double value)
Specified by:
putDouble in class ByteBuffer
See Also:
ByteBuffer.putDouble(int, double)

asDoubleBuffer

public java.nio.DoubleBuffer asDoubleBuffer()
Specified by:
asDoubleBuffer in class ByteBuffer
See Also:
ByteBuffer.asDoubleBuffer()