|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.bb.util.ByteRef
public final class ByteRef
A String like class to manipulate byte arrays. The most important differences to Strings:
ByteRef share their bufferByteRef must handle them correctly. The result is a big speed gain in data parsing and handling.
For not yet or bad documented functions search the comment in the String class (or guess).
| Constructor Summary | |
|---|---|
ByteRef()
Initializes a newly created ByteRef object so that it
represents an empty byte sequence. |
|
ByteRef(byte[] b)
Initializes a newly created ByteRef object so that it
represents the same sequence of bytes as the argument; in other
words, the newly created byte array is a copy of the argument. |
|
ByteRef(byte[] b,
int _begin,
int _end)
Initializes a newly created ByteRef object so that it
represents the same sequence of bytes as the argument; in other
words, the newly created byte array is a copy of the specified part of the argument. |
|
ByteRef(java.lang.String s)
Initializes a newly created ByteRef object so that it
represents the same sequence of bytes as the argument; in other
words, the newly created byte array is a copy of the argument string.getBytes(). |
|
| Method Summary | |
|---|---|
void |
adjustLeft(int count)
Move the left offset by count bytes. |
ByteRef |
append(ByteRef o)
Append the specified ByteRef to this ByteRef. |
ByteRef |
append(java.lang.String s)
Append the bytes of the String to this ByteRef. |
void |
assign(byte[] b,
int _begin,
int _end)
Assigns the parameters physical byte array to this object. |
void |
assign(ByteRef o)
Assigns the parameters physical byte array to this object. |
int |
charAt(int idx)
Returns the byte at the specified position. |
java.lang.Object |
clone()
|
int |
compareTo(ByteRef o)
Compares this ByteRef's data to another ByteRef. |
void |
copy(byte[] b)
Copy this data into the specified byte array. |
int |
copy(byte[] b,
int off,
int l)
Copy a part of this data into the specified byte array at specified offset. |
boolean |
endsWith(ByteRef o)
Tests whether this BytRef ends with the specified ByteRef. |
boolean |
endsWith(java.lang.String s)
Tests whether this BytRef ends with the specified String. |
boolean |
equals(java.lang.Object _o)
Compares this objects data to another object. |
boolean |
equalsIgnoreCase(java.lang.Object _o)
Compares this objects data to another object ignoring upper and lower case. |
int |
hashCode()
Compute a hashCode for use in Hashtable. |
int |
indexOf(ByteRef s)
Returns the first index of the specified ByteRef's bytes. |
int |
indexOf(ByteRef s,
int off)
Returns the first index of the specified ByteRef's bytes. |
int |
indexOf(int z)
Returns the first index of the specified byte. |
int |
indexOf(int z,
int off)
Returns the first index of the specified byte. |
int |
indexOf(java.lang.String s)
Returns the first index of the specified String's bytes. |
int |
indexOf(java.lang.String s,
int off)
Returns the first index of the specified String's bytes. |
int |
lastIndexOf(int z)
Returns the last index of the specified byte. |
int |
lastIndexOf(int z,
int off)
Returns the last index of the specified byte. |
int |
length()
Return the length of this ByteRef object. |
ByteRef |
nextLine()
Extracts the next available line from this object and returns that line as a new BytRef object. |
ByteRef |
nextWord()
Extracts the next available word from this object and returns that word as a new BytRef object. |
ByteRef |
nextWord(int delim)
Extracts the content from this object up to the delimiter and returns that as a new BytRef object. |
java.lang.String |
nextWordAsString(int delim)
Extracts the content from this object up to the delimiter and returns that as a new BytRef object. |
static ByteRef |
readLine(ByteRef br,
java.io.InputStream is)
Extracts the next line from the specified ByteRef br. |
int |
removeLeft()
Remove the first byte and return it as int >= 0 or return -1; This is a self modification. |
ByteRef |
splitLeft(int stop)
Returns a ByteRef starting from 0 to stop, and removes this part from the current ByteRef. |
ByteRef |
splitLeft(int start,
int stop)
Returns a ByteRef starting from start to stop, and removes this part from the current ByteRef. |
boolean |
startsWith(ByteRef o)
Tests whether this BytRef starts with the specified ByteRef. |
boolean |
startsWith(java.lang.String s)
Tests whether this BytRef starts with the specified String. |
ByteRef |
substring(int a)
Returns a new BytRef object using only the specified part of this ByteRef, up to end of this ByteRef. |
ByteRef |
substring(int a,
int z)
Returns a new BytRef object using only the specified part of this ByteRef. |
byte[] |
toByteArray()
Returns the ByteRefs data as a new byte array. |
int |
toInteger()
Interpret the bytes as characters and convert them into an int value. |
ByteRef |
toLowerCase()
Converts upper case letters into lower case letters. |
java.lang.String |
toString()
Returns the ByteRefs data as a String. |
java.lang.String |
toString(int offset)
Returns the ByteRefs data as a String starting from specified offset. |
ByteRef |
toUpperCase()
Converts lower case letters into lower case letters. |
ByteRef |
trim()
Remove all white spaces at begin and end. |
ByteRef |
trim(int ch)
Remove all occurencies of the specified charater at begin and end. |
ByteRef |
update(java.io.InputStream is)
Update this ByteRef with the availabledata of the specified input stream. |
void |
writeTo(java.io.OutputStream os)
Write the bytes to the specified output stream. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ByteRef()
ByteRef object so that it
represents an empty byte sequence.
public ByteRef(java.lang.String s)
ByteRef object so that it
represents the same sequence of bytes as the argument; in other
words, the newly created byte array is a copy of the argument string.getBytes().
s - a String.public ByteRef(byte[] b)
ByteRef object so that it
represents the same sequence of bytes as the argument; in other
words, the newly created byte array is a copy of the argument.
b - a byte array.
public ByteRef(byte[] b,
int _begin,
int _end)
ByteRef object so that it
represents the same sequence of bytes as the argument; in other
words, the newly created byte array is a copy of the specified part of the argument.
b - a byte array._begin - begin in the byte array_end - end in the byte array| Method Detail |
|---|
public void assign(ByteRef o)
o - a ByteRef
public final void assign(byte[] b,
int _begin,
int _end)
b - a byte array_begin - begin in the byte array_end - end in the byte arraypublic final ByteRef nextLine()
BytRef object.
Unix and DOS EOLs are recognized correctly. MAC EOLs will fail at end of buffer!
ByteRef object with the next line, or null if no EOL was found.public final ByteRef nextWord()
BytRef object.
All bytes < 0x20 are treated as white spaces.
ByteRef object with the next word, or null at end of buffer.public final ByteRef nextWord(int delim)
BytRef object.
The current object is modified and contains the remaining content behind the delimiter.
delim - the used delimiter
ByteRef object with the next word, or null at end of buffer.public final java.lang.String nextWordAsString(int delim)
BytRef object.
The current object is modified and contains the remaining content behind the delimiter.
delim - the used delimiter
String object with the next word, or null at end of buffer.public final int length()
ByteRef object.
ByteRef objectpublic final void copy(byte[] b)
byte array.
b - a byte array
public final int copy(byte[] b,
int off,
int l)
byte array at specified offset.
b - a byte arrayoff - the offset into bl - the copied length
public final ByteRef append(ByteRef o)
ByteRef to this ByteRef.
A new ByteRef is allocated and returned, to store the concatenation of both ByteRefs.
o - the appended ByteRef
ByteRef object with the concatenation of both ByteRefs.public final ByteRef append(java.lang.String s)
String to this ByteRef.
A new ByteRef is allocated and returned, to store the concatenation.
s - the appended String
ByteRef object with the concatenation.public final java.lang.String toString()
ByteRefs data as a String.
toString in class java.lang.ObjectByteRefs data as a String.public final java.lang.String toString(int offset)
ByteRefs data as a String starting from specified offset.
offset - starting from offset
ByteRefs data as a String.public final byte[] toByteArray()
ByteRefs data as a new byte array.
ByteRefs data as a new byte array.public final ByteRef toUpperCase()
public final ByteRef toLowerCase()
public final int lastIndexOf(int z)
z - the searched byte
public final int lastIndexOf(int z,
int off)
z - the searched byteoff - the offset (from begin) where search starts
public final int indexOf(int z)
z - the searched byte
public final int indexOf(int z,
int off)
z - the searched byteoff - the offset (from begin) where search starts
public final int indexOf(java.lang.String s)
s - the searched String
public final int indexOf(java.lang.String s,
int off)
s - the searched Stringoff - the offset (from begin) where search starts
public final int indexOf(ByteRef s,
int off)
s - the searched ByteRefoff - the offset (from begin) where search starts
public final int indexOf(ByteRef s)
s - the searched ByteRef
public final ByteRef substring(int a,
int z)
ByteRef.
a - begin of used bytesz - end of used bytes
ByteRef.public final ByteRef substring(int a)
ByteRef, up to end of this ByteRef.
a - begin of used bytes
ByteRef.public final int charAt(int idx)
idx - index of the byte
public final int hashCode()
hashCode in class java.lang.Objectpublic final boolean equals(java.lang.Object _o)
equals in class java.lang.Object_o - an Object
public final boolean equalsIgnoreCase(java.lang.Object _o)
_o - an Object
public final int compareTo(ByteRef o)
ByteRef's data to another ByteRef.
o - a ByteRef object
ByteRef contains same data, -1 when this is less and 1 when this is greater then the other ByteRef.public final boolean endsWith(ByteRef o)
ByteRef.
o - the other ByteRef where the end is tested against
ByteRefpublic final boolean endsWith(java.lang.String s)
s - the other String where the end is tested against
Stringpublic final boolean startsWith(ByteRef o)
ByteRef.
o - the other ByteRef where the end is tested against
ByteRefpublic final boolean startsWith(java.lang.String s)
s - the other String where the end is tested against
String
public final void writeTo(java.io.OutputStream os)
throws java.io.IOException
os - a output stream
java.io.IOException - on io errorspublic final ByteRef trim(int ch)
ch - a character value
ByteRef with the trimed data.public final ByteRef trim()
ByteRef with the trimed data.public final int toInteger()
public final ByteRef update(java.io.InputStream is)
ByteRef with the availabledata of the specified input stream.
current object's data is also updated!.
is - an input stream
public static final ByteRef readLine(ByteRef br,
java.io.InputStream is)
ByteRef br.
If there is no complete line in br, the ByteRef is updated using the specified input stream.
This is done until a complete line is read, or br.update(is) fails.
br - the ByteRef used as input bufferis - a input stream
ByteRef containing the next line, or null on EOS.public final java.lang.Object clone()
clone in class java.lang.Objectpublic final ByteRef splitLeft(int stop)
stop - end position
public final ByteRef splitLeft(int start,
int stop)
start - start position for returned ByteRefstop - stop position for returned ByteRef
public final int removeLeft()
public final void adjustLeft(int count)
count - the count of bytes to remove from left side.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||