Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mortbay.io.nio
Class DirectNIOBuffer

    java.lang.Object
      org.mortbay.io.AbstractBuffer
          org.mortbay.io.nio.DirectNIOBuffer

All Implemented Interfaces:
  java.lang.Cloneable, Buffer, NIOBuffer

    public class DirectNIOBuffer

extends AbstractBuffer
implements NIOBuffer

Author:
  gregw

Nested Class Summary

Nested classes/interfaces inherited from interface org.mortbay.io.Buffer
`Buffer.CaseInsensitve`

Field Summary
`protected java.nio.ByteBuffer` | `_buf`

Fields inherited from class org.mortbay.io.AbstractBuffer
`__IMMUTABLE, __READONLY, __READWRITE, __VOLATILE, _access, _get, _hash, _hashGet, _hashPut, _mark, _put, _string, _view, _volatile`

Fields inherited from interface org.mortbay.io.Buffer
`IMMUTABLE, NON_VOLATILE, READONLY, READWRITE, VOLATILE`

Constructor Summary
`DirectNIOBuffer(java.nio.ByteBuffer buffer, boolean immutable)`
`DirectNIOBuffer(java.io.File file)`
`DirectNIOBuffer(int size)`

Method Summary
`byte[]` | `array()` Get the underlying array, if one exists.
`int` | `capacity()` The capacity of the buffer.
`java.nio.ByteBuffer` | `getByteBuffer()`
`boolean` | `isDirect()`
`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 index, 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.
`int` | `readFrom(java.io.InputStream in, int max)` Read the buffer's contents from the input stream
`void` | `writeTo(java.io.OutputStream out)` Write the buffer's contents to the output stream

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, toDebugString, toDetailString, toString`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface org.mortbay.io.Buffer
`asArray, asImmutableBuffer, asMutableBuffer, asNonVolatileBuffer, asReadOnlyBuffer, buffer, clear, compact, equalsIgnoreCase, get, get, get, getIndex, hasContent, isImmutable, isReadOnly, isVolatile, length, mark, mark, markIndex, peek, peek, put, put, put, put, putIndex, reset, setGetIndex, setMarkIndex, setPutIndex, skip, slice, sliceFromMark, sliceFromMark, space, toDetailString`

Field Detail

### _buf

    protected java.nio.ByteBuffer _buf

Constructor Detail

### DirectNIOBuffer

    public DirectNIOBuffer(int size)

### DirectNIOBuffer

    public DirectNIOBuffer(java.nio.ByteBuffer buffer,
                           boolean immutable)

### DirectNIOBuffer

    public DirectNIOBuffer(java.io.File file)
                    throws java.io.IOException

Parameters:
  `file` -
Throws:
  `java.io.IOException`

Method Detail

### isDirect

    public boolean isDirect()

  Specified by:
    `isDirect` in interface `NIOBuffer`

### array

    public byte[] array()

  Description copied from interface: `Buffer`
  Get the underlying array, if one exists.

  Specified by:
    `array` in interface `Buffer`
  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.

  Specified by:
    `capacity` in interface `Buffer`
  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.

  Specified by:
    `peek` in interface `Buffer`
  Parameters:
    `position` - an `int` value
  Returns:
    a `byte` value

### peek

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

  Specified by:
    `peek` in interface `Buffer`
  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 index,
                     byte b)

  Description copied from interface: `Buffer`
  Put a specific byte to a specific getIndex.

  Specified by:
    `poke` in interface `Buffer`
  Parameters:
    `index` - 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 java.nio.ByteBuffer getByteBuffer()

  Specified by:
    `getByteBuffer` in interface `NIOBuffer`

### readFrom

    public int readFrom(java.io.InputStream in,
                        int max)
                 throws java.io.IOException

  Description copied from interface: `Buffer`
  Read the buffer's contents from the input stream

  Specified by:
    `readFrom` in interface `Buffer`
  Overrides:
    `readFrom` in class `AbstractBuffer`
  Parameters:
    `in` - input stream
    `max` - maximum number of bytes that may be read
  Returns:
    actual number of bytes read or -1 for EOF
  Throws:
    `java.io.IOException`

### writeTo

    public void writeTo(java.io.OutputStream out)
                 throws java.io.IOException

  Description copied from interface: `Buffer`
  Write the buffer's contents to the output stream

  Specified by:
    `writeTo` in interface `Buffer`
  Overrides:
    `writeTo` in class `AbstractBuffer`
  Throws:
    `java.io.IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.