Top Fields Constructors Methods
org.mortbay.io

public abstract Class AbstractBuffer

extends Object
implements Buffer
Class Inheritance
All Implemented Interfaces
org.mortbay.io.Buffer, java.lang.Cloneable
Known Direct Subclasses
org.mortbay.io.ByteArrayBuffer, org.mortbay.io.View, org.mortbay.io.nio.DirectNIOBuffer
Imports
java.io.IOException, .InputStream, .OutputStream, org.mortbay.log.Log

Author
gregw

Field Summary

Modifier and TypeField and Description
protected static final String
protected static final String
protected static final String
protected static final String
protected int
protected int
protected int
protected int
protected int
protected int
protected int
protected String
protected View
protected boolean

Constructor Summary

AccessConstructor and Description
public
AbstractBuffer(int
0==IMMUTABLE, 1==READONLY, 2==READWRITE
access
,
boolean isVolatile)

Constructor for BufferView

Method Summary

Modifier and TypeMethod and Description
public byte[]
public Buffer
public Buffer
public Buffer
public Buffer
public Buffer
buffer()

Implements org.mortbay.io.Buffer.buffer.

Get the unerlying buffer.
public void
clear()

Implements org.mortbay.io.Buffer.clear.

Clear the buffer.
public void
compact()

Implements org.mortbay.io.Buffer.compact.

Compact the buffer by discarding bytes before the postion (or mark if set).
public ByteArrayBuffer
duplicate(int access)

public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public boolean
public byte
get()

Implements org.mortbay.io.Buffer.get.

Get the byte at the current getIndex and increment it.
public int
get(byte[]
The byte array to fill.
b
,
int
Offset in the array.
offset
,
int
The max number of bytes to read.
length
)

Implements org.mortbay.io.Buffer.get.

Get bytes from the current postion and put them into the passed byte array.
public Buffer
get(int
an int value
length
)

Implements org.mortbay.io.Buffer.get.

public final int
getIndex()

Implements org.mortbay.io.Buffer.getIndex.

The index within the buffer that will next be read or written.
public boolean
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public boolean
public boolean
public boolean
public int
length()

Implements org.mortbay.io.Buffer.length.

The number of bytes from the getIndex to the putIndex
public void
mark()

Implements org.mortbay.io.Buffer.mark.

Set the mark to the current getIndex.
public void
mark(int
an int value to add to the current getIndex to obtain the mark value.
offset
)

Implements org.mortbay.io.Buffer.mark.

Set the mark relative to the current getIndex
public int
markIndex()

Implements org.mortbay.io.Buffer.markIndex.

The current index of the mark.
public byte
peek()

Implements org.mortbay.io.Buffer.peek.

Get the byte at the current getIndex without incrementing the getIndex.
public Buffer
peek(int
an int value
index
,
int
an int value
length
)

Implements org.mortbay.io.Buffer.peek.

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

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)

Implements org.mortbay.io.Buffer.poke.

Put a specific byte to a specific getIndex.
public int
put(Buffer
The source Buffer it is not modified.
src
)

Implements org.mortbay.io.Buffer.put.

Write the bytes from the source buffer to the current getIndex.
public void
put(byte
a byte value
b
)

Implements org.mortbay.io.Buffer.put.

Put a byte to the current getIndex and increment the getIndex.
public int
put(byte[]
a byte value
b
,
int offset, int length)

Implements org.mortbay.io.Buffer.put.

Put a byte to the current getIndex and increment the getIndex.
public int
put(byte[]
a byte value
b
)

Implements org.mortbay.io.Buffer.put.

Put a byte to the current getIndex and increment the getIndex.
public final int
putIndex()

Implements org.mortbay.io.Buffer.putIndex.

The index of the first element that should not be read.
public int
readFrom(InputStream
input stream
in
,
int
maximum number of bytes that may be read
max
)

Implements org.mortbay.io.Buffer.readFrom.

Read the buffer's contents from the input stream
public void
reset()

Implements org.mortbay.io.Buffer.reset.

Reset the current getIndex to the mark
public void
public void
setGetIndex(int
an int value
getIndex
)

