|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Buffer
Byte Buffer interface. This is a byte buffer that is designed to work like a FIFO for bytes. Puts and Gets operate on different pointers into the buffer and the valid _content of the buffer is always between the getIndex and the putIndex. This buffer interface is designed to be similar, but not dependant on the java.nio buffers, which may be used to back an implementation of this Buffer. The main difference is that NIO buffer after a put have their valid _content before the position and a flip is required to access that data. For this buffer it is always true that: markValue <= getIndex <= putIndex <= capacity
Nested Class Summary | |
---|---|
static interface |
Buffer.CaseInsensitve
|
Field Summary | |
---|---|
static int |
IMMUTABLE
|
static boolean |
NON_VOLATILE
|
static int |
READONLY
|
static int |
READWRITE
|
static boolean |
VOLATILE
|
Method Summary | |
---|---|
byte[] |
array()
Get the underlying array, if one exists. |
byte[] |
asArray()
|
Buffer |
asImmutableBuffer()
|
Buffer |
asMutableBuffer()
|
Buffer |
asNonVolatileBuffer()
|
Buffer |
asReadOnlyBuffer()
|
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 |
equalsIgnoreCase(Buffer buffer)
|
byte |
get()
Get the byte at the current getIndex and increment it. |
int |
get(byte[] b,
int offset,
int length)
Get bytes from the current postion and put them into the passed byte array. |
Buffer |
get(int length)
|
int |
getIndex()
The index within the buffer that will next be read or written. |
boolean |
hasContent()
|
boolean |
isImmutable()
|
boolean |
isReadOnly()
|
boolean |
isVolatile()
|
int |
length()
The number of bytes from the getIndex to the putIndex |
void |
mark()
Set the mark to the current getIndex. |
void |
mark(int offset)
Set the mark relative to the current getIndex |
int |
markIndex()
The current index of the mark. |
byte |
peek()
Get the byte at the current getIndex without incrementing the getIndex. |
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. |
int |
put(Buffer src)
Write the bytes from the source buffer to the current getIndex. |
void |
put(byte b)
Put a byte to the current getIndex and increment the getIndex. |
int |
put(byte[] b)
Put a byte to the current getIndex and increment the getIndex. |
int |
put(byte[] b,
int offset,
int length)
Put a byte to the current getIndex and increment the getIndex. |
int |
putIndex()
The index of the first element that should not be read. |
int |
readFrom(InputStream in,
int max)
Read the buffer's contents from the input stream |
void |
reset()
Reset the current getIndex to the mark |
void |
setGetIndex(int newStart)
Set the buffers start getIndex. |
void |
setMarkIndex(int newMark)
Set a specific value for the mark. |
void |
setPutIndex(int newLimit)
|
int |
skip(int n)
Skip _content. |
Buffer |
slice()
|
Buffer |
sliceFromMark()
|
Buffer |
sliceFromMark(int length)
|
int |
space()
the space remaining in the buffer. |
String |
toDetailString()
|
void |
writeTo(OutputStream out)
Write the buffer's contents to the output stream |
Field Detail |
---|
static final int IMMUTABLE
static final int READONLY
static final int READWRITE
static final boolean VOLATILE
static final boolean NON_VOLATILE
Method Detail |
---|
byte[] array()
byte[]
backing this buffer or null if none exists.byte[] asArray()
byte[]
value of the bytes from the getIndex to the putIndex.Buffer buffer()
Buffer asNonVolatileBuffer()
Buffer
valueBuffer asReadOnlyBuffer()
Buffer
.Buffer asImmutableBuffer()
Buffer
.Buffer asMutableBuffer()
Buffer
.int capacity()
int
valueint space()
void clear()
void compact()
byte get()
byte
value from the current getIndex.int get(byte[] b, int offset, int length)
b
- The byte array to fill.offset
- Offset in the array.length
- The max number of bytes to read.
Buffer get(int length)
length
- an int
value
Buffer
valueint getIndex()
int
value >=0 <= putIndex()boolean hasContent()
boolean equalsIgnoreCase(Buffer buffer)
boolean
value true if case sensitive comparison on this bufferboolean isImmutable()
boolean
value true if the buffer is immutable and that neither
the buffer contents nor the indexes may be changed.boolean isReadOnly()
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.boolean isVolatile()
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.int length()
int
== putIndex()-getIndex()void mark()
void mark(int offset)
offset
- an int
value to add to the current getIndex to obtain the mark value.int markIndex()
int
index in the buffer or -1 if the mark is not set.byte peek()
byte
value from the current getIndex.byte peek(int index)
index
- an int
value
byte
valueBuffer peek(int index, int length)
index
- an int
valuelength
- an int
value
Buffer
value from the requested getIndex.int peek(int index, byte[] b, int offset, int length)
index
- an int
valueb
- The byte array to peek intooffset
- The offset into the array to start peekinglength
- an int
value
int poke(int index, Buffer src)
index
- an int
valuesrc
- a Buffer
. If the source buffer is not modified
void poke(int index, byte b)
index
- an int
valueb
- a byte
valueint poke(int index, byte[] b, int offset, int length)
index
- an int
valueb
- a byte array
value
int put(Buffer src)
src
- The source Buffer
it is not modified.
void put(byte b)
b
- a byte
valueint put(byte[] b, int offset, int length)
b
- a byte
value
int put(byte[] b)
b
- a byte
value
int putIndex()
int
value >= getIndex()void reset()
void setGetIndex(int newStart)
newStart
- an int
valuevoid setMarkIndex(int newMark)
newMark
- an int
valuevoid setPutIndex(int newLimit)
newLimit
- an int
valueint skip(int n)
n
- The number of bytes to skip
Buffer slice()
Buffer
from the postion to the putIndex.Buffer sliceFromMark()
Buffer
value from the mark to the putIndexBuffer sliceFromMark(int length)
length
- an int
value
Buffer
value from the mark of the length requested.String toDetailString()
String
value describing the state and contents of the buffer.void writeTo(OutputStream out) throws IOException
out
-
IOException
int readFrom(InputStream in, int max) throws IOException
in
- input streammax
- maximum number of bytes that may be read
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |