Top Inners Fields Constructors Methods
org.mortbay.io

public Class ByteArrayBuffer

extends AbstractBuffer
Class Inheritance
Known Direct Subclasses
org.mortbay.io.ByteArrayBuffer.CaseInsensitive, org.mortbay.io.nio.IndirectNIOBuffer
Imports
java.io.IOException, .InputStream, .OutputStream, .UnsupportedEncodingException, java.util.Arrays, org.mortbay.util.StringUtil

Author
gregw

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
protected byte[]
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
protected
ByteArrayBuffer(int access, boolean isVolatile)

public
ByteArrayBuffer(byte[] bytes)

public
ByteArrayBuffer(byte[] bytes, int index, int length)

public
ByteArrayBuffer(byte[] bytes, int index, int length, int access)

public
ByteArrayBuffer(byte[] bytes, int index, int length, int access, boolean isVolatile)

public
ByteArrayBuffer(int size)

public
public
ByteArrayBuffer(String value, String encoding)

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 void
compact()

Overrides org.mortbay.io.AbstractBuffer.compact.

Implements org.mortbay.io.Buffer.compact.

Compact the buffer by discarding bytes before the postion (or mark if set).
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides org.mortbay.io.AbstractBuffer.equals.

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

Overrides org.mortbay.io.AbstractBuffer.get.

Implements org.mortbay.io.Buffer.get.

Get the byte at the current getIndex and increment it.
public int
hashCode()

Overrides org.mortbay.io.AbstractBuffer.hashCode.

Returns a hash code value for the object.
public byte
peek(int
an int value
index
)

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 int
space()

Overrides org.mortbay.io.AbstractBuffer.space.

Implements org.mortbay.io.Buffer.space.

the space remaining in the buffer.
public void
wrap(byte[] b, int off, int len)

Wrap a byte array.

public void
wrap(byte[] b)

Wrap a byte array

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:
asArrayasImmutableBufferasMutableBufferasNonVolatileBufferasReadOnlyBufferbufferclearduplicategetgetgetIndexhasContentisImmutableisReadOnlyisVolatilelengthmarkmarkmarkIndexpeekpeekputputputputputIndexresetrewindsetGetIndexsetMarkIndexsetPutIndexskipslicesliceFromMarksliceFromMarktoDebugStringtoDetailStringtoStringtoString

Field Detail

_bytesback to summary
protected byte[] _bytes

Constructor Detail

ByteArrayBufferback to summary
protected ByteArrayBuffer(int access, boolean isVolatile)
ByteArrayBufferback to summary
public ByteArrayBuffer(byte[] bytes)
ByteArrayBufferback to summary
public ByteArrayBuffer(byte[] bytes, int index, int length)
ByteArrayBufferback to summary
public ByteArrayBuffer(byte[] bytes, int index, int length, int access)
ByteArrayBufferback to summary
public ByteArrayBuffer(byte[] bytes, int index, int length, int access, boolean isVolatile)
ByteArrayBufferback to summary
public ByteArrayBuffer(int size)
ByteArrayBufferback to summary
public ByteArrayBuffer(String value)
ByteArrayBufferback to summary
public ByteArrayBuffer(String value, String encoding) throws UnsupportedEncodingException

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

compactback to summary
public void compact()

Overrides org.mortbay.io.AbstractBuffer.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.

equalsback to summary
public boolean equals(Object obj)

Overrides org.mortbay.io.AbstractBuffer.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)

Overrides org.mortbay.io.AbstractBuffer.equalsIgnoreCase.

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()

Overrides org.mortbay.io.AbstractBuffer.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.

hashCodeback to summary
public int hashCode()

Overrides org.mortbay.io.AbstractBuffer.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.

peekback to summary
public byte peek(int index)

Implements org.mortbay.io.Buffer.peek.

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

Get the byte at a specific index in the buffer.

Parameters
index: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

spaceback to summary
public int space()

Overrides org.mortbay.io.AbstractBuffer.space.

Implements org.mortbay.io.Buffer.space.

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

the space remaining in the buffer.

Returns:int

capacity - putIndex

wrapback to summary
public void wrap(byte[] b, int off, int len)

Wrap a byte array.

wrapback to summary
public void wrap(byte[] b)

Wrap a byte array

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

org.mortbay.io back to summary

public Class ByteArrayBuffer.CaseInsensitive

extends ByteArrayBuffer
implements CaseInsensitve
Class Inheritance
All Implemented Interfaces
org.mortbay.io.Buffer.CaseInsensitve
Known Direct Subclasses
org.mortbay.io.BufferCache.CachedBuffer

Field Summary

Inherited from org.mortbay.io.ByteArrayBuffer:
_bytes

Constructor Summary

AccessConstructor and Description
public
public
CaseInsensitive(byte[] b, int o, int l, int rw)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides org.mortbay.io.ByteArrayBuffer.equals.

Indicates whether some other object is "equal to" this one.
Inherited from org.mortbay.io.ByteArrayBuffer:
arraycapacitycompactequalsIgnoreCasegethashCodepeekpeekpokepokepokereadFromspacewrapwrapwriteTo

Constructor Detail

CaseInsensitiveback to summary
public CaseInsensitive(String s)
CaseInsensitiveback to summary
public CaseInsensitive(byte[] b, int o, int l, int rw)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides org.mortbay.io.ByteArrayBuffer.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.