Implements org.mortbay.io.Buffer.setGetIndex.

Set the buffers start getIndex.
public void
setMarkIndex(int
an int value
index
)

Implements org.mortbay.io.Buffer.setMarkIndex.

Set a specific value for the mark.
public void
setPutIndex(int
an int value
putIndex
)

Implements org.mortbay.io.Buffer.setPutIndex.

public int
skip(int
The number of bytes to skip
n
)

Implements org.mortbay.io.Buffer.skip.

Skip _content.
public Buffer
public Buffer
public Buffer
sliceFromMark(int
an int value
length
)

Implements org.mortbay.io.Buffer.sliceFromMark.

public int
space()

Implements org.mortbay.io.Buffer.space.

the space remaining in the buffer.
public String
public String
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public String
public void
writeTo(OutputStream out)

Implements org.mortbay.io.Buffer.writeTo.

Write the buffer's contents to the output stream
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

__IMMUTABLEback to summary
protected static final String __IMMUTABLE
__READONLYback to summary
protected static final String __READONLY
__READWRITEback to summary
protected static final String __READWRITE
__VOLATILEback to summary
protected static final String __VOLATILE
_accessback to summary
protected int _access
_getback to summary
protected int _get
_hashback to summary
protected int _hash
_hashGetback to summary
protected int _hashGet
_hashPutback to summary
protected int _hashPut
_markback to summary
protected int _mark
_putback to summary
protected int _put
_stringback to summary
protected String _string
_viewback to summary
protected View _view
_volatileback to summary
protected boolean _volatile

Constructor Detail

AbstractBufferback to summary
public AbstractBuffer(int access, boolean isVolatile)

Constructor for BufferView

Parameters
access:int

0==IMMUTABLE, 1==READONLY, 2==READWRITE

Method Detail

asArrayback to summary
public byte[] asArray()

Implements org.mortbay.io.Buffer.asArray.

Returns:byte[]

Doc from org.mortbay.io.Buffer.asArray.

a byte[] value of the bytes from the getIndex to the putIndex.

asImmutableBufferback to summary
public Buffer asImmutableBuffer()

Implements org.mortbay.io.Buffer.asImmutableBuffer.

Returns:Buffer

Doc from org.mortbay.io.Buffer.asImmutableBuffer.

an immutable version of this Buffer.

asMutableBufferback to summary
public Buffer asMutableBuffer()

Implements org.mortbay.io.Buffer.asMutableBuffer.

Returns:Buffer

Doc from org.mortbay.io.Buffer.asMutableBuffer.

an immutable version of this Buffer.

asNonVolatileBufferback to summary
public Buffer asNonVolatileBuffer()

Implements org.mortbay.io.Buffer.asNonVolatileBuffer.

Returns:Buffer

Doc from org.mortbay.io.Buffer.asNonVolatileBuffer.

a non volitile version of this Buffer value

asReadOnlyBufferback to summary
public Buffer asReadOnlyBuffer()

Implements org.mortbay.io.Buffer.asReadOnlyBuffer.

Returns:Buffer

Doc from org.mortbay.io.Buffer.asReadOnlyBuffer.

a readonly version of this Buffer.

bufferback to summary
public Buffer buffer()

Implements org.mortbay.io.Buffer.buffer.

Doc from org.mortbay.io.Buffer.buffer.

Get the unerlying buffer. If this buffer wraps a backing buffer.

Returns:Buffer

The root backing buffer or this if there is no backing buffer;

clearback to summary
public void clear()

Implements org.mortbay.io.Buffer.clear.

Doc from org.mortbay.io.Buffer.clear.

Clear the buffer. getIndex=0, putIndex=0.

compactback to summary
public void compact()

Implements org.mortbay.io.Buffer.compact.

Doc from org.mortbay.io.Buffer.compact.

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.

duplicateback to summary
public ByteArrayBuffer duplicate(int access)
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

equalsIgnoreCaseback to summary
public boolean equalsIgnoreCase(Buffer b)

Implements org.mortbay.io.Buffer.equalsIgnoreCase.

Returns:boolean

