org.mortbay.io
Class View

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

public class View
extends AbstractBuffer

A View on another buffer. Allows operations that do not change the _content or indexes of the backing buffer.

Author:
gregw

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.mortbay.io.Buffer
Buffer.CaseInsensitve
 
Field Summary
 
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
View()
           
View(Buffer buffer)
           
View(Buffer buffer, int mark, int get, int put, int access)
           
 
Method Summary
 byte[] array()
          Get the underlying array, if one exists.
 Buffer buffer()
          Get the unerlying buffer.
 int capacity()
          The capacity of the buffer.
 void clear()
          Clear the buffer.
 void compact()
          Compact the buffer by discarding bytes before the postion (or mark if set).
 boolean equals(Object arg0)
           
 boolean isReadOnly()
           
 boolean isVolatile()
           
 byte peek(int index)
          Get the byte at a specific index in the buffer.
 int peek(int index, byte[] b, int offset, int length)
           
 Buffer peek(int index, 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.
 String toString()
           
 void update(Buffer buffer)
          Update view to buffer
 void update(int get, int put)
           
 
Methods inherited from class org.mortbay.io.AbstractBuffer
asArray, asImmutableBuffer, asMutableBuffer, asNonVolatileBuffer, asReadOnlyBuffer, duplicate, equalsIgnoreCase, get, get, get, getIndex, hasContent, hashCode, isImmutable, length, mark, mark, markIndex, peek, put, put, put, put, putIndex, readFrom, reset, rewind, setGetIndex, setMarkIndex, setPutIndex, skip, slice, sliceFromMark, sliceFromMark, space, toDebugString, toDetailString, writeTo
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

View

public View(Buffer buffer,
            int mark,
            int get,
            int put,
            int access)
Parameters:
buffer - The Buffer on which we are presenting a View.
mark - The initial value of the mark index
get - The initial value of the get index
put - The initial value of the put index
access - The access level - one of the constants from Buffer.

View

public View(Buffer buffer)

View

public View()
Method Detail

update

public void update(Buffer buffer)
Update view to buffer


update

public void update(int get,
                   int put)

array

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

Returns:
The Buffer.array() from the underlying buffer.

buffer

public Buffer buffer()
Description copied from interface: Buffer
Get the unerlying buffer. If this buffer wraps a backing buffer.

Specified by:
buffer in interface Buffer
Overrides:
buffer in class AbstractBuffer
Returns:
The Buffer.buffer() from the underlying buffer.

capacity

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

Returns:
The Buffer.capacity() of the underlying buffer.

clear

public void clear()
Description copied from interface: Buffer
Clear the buffer. getIndex=0, putIndex=0.

Specified by:
clear in interface Buffer
Overrides:
clear in class AbstractBuffer

compact

public void compact()
Description copied from interface: Buffer
Compact the buffer by discarding bytes before the postion (or mark if set). Bytes from the getIndex (or mark) to the putIndex are moved to the beginning of the buffer and the values adjusted accordingly.

Specified by:
compact in interface Buffer
Overrides:
compact in class AbstractBuffer

equals

public boolean equals(Object arg0)
Overrides:
equals in class AbstractBuffer

isReadOnly

public boolean isReadOnly()
Specified by:
isReadOnly in interface Buffer
Overrides:
isReadOnly in class AbstractBuffer
Returns:
Whether the underlying buffer is read only

isVolatile

public boolean isVolatile()
Specified by:
isVolatile in interface Buffer
Overrides:
isVolatile in class AbstractBuffer
Returns:
Whether the underlying buffer is volatile

peek

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

Parameters:
index - an int value
Returns:
The result of calling Buffer.peek(int) on the underlying buffer

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 result of calling Buffer.peek(int, byte[], int, int) on the underlying buffer

peek

public Buffer peek(int index,
                   int length)
Specified by:
peek in interface Buffer
Overrides:
peek in class AbstractBuffer
Parameters:
index - an int value
length - an int value
Returns:
The result of calling Buffer.peek(int, int) on the underlying buffer

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 -
src -
Returns:
The number of bytes actually poked

poke

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

Parameters:
index -
b -

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 -
b -
offset -
length -
Returns:
The number of bytes actually poked

toString

public String toString()
Overrides:
toString in class AbstractBuffer