public class CharRef
extends java.lang.Object
implements java.lang.Cloneable
A String like class to manipulate byte arrays. The most important differences to Strings:
CharRef share their bufferCharRef 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 and Description |
|---|
CharRef()
Initializes a newly created
CharRef object so that it
represents an empty byte sequence. |
CharRef(char[] b)
Initializes a newly created
CharRef 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. |
CharRef(char[] b,
int _begin,
int _end)
Initializes a newly created
CharRef object so that it
represents the same sequence of chars as the argument; in other
words, the newly created char array is a copy of the specified part of the argument. |
CharRef(java.lang.String s)
Initializes a newly created
CharRef 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.getChars(). |
| Modifier and Type | Method and Description |
|---|---|
CharRef |
append(CharRef o)
Append the specified
CharRef to this CharRef. |
CharRef |
append(java.lang.String s)
Append the chars of the
String to this CharRef. |
void |
assign(char[] b,
int _begin,
int _end)
Assigns the parameters physical char array to this object.
|
void |
assign(CharRef o)
Assigns the parameters physical char array to this object.
|
int |
charAt(int idx)
Returns the char at the specified position.
|
java.lang.Object |
clone() |
int |
compareTo(CharRef o)
Compares this
CharRef's data to another CharRef. |
void |
copy(byte[] b)
Copy this data into the specified
char array. |
void |
copy(char[] b)
Copy this data into the specified
char array. |
int |
copy(char[] b,
int off,
int l)
Copy a part of this data into the specified
char array at specified offset. |
boolean |
endsWith(CharRef o)
Tests whether this BytRef ends with the specified
CharRef. |
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(CharRef s)
Returns the first index of the specified CharRef's chars.
|
int |
indexOf(CharRef s,
int off)
Returns the first index of the specified CharRef's chars.
|
int |
indexOf(int z)
Returns the first index of the specified char.
|
int |
indexOf(int z,
int off)
Returns the first index of the specified char.
|
int |
indexOf(java.lang.String s)
Returns the first index of the specified String's chars.
|
int |
indexOf(java.lang.String s,
int off)
Returns the first index of the specified String's chars.
|
int |
lastIndexOf(int z)
Returns the last index of the specified char.
|
int |
lastIndexOf(int z,
int off)
Returns the last index of the specified char.
|
int |
length()
Return the length of this
CharRef object. |
CharRef |
nextLine()
Extracts the next available line from this object and returns that line as a new
BytRef object. |
CharRef |
nextWord()
Extracts the next available word from this object and returns that word as a new
BytRef object. |
CharRef |
nextWord(int delim)
Extracts the next available word from this object and returns that word as a new
BytRef object. |
static CharRef |
readLine(CharRef br,
java.io.InputStream is)
Extracts the next line from the specified
CharRef br. |
CharRef |
splitLeft(int stop)
Returns a CharRef starting from 0 to stop,
and removes this part from the current CharRef.
|
CharRef |
splitLeft(int start,
int stop)
Returns a CharRef starting from start to stop,
and removes this part from the current CharRef.
|
boolean |
startsWith(CharRef o)
Tests whether this BytRef starts with the specified
CharRef. |
boolean |
startsWith(java.lang.String s)
Tests whether this BytRef starts with the specified String.
|
CharRef |
substring(int a)
Returns a new BytRef object using only the specified part of this
CharRef, up to end of this CharRef. |
CharRef |
substring(int a,
int z)
Returns a new BytRef object using only the specified part of this
CharRef. |
char[] |
toCharArray()
Returns the
CharRefs data as a new char array. |
int |
toInteger()
Interpret the chars as characters and convert them into an int value.
|
CharRef |
toLowerCase()
Converts upper case letters into lower case letters.
|
java.lang.String |
toString()
Returns the
CharRefs data as a String. |
CharRef |
toUpperCase()
Converts lower case letters into lower case letters.
|
CharRef |
trim()
Remove all white spaces at begin and end.
|
CharRef |
trim(int ch)
Remove all occurencies of the specified charater at begin and end.
|
CharRef |
update(java.io.InputStream is)
Update this
CharRef with the availabledata of the specified input stream. |
void |
writeTo(java.io.OutputStream os)
Write the chars to the specified output stream.
|
public CharRef()
CharRef object so that it
represents an empty byte sequence.public CharRef(java.lang.String s)
CharRef 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.getChars().s - a String.public CharRef(char[] b)
CharRef 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 char array.public CharRef(char[] b,
int _begin,
int _end)
CharRef object so that it
represents the same sequence of chars as the argument; in other
words, the newly created char array is a copy of the specified part of the argument.b - a char array._begin - begin in the char array_end - end in the char arraypublic void assign(CharRef o)
o - a CharRefpublic void assign(char[] b,
int _begin,
int _end)
b - a char array_begin - begin in the char array_end - end in the char arraypublic CharRef nextLine()
BytRef object.
Unix and DOS EOLs are recognized correctly. MAC EOLs will fail at end of buffer!CharRef object with the next line, or null if no EOL was found.public CharRef nextWord()
BytRef object.
All chars < 0x20 are treated as white spaces.CharRef object with the next word, or null at end of buffer.public CharRef nextWord(int delim)
BytRef object.delim - the used delimiterCharRef object with the next word, or null at end of buffer.public int length()
CharRef object.CharRef objectpublic void copy(byte[] b)
char array.b - a char arraypublic void copy(char[] b)
char array.b - a char arraypublic int copy(char[] b,
int off,
int l)
char array at specified offset.b - a char arrayoff - the offset into bl - the copied lengthpublic CharRef append(CharRef o)
CharRef to this CharRef.
A new CharRef is allocated and returned, to store the concatenation of both CharRefs.o - the appended CharRefCharRef object with the concatenation of both CharRefs.public CharRef append(java.lang.String s)
String to this CharRef.
A new CharRef is allocated and returned, to store the concatenation.s - the appended StringCharRef object with the concatenation.public java.lang.String toString()
CharRefs data as a String.toString in class java.lang.ObjectCharRefs data as a String.public char[] toCharArray()
CharRefs data as a new char array.CharRefs data as a new char array.public CharRef toUpperCase()
public CharRef toLowerCase()
public int lastIndexOf(int z)
z - the searched charpublic int lastIndexOf(int z,
int off)
z - the searched charoff - the offset (from begin) where search startspublic int indexOf(int z)
z - the searched charpublic int indexOf(int z,
int off)
z - the searched charoff - the offset (from begin) where search startspublic int indexOf(java.lang.String s)
s - the searched Stringpublic int indexOf(java.lang.String s,
int off)
s - the searched Stringoff - the offset (from begin) where search startspublic int indexOf(CharRef s, int off)
s - the searched CharRefoff - the offset (from begin) where search startspublic int indexOf(CharRef s)
s - the searched CharRefpublic CharRef substring(int a, int z)
CharRef.a - begin of used charsz - end of used charsCharRef.public CharRef substring(int a)
CharRef, up to end of this CharRef.a - begin of used charsCharRef.public int charAt(int idx)
idx - index of the charpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object _o)
equals in class java.lang.Object_o - an Objectpublic boolean equalsIgnoreCase(java.lang.Object _o)
_o - an Objectpublic int compareTo(CharRef o)
CharRef's data to another CharRef.o - a CharRef objectCharRef contains same data, -1 when this is less and 1 when this is greater then the other CharRef.public boolean endsWith(CharRef o)
CharRef.o - the other CharRef where the end is tested againstCharRefpublic boolean endsWith(java.lang.String s)
s - the other String where the end is tested againstStringpublic boolean startsWith(CharRef o)
CharRef.o - the other CharRef where the end is tested againstCharRefpublic boolean startsWith(java.lang.String s)
s - the other String where the end is tested againstStringpublic void writeTo(java.io.OutputStream os)
throws java.io.IOException
os - a output streamjava.io.IOException - on io errorspublic CharRef trim(int ch)
ch - a character valueCharRef with the trimed data.public CharRef trim()
CharRef with the trimed data.public int toInteger()
public CharRef update(java.io.InputStream is)
CharRef with the availabledata of the specified input stream.
current object's data is also updated!.is - an input streampublic static CharRef readLine(CharRef br, java.io.InputStream is)
CharRef br.
If there is no complete line in br, the CharRef is updated using the specified input stream.
This is done until a complete line is read, or br.update(is) fails.br - the CharRef used as input bufferis - a input streamCharRef containing the next line, or null on EOS.public java.lang.Object clone()
clone in class java.lang.Objectpublic CharRef splitLeft(int stop)
stop - end positionpublic CharRef splitLeft(int start, int stop)
start - start position for returned CharRefstop - stop position for returned CharRef