Doc from org.mortbay.io.Buffer.equalsIgnoreCase.

a boolean value true if case sensitive comparison on this buffer

getback to summary
public byte get()

Implements org.mortbay.io.Buffer.get.

Doc from org.mortbay.io.Buffer.get.

Get the byte at the current getIndex and increment it.

Returns:byte

The byte value from the current getIndex.

getback to summary
public int get(byte[] b, int offset, int length)

Implements org.mortbay.io.Buffer.get.

Doc from org.mortbay.io.Buffer.get.

Get bytes from the current postion and put them into the passed byte array. The getIndex is incremented by the number of bytes copied into the array.

Parameters
b:byte[]

The byte array to fill.

offset:int

Offset in the array.

length:int

The max number of bytes to read.

Returns:int

The number of bytes actually read.

getback to summary
public Buffer get(int length)

Implements org.mortbay.io.Buffer.get.

Parameters
length:int

Doc from org.mortbay.io.Buffer.get.

an int value

Returns:Buffer

Doc from org.mortbay.io.Buffer.get.

a Buffer value

getIndexback to summary
public final int getIndex()

Implements org.mortbay.io.Buffer.getIndex.

Doc from org.mortbay.io.Buffer.getIndex.

The index within the buffer that will next be read or written.

Returns:int

an int value >=0 <= putIndex()

hasContentback to summary
public boolean hasContent()

Implements org.mortbay.io.Buffer.hasContent.

Returns:boolean

Doc from org.mortbay.io.Buffer.hasContent.

true of putIndex > getIndex

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

isImmutableback to summary
public boolean isImmutable()

Implements org.mortbay.io.Buffer.isImmutable.

Returns:boolean

Doc from org.mortbay.io.Buffer.isImmutable.

a boolean value true if the buffer is immutable and that neither the buffer contents nor the indexes may be changed.

isReadOnlyback to summary
public boolean isReadOnly()

Implements org.mortbay.io.Buffer.isReadOnly.

Returns:boolean

Doc from org.mortbay.io.Buffer.isReadOnly.

a boolean value true if the buffer is readonly. The buffer indexes may be modified, but the buffer contents may not. For example a View onto an immutable Buffer will be read only.

isVolatileback to summary
public boolean isVolatile()

Implements org.mortbay.io.Buffer.isVolatile.

Returns:boolean

Doc from org.mortbay.io.Buffer.isVolatile.

a boolean value true if the buffer contents may change via alternate paths than this buffer. If the contents of this buffer are to be used outside of the current context, then a copy must be made.

lengthback to summary
public int length()

Implements org.mortbay.io.Buffer.length.

Doc from org.mortbay.io.Buffer.length.

The number of bytes from the getIndex to the putIndex

Returns:int

an int == putIndex()-getIndex()

markback to summary
public void mark()

Implements org.mortbay.io.Buffer.mark.

Doc from org.mortbay.io.Buffer.mark.

Set the mark to the current getIndex.

markback to summary
public void mark(int offset)

Implements org.mortbay.io.Buffer.mark.

Doc from org.mortbay.io.Buffer.mark.

Set the mark relative to the current getIndex

Parameters
offset:int

an int value to add to the current getIndex to obtain the mark value.

markIndexback to summary
public int markIndex()

Implements org.mortbay.io.Buffer.markIndex.

Doc from org.mortbay.io.Buffer.markIndex.

The current index of the mark.

Returns:int

an int index in the buffer or -1 if the mark is not set.

peekback to summary
public byte peek()

Implements org.mortbay.io.Buffer.peek.

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

Get the byte at the current getIndex without incrementing the getIndex.

Returns:byte

The byte value from the current getIndex.

peekback to summary
public Buffer peek(int index, int length)

Implements org.mortbay.io.Buffer.peek.

Parameters
index:int

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

an int value

length:int

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

an int value

Returns:Buffer

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

The Buffer value from the requested getIndex.

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

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)

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

putback to summary
public int put(Buffer src)

Implements org.mortbay.io.Buffer.put.

Doc from org.mortbay.io.Buffer.put.

