Top Fields Constructors Methods
org.mortbay.io.nio

public Class DirectNIOBuffer

extends AbstractBuffer
implements NIOBuffer
Class Inheritance
All Implemented Interfaces
org.mortbay.io.nio.NIOBuffer, org.mortbay.io.Buffer, java.lang.Cloneable
Imports
java.io.File, .FileInputStream, .IOException, .InputStream, .OutputStream, java.nio.ByteBuffer, java.nio.channels.Channels, .FileChannel, .ReadableByteChannel, .WritableByteChannel, org.mortbay.io.AbstractBuffer, .Buffer

Author
gregw

Field Summary

Modifier and TypeField and Description
protected ByteBuffer
private ReadableByteChannel
private InputStream
private WritableByteChannel
private OutputStream
Inherited from org.mortbay.io.AbstractBuffer:
__IMMUTABLE__READONLY__READWRITE__VOLATILE_access_get_hash_hashGet_hashPut_mark_put_string_view_volatile

Constructor Summary

AccessConstructor and Description
public
DirectNIOBuffer(int size)

public
DirectNIOBuffer(ByteBuffer buffer, boolean immutable)

public

Method Summary

Modifier and TypeMethod and Description
public byte[]
array()

Implements org.mortbay.io.Buffer.array.

Get the underlying array, if one exists.
public int
capacity()

Implements org.mortbay.io.Buffer.capacity.

The capacity of the buffer.
public ByteBuffer
public boolean
public byte
peek(int
an int value
position
)

Implements org.mortbay.io.Buffer.peek.

Get the byte at a specific index in the buffer.
public int
peek(int
an int value
index
,
byte[]
The byte array to peek into
b
,
int
The offset into the array to start peeking
offset
,
int
an int value
length
)

Implements org.mortbay.io.Buffer.peek.

public void
poke(int
an int value
index
,
byte
a byte value
b
)

Implements org.mortbay.io.Buffer.poke.

Put a specific byte to a specific getIndex.
public int
poke(int
an int value
index
,
Buffer
a Buffer. If the source buffer is not modified
src
)

Overrides org.mortbay.io.AbstractBuffer.poke.

Implements org.mortbay.io.Buffer.poke.

Put the contents of the buffer at the specific index.
public int
poke(int
an int value
index
,
byte[]
a byte array value
b
,
int offset, int length)

Overrides org.mortbay.io.AbstractBuffer.poke.

Implements org.mortbay.io.Buffer.poke.

Put a specific byte to a specific getIndex.
public int
readFrom(InputStream
input stream
in
,
int
maximum number of bytes that may be read
max
)

Overrides org.mortbay.io.AbstractBuffer.readFrom.

Implements org.mortbay.io.Buffer.readFrom.

Read the buffer's contents from the input stream
public void
writeTo(OutputStream out)

Overrides org.mortbay.io.AbstractBuffer.writeTo.

Implements org.mortbay.io.Buffer.writeTo.

Write the buffer's contents to the output stream
Inherited from org.mortbay.io.AbstractBuffer:
asArrayasImmutableBufferasMutableBufferasNonVolatileBufferasReadOnlyBufferbufferclearcompactduplicateequalsequalsIgnoreCasegetgetgetgetIndexhasContenthashCodeisImmutableisReadOnlyisVolatilelengthmarkmarkmarkIndexpeekpeekputputputputputIndexresetrewindsetGetIndexsetMarkIndexsetPutIndexskipslicesliceFromMarksliceFromMarkspacetoDebugStringtoDetailStringtoString

Field Detail

_bufback to summary
protected ByteBuffer _buf
_inback to summary
private ReadableByteChannel _in
_inStreamback to summary
private InputStream _inStream
_outback to summary
private WritableByteChannel _out
_outStreamback to summary
private OutputStream _outStream

Constructor Detail

DirectNIOBufferback to summary
public DirectNIOBuffer(int size)
DirectNIOBufferback to summary
public DirectNIOBuffer(ByteBuffer buffer, boolean immutable)
DirectNIOBufferback to summary
public DirectNIOBuffer(File file) throws IOException

Method Detail

arrayback to summary
public byte[] array()

Implements org.mortbay.io.Buffer.array.

Doc from org.mortbay.io.Buffer.array.

Get the underlying array, if one exists.

Returns:byte[]

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

capacityback to summary
public int capacity()

Implements org.mortbay.io.Buffer.capacity.

Doc from org.mortbay.io.Buffer.capacity.

The capacity of the buffer. This is the maximum putIndex that may be set.

Returns:int

an int value

getByteBufferback to summary
public ByteBuffer getByteBuffer()

Implements org.mortbay.io.nio.NIOBuffer.getByteBuffer.

isDirectback to summary
public boolean isDirect()

Implements org.mortbay.io.nio.NIOBuffer.isDirect.

peekback to summary
public byte peek(int position)

Implements org.mortbay.io.Buffer.peek.

Doc from org.mortbay.io.Buffer.peek.

Get the byte at a specific index in the buffer.

Parameters
position:int

an int value

Returns:byte

a byte value

peekback to summary
public int peek(int index, byte[] b, int offset, int length)

Implements org.mortbay.io.Buffer.peek.

Parameters
index:int

Doc from org.mortbay.io.Buffer.peek.

an int value

b:byte[]

Doc from org.mortbay.io.Buffer.peek.

The byte array to peek into

offset:int

Doc from org.mortbay.io.Buffer.peek.

The offset into the array to start peeking

length:int

Doc from org.mortbay.io.Buffer.peek.

an int value

Returns:int

Doc from org.mortbay.io.Buffer.peek.

The number of bytes actually peeked

pokeback to summary
public void poke(int index, byte b)

Implements org.mortbay.io.Buffer.poke.

Doc from org.mortbay.io.Buffer.poke.

Put a specific byte to a specific getIndex.

Parameters
index:int

an int value

b:byte

a byte value

pokeback to summary
public int poke(int index, Buffer src)

Overrides org.mortbay.io.AbstractBuffer.poke.

Implements org.mortbay.io.Buffer.poke.

Doc from org.mortbay.io.Buffer.poke.

Put the contents of the buffer at the specific index.

Parameters
index:int

an int value

src:Buffer

a Buffer. If the source buffer is not modified

Returns:int

The number of bytes actually poked

pokeback to summary
public int poke(int index, byte[] b, int offset, int length)

Overrides org.mortbay.io.AbstractBuffer.poke.

Implements org.mortbay.io.Buffer.poke.

Doc from org.mortbay.io.Buffer.poke.

Put a specific byte to a specific getIndex.

Parameters
index:int

an int value

b:byte[]

a byte array value

Returns:int

The number of bytes actually poked

readFromback to summary
public int readFrom(InputStream in, int max) throws IOException

Overrides org.mortbay.io.AbstractBuffer.readFrom.

Implements org.mortbay.io.Buffer.readFrom.

Doc from org.mortbay.io.Buffer.readFrom.

Read the buffer's contents from the input stream

Parameters
in:InputStream

input stream

max:int

maximum number of bytes that may be read

Returns:int

actual number of bytes read or -1 for EOF

writeToback to summary
public void writeTo(OutputStream out) throws IOException

Overrides org.mortbay.io.AbstractBuffer.writeTo.

Implements org.mortbay.io.Buffer.writeTo.

Doc from org.mortbay.io.Buffer.writeTo.

Write the buffer's contents to the output stream