|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.sun.faban.harness.logging.FlexBuffer
public class FlexBuffer
FlexBuffer is an expandable byte buffer. It uses 1 or more byte arrays internally and expands with an array of the initial size at a time. This byte buffer is intended for reuse. The clear() method resets all pointers and the buffer to 0. It does not free up any memory.
| Nested Class Summary | |
|---|---|
class |
FlexBuffer.Tokenizer
A tokenizer for the FlexBuffer. |
| Field Summary | |
|---|---|
static byte |
CR
Carriage return. |
static byte |
LF
Line feed. |
static byte |
WS
White space. |
| Constructor Summary | |
|---|---|
FlexBuffer(byte[] backingArray)
Constructs a FlexBuffer with an initial backing array. |
|
FlexBuffer(byte[] origin,
int start,
int length)
Constructs a FlexBuffer with initial content. |
|
FlexBuffer(int initial)
FlexBuffer constructor. |
|
| Method Summary | |
|---|---|
void |
append(byte b)
Appends one byte to the buffer. |
void |
append(byte[] b)
Appends the content from the whole byte array to the buffer. |
void |
append(byte[] b,
int offset,
int length)
Appends content from byte array to the buffer. |
void |
append(ByteBuffer b,
int length)
Appends content of the nio ByteBuffer of a certain length. |
void |
appendDirect(ByteBuffer b,
int length)
Appends content of the nio direct ByteBuffer of a certain length to the FlexBuffer. |
void |
clear()
Clears the FlexBuffer. |
boolean |
endsWith(String s)
Checks if the string ends with provided string. |
int |
getByte(int pos)
Obtains the byte a a certain position in the buffer. |
byte[] |
getBytes()
Gets a byte array resembling the whole buffer. |
int |
getBytes(int pos,
byte[] b,
int off,
int length)
Copies buffer content into byte array. |
byte[] |
getBytes(int pos,
int length)
Gets a byte array resembling part of the buffer. |
String |
getString(int pos,
int length)
Obtains a String representation of all or part of the buffer. |
FlexBuffer.Tokenizer |
getTokenizer()
Returns Tokenizer instance. |
String |
getTrimmedString(int pos,
int length)
Trims the string based on the position and the length. |
int |
indexOf(String s)
Searches the byte buffer for the first occurrence of the input string, converted to bytes. |
int |
indexOf(String s,
int start)
Searches the byte buffer for the first occurrence of the input string from a starting index, converted to bytes. |
int |
indexOfBOL(int eol)
Obtains the index of the next line begin, given the EOL marker. |
int |
indexOfEOL(int start)
Searches the buffer for an end-of-line. |
protected void |
nextBuffer()
Switches the buffer to the next one. |
int |
size()
Obtains the size of this buffer. |
String |
toString()
Provides a String representation of the buffer content. |
int |
writeBytes(int pos,
int length,
OutputStream stream)
Writes buffer content into an OutputStream. |
int |
writeBytes(OutputStream stream)
Writes buffer content into an OutputStream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final byte CR
public static final byte LF
public static final byte WS
| Constructor Detail |
|---|
public FlexBuffer(int initial)
initial - The initial size and expansion block
public FlexBuffer(byte[] origin,
int start,
int length)
origin - the byte array to take content fromstart - the starting offset in the byte arraylength - the content length to copypublic FlexBuffer(byte[] backingArray)
backingArray - The byte array to be used as a backing array.| Method Detail |
|---|
public void clear()
protected void nextBuffer()
public void append(byte b)
b - byte to append
public void append(byte[] b,
int offset,
int length)
b - byte array to appendoffset - the offset to start appendinglength - the length to start appendingpublic void append(byte[] b)
b - byte array to append
public void append(ByteBuffer b,
int length)
b - The bufferlength - append
public void appendDirect(ByteBuffer b,
int length)
b - The bufferlength - The length to appendpublic int size()
public byte[] getBytes()
public byte[] getBytes(int pos,
int length)
pos - starting position in the bufferlength - content length
public int getBytes(int pos,
byte[] b,
int off,
int length)
pos - position to start copy in the bufferb - byte array to copy intooff - offset in the byte array to start copylength - content length to copy
public int writeBytes(int pos,
int length,
OutputStream stream)
throws IOException
pos - position to start copy in the bufferlength - content length to copystream - the output stream to write to
IOException - write error
public int writeBytes(OutputStream stream)
throws IOException
stream - the output stream to write to
IOException - write error
public String getString(int pos,
int length)
pos - The starting positionlength - The length
public String getTrimmedString(int pos,
int length)
pos - The starting positionlength - The length
public int getByte(int pos)
pos - the position of the byte
public int indexOf(String s)
s - the string to match
public boolean endsWith(String s)
s - The string to check the buffer against
public int indexOf(String s,
int start)
s - the string to matchstart - the search starting point
public int indexOfEOL(int start)
start - The offset to start searching
public int indexOfBOL(int eol)
Note: the method does not actually check that
eol - The EOL index
public String toString()
toString in class Objectpublic FlexBuffer.Tokenizer getTokenizer()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||