|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.util.SubString
This is a very specialized Utility class used for bulk processing of text strings, while minimizing overheads of new Object creation.
A SubString consists of a reference to a character array (which may be shared by other SubStrings), a start index within the array and a length value for the sub-string.
You can manipulate a SubString in many of the same ways as you do a String, but unlike a String, a SubString is mutable (since you have full access to its data and its start and length values).
| Field Summary | |
static int |
BACKWARDS
An option for equals(). |
char[] |
data
|
static int |
IGNORE_CASE
An option for equals(). |
int |
length
|
int |
start
|
static int |
STARTS_WITH
An option for equals(). |
| Constructor Summary | |
SubString()
Create a new SubString - use one of the set() methods to setup the text for the SubString. |
|
| Method Summary | |
char |
charAt(int idx)
Return the character at a particular index. |
static int |
compare(char[] one,
int oneStart,
int oneLength,
char[] two,
int twoStart,
int twoLength)
This does a numeric char for char comparison. |
int |
compareTo(Object other)
Compare this SubString with either another SubString or a String. |
int |
compareTo(Object other,
int options)
Compare this SubString with either another SubString or a String. |
void |
copyInto(byte[] dest,
int offset,
boolean ascii)
Copy all the characters of this substring into a byte array. |
void |
copyInto(byte[] dest,
int offset,
int len,
int startPoint,
boolean ascii)
Copy a subset of this SubStrings data into a byte array. |
void |
copyInto(char[] dest,
int offset)
Copy all the characters of this substring into a character array. |
void |
copyInto(char[] dest,
int offset,
int len,
int startPoint)
Copy a subset of this SubStrings data into a character array. |
boolean |
endsWith(String endWith)
Check if the SubString endsWith a particular String. |
static boolean |
equals(char[] big,
int bigStart,
int bigLength,
char[] small,
int smallStart,
int smallLength,
int options)
This compares the character sequence given by the "small" parameters to the character sequence given by the "big" parameters. |
boolean |
equals(Object other)
Compare this SubString with either another SubString or a String. |
SubString |
getCopy(SubString destination,
char[] copyDataInto)
Get a copy of the SubString. |
SubString |
getNew()
Get a new SubString(). |
int |
hashCode()
As specified in the hashCode() contract, this returns the same hashCode that a String with the same text would return. |
static int |
indexOf(char what,
char[] str,
int strStart,
int strLength,
int start,
int options)
Find the index of a character within an array of characters, looking either backwards or forwards. |
boolean |
isNull()
Return if this SubString is null (i.e. |
int |
length()
Get the length of the SubString. |
void |
replace(char[] what,
char[] with)
|
SubString |
set(char[] dt,
int st,
int len)
|
SubString |
set(String string)
|
SubString |
set(String string,
int st,
int len)
Create a SubString based on a substring of the text in the provided String. |
int |
split(char separator,
Vector destination)
This will split this substring and place the results as a series of SubString objects in the destination list. |
int |
split(char separator,
Vector destination,
int destinationStart)
This will split this substring and place the results as a series of SubString objects in the destination list. |
static Vector |
split(String what,
char separator,
Vector dest)
Split a String into smaller sub Strings placed in an output Vector. |
boolean |
startsWith(String startWith)
Check if the SubString startsWith a particular String. |
String |
substring(int start,
int length)
Get a new SubString that is a substring of this SubString. |
SubString |
substring(int start,
int length,
SubString destination)
Get a new SubString that is a substring of this SubString. |
SubString |
substring(int start,
int length,
SubString destination,
char[] copyDataInto)
Get a new SubString that is a substring of this SubString, optionally copying the data out into a new array. |
void |
toLowerCase()
|
String |
toString()
Return a String representation of this SubString. |
void |
toUpperCase()
|
void |
trim()
Trim the SubString so there are no leading or trailing spaces or Tabs. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass |
| Field Detail |
public char[] data
public int start
public int length
public static final int IGNORE_CASE
public static final int STARTS_WITH
public static final int BACKWARDS
| Constructor Detail |
public SubString()
| Method Detail |
public String toString()
toString in class Objectpublic boolean isNull()
public int length()
public char charAt(int idx)
public void copyInto(char[] dest,
int offset)
dest - The destination character array.offset - The offset in the destination to start copying into.
public void copyInto(char[] dest,
int offset,
int len,
int startPoint)
dest - The destination character array.offset - The offset in the destination to start copying into.len - The number of characters to copy.startPoint - The first index in this substring to copy from.
public void copyInto(byte[] dest,
int offset,
boolean ascii)
dest - The destination byte array.offset - The offset in the destination to start copying into.ascii - if this is true then only the low byte is copied into the destination.
If you want to do Utf8 encoding, then see the encode method.
public void copyInto(byte[] dest,
int offset,
int len,
int startPoint,
boolean ascii)
dest - The destination byte array.offset - The offset in the destination to start copying into.len - The number of characters to copy.startPoint - The first index in this substring to copy from.ascii - if this is true then only the low byte is copied into the destination.
If you want to do Utf8 encoding, then see the encode method.
public SubString set(char[] dt,
int st,
int len)
public SubString set(String string)
public SubString set(String string,
int st,
int len)
public SubString getNew()
public int split(char separator,
Vector destination)
separator - The separator character. A separator of ' ' (a space) will
also use the TAB ('\t') as a separator. A space separator also has the property
that a sequence of more than one space or TAB characters will be considered as just one
separator. So a line like "hello there how are you" will be separated into the five
words exactly.destination - This is the destination vector (which must NOT be null) in which SubString
objects representing each separated text is placed.
public int split(char separator,
Vector destination,
int destinationStart)
separator - The separator character. A separator of ' ' (a space) will
also use the TAB ('\t') as a separator. A space separator also has the property
that a sequence of more than one space or TAB characters will be considered as just one
separator. So a line like "hello there how are you" will be separated into the five
words exactly.destination - This is the destination vector (which must NOT be null) in which SubString
objects representing each separated text is placed.
public static Vector split(String what,
char separator,
Vector dest)
what - The String to split.separator - The separator character.dest - A destination Vector (which may be null).
public static boolean equals(char[] big,
int bigStart,
int bigLength,
char[] small,
int smallStart,
int smallLength,
int options)
public static int indexOf(char what,
char[] str,
int strStart,
int strLength,
int start,
int options)
what - The character to look for.str - The array of characters to look in.strStart - The start of the source characters in the array.strLength - The number of source characters in the array.start - The location in str to start looking from (which should be >= strStart and < strStart+strLength).
This character is always included in the search whether going backwards or forwards.options - This can be 0 or BACKWARDS to start searching backwards.
public static int compare(char[] one,
int oneStart,
int oneLength,
char[] two,
int twoStart,
int twoLength)
public int compareTo(Object other)
compareTo in interface Comparableother - Either another SubString or a String.
public int compareTo(Object other,
int options)
other - Either another SubString or a String.options - This can be IGNORE_CASE or 0.
public boolean equals(Object other)
equals in class Objectother - Either another SubString or a String.
public int hashCode()
hashCode in class Object
public SubString substring(int start,
int length,
SubString destination,
char[] copyDataInto)
start - The first index in this SubString.length - The number of characters.destination - The destination SubString. If this is null a new one will be created.copyDataInto - If this is null then the new SubString will reference the original
character array for its data. If it is not null then the characters will be copied into
this array. if this array is not big enough, a new one will be created and that one will
be used instead.
public void toUpperCase()
public void toLowerCase()
public SubString substring(int start,
int length,
SubString destination)
start - The first index in this SubString.length - The number of characters.destination - The destination SubString. If this is null a new one will be created.
public String substring(int start,
int length)
start - The first index in this SubString.length - The number of characters.
public SubString getCopy(SubString destination,
char[] copyDataInto)
destination - The destination SubString. If this is null a new one will be created.copyDataInto - If this is null then the new SubString will reference the original
character array for its data. If it is not null then the characters will be copied into
this array. if this array is not big enough, a new one will be created and that one will
be used instead.
public boolean startsWith(String startWith)
public boolean endsWith(String endWith)
public void trim()
public void replace(char[] what,
char[] with)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||