Write the bytes from the source buffer to the current getIndex.

Parameters
src:Buffer

The source Buffer it is not modified.

Returns:int

The number of bytes actually poked

putback to summary
public void put(byte b)

Implements org.mortbay.io.Buffer.put.

Doc from org.mortbay.io.Buffer.put.

Put a byte to the current getIndex and increment the getIndex.

Parameters
b:byte

a byte value

putback to summary
public int put(byte[] b, int offset, int length)

Implements org.mortbay.io.Buffer.put.

Doc from org.mortbay.io.Buffer.put.

Put a byte to the current getIndex and increment the getIndex.

Parameters
b:byte[]

a byte value

Returns:int

The number of bytes actually poked

putback to summary
public int put(byte[] b)

Implements org.mortbay.io.Buffer.put.

Doc from org.mortbay.io.Buffer.put.

Put a byte to the current getIndex and increment the getIndex.

Parameters
b:byte[]

a byte value

Returns:int

The number of bytes actually poked

putIndexback to summary
public final int putIndex()

Implements org.mortbay.io.Buffer.putIndex.

Doc from org.mortbay.io.Buffer.putIndex.

The index of the first element that should not be read.

Returns:int

an int value >= getIndex()

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

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

resetback to summary
public void reset()

Implements org.mortbay.io.Buffer.reset.

Doc from org.mortbay.io.Buffer.reset.

Reset the current getIndex to the mark

rewindback to summary
public void rewind()
setGetIndexback to summary
public void setGetIndex(int getIndex)

Implements org.mortbay.io.Buffer.setGetIndex.

Doc from org.mortbay.io.Buffer.setGetIndex.

Set the buffers start getIndex.

Parameters
getIndex:int

an int value

setMarkIndexback to summary
public void setMarkIndex(int index)

Implements org.mortbay.io.Buffer.setMarkIndex.

Doc from org.mortbay.io.Buffer.setMarkIndex.

Set a specific value for the mark.

Parameters
index:int

an int value

setPutIndexback to summary
public void setPutIndex(int putIndex)

Implements org.mortbay.io.Buffer.setPutIndex.

Parameters
putIndex:int

Doc from org.mortbay.io.Buffer.setPutIndex.

an int value

skipback to summary
public int skip(int n)

Implements org.mortbay.io.Buffer.skip.

Doc from org.mortbay.io.Buffer.skip.

Skip _content. The getIndex is updated by min(remaining(), n)

Parameters
n:int

The number of bytes to skip

Returns:int

the number of bytes skipped.

sliceback to summary
public Buffer slice()

Implements org.mortbay.io.Buffer.slice.

Returns:Buffer

Doc from org.mortbay.io.Buffer.slice.

a volitile Buffer from the postion to the putIndex.

sliceFromMarkback to summary
public Buffer sliceFromMark()

Implements org.mortbay.io.Buffer.sliceFromMark.

Returns:Buffer

Doc from org.mortbay.io.Buffer.sliceFromMark.

a volitile Buffer value from the mark to the putIndex

sliceFromMarkback to summary
public Buffer sliceFromMark(int length)

Implements org.mortbay.io.Buffer.sliceFromMark.

Parameters
length:int

Doc from org.mortbay.io.Buffer.sliceFromMark.

an int value

Returns:Buffer

Doc from org.mortbay.io.Buffer.sliceFromMark.

a valitile Buffer value from the mark of the length requested.

spaceback to summary
public int space()

Implements org.mortbay.io.Buffer.space.

Doc from org.mortbay.io.Buffer.space.

the space remaining in the buffer.

Returns:int

capacity - putIndex

toDebugStringback to summary
public String toDebugString()
toDetailStringback to summary
public String toDetailString()

Implements org.mortbay.io.Buffer.toDetailString.

Returns:String

Doc from org.mortbay.io.Buffer.toDetailString.

a String value describing the state and contents of the buffer.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

toStringback to summary
public String toString(String charset)

Implements org.mortbay.io.Buffer.toString.

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

Implements org.mortbay.io.Buffer.writeTo.

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

Write the buffer's contents to the output stream