org.mortbay.io.nio
Class NIOBuffer

java.lang.Object
  extended by org.mortbay.io.AbstractBuffer
      extended by org.mortbay.io.nio.NIOBuffer
All Implemented Interfaces:
Cloneable, Buffer

public class NIOBuffer
extends AbstractBuffer

Author:
gregw

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.mortbay.io.Buffer
Buffer.CaseInsensitve
 
Field Summary
private  ByteBuffer _buf
           
static boolean DIRECT
           
static boolean INDIRECT
           
 
Fields inherited from class org.mortbay.io.AbstractBuffer
__IMMUTABLE, __READONLY, __READWRITE, __VOLATILE, _access, _get, _hash, _put, _string, _volatile
 
Fields inherited from interface org.mortbay.io.Buffer
IMMUTABLE, NON_VOLATILE, READONLY, READWRITE, VOLATILE
 
Constructor Summary
NIOBuffer(File file)
           
NIOBuffer(int size, boolean direct)
           
 
Method Summary
 byte[] array()
          Get the underlying array, if one exists.
 int capacity()
          The capacity of the buffer.
 ByteBuffer getByteBuffer()
           
 byte peek(int position)
          Get the byte at a specific index in the buffer.
 int peek(int index, byte[] b, int offset, int length)
           
 int poke(int index, Buffer src)
          Put the contents of the buffer at the specific index.
 void poke(int position, byte b)
          Put a specific byte to a specific getIndex.
 int poke(int index, byte[] b, int offset, int length)
          Put a specific byte to a specific getIndex.
 
Methods inherited from class org.mortbay.io.AbstractBuffer
asArray, asImmutableBuffer, asMutableBuffer, asNonVolatileBuffer, asReadOnlyBuffer, buffer, clear, compact, duplicate, equals, equalsIgnoreCase, get, get, get, getIndex, hasContent, hashCode, isImmutable, isReadOnly, isVolatile, length, mark, mark, markIndex, peek, peek, put, put, put, put, putIndex, reset, rewind, setGetIndex, setMarkIndex, setPutIndex, skip, slice, sliceFromMark, sliceFromMark, space, toDetailString, toString, writeTo
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DIRECT

public static final boolean DIRECT
See Also:
Constant Field Values

INDIRECT

public static final boolean INDIRECT
See Also:
Constant Field Values

_buf

private ByteBuffer _buf
Constructor Detail

NIOBuffer

public NIOBuffer(int size,
                 boolean direct)

NIOBuffer

public NIOBuffer(File file)
          throws IOException
Parameters:
file -
Throws:
IOException
Method Detail

array

public byte[] array()
Description copied from interface: Buffer
Get the underlying array, if one exists.

Returns:
a byte[] backing this buffer or null if none exists.

capacity

public int capacity()
Description copied from interface: Buffer
The capacity of the buffer. This is the maximum putIndex that may be set.

Returns:
an int value

peek

public byte peek(int position)
Description copied from interface: Buffer
Get the byte at a specific index in the buffer.

Parameters:
position - an int value
Returns:
a byte value

peek

public int peek(int index,
                byte[] b,
                int offset,
                int length)
Parameters:
index - an int value
b - The byte array to peek into
offset - The offset into the array to start peeking
length - an int value
Returns:
The number of bytes actually peeked

poke

public void poke(int position,
                 byte b)
Description copied from interface: Buffer
Put a specific byte to a specific getIndex.

Parameters:
position - an int value
b - a byte value

poke

public int poke(int index,
                Buffer src)
Description copied from interface: Buffer
Put the contents of the buffer at the specific index.

Specified by:
poke in interface Buffer
Overrides:
poke in class AbstractBuffer
Parameters:
index - an int value
src - a Buffer. If the source buffer is not modified
Returns:
The number of bytes actually poked

poke

public int poke(int index,
                byte[] b,
                int offset,
                int length)
Description copied from interface: Buffer
Put a specific byte to a specific getIndex.

Specified by:
poke in interface Buffer
Overrides:
poke in class AbstractBuffer
Parameters:
index - an int value
b - a byte array value
Returns:
The number of bytes actually poked

getByteBuffer

public ByteBuffer getByteBuffer()