public class SubString extends DataObject
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).
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
SubString()
Create a new SubString - use one of the set() methods to setup the
text for the SubString.
|
Modifier and Type | Method and Description |
---|---|
void |
cache()
Put this object into a cache of re-usable objects.
|
void |
cached() |
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.
|
static SubString |
getCached() |
SubString |
getCopy(SubString destination,
char[] copyDataInto)
Get a copy of the SubString.
|
Object |
getNew()
This returns a new SubString().
|
SubString |
getStringChars(String s)
Convert a String to a SubString without making a copy of the String characters if
possible.
|
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[] other,
int otherStart,
int otherLength,
char[] inStr,
int strStart,
int strLength,
int start)
Find the index of a string within another string.
|
static int |
indexOf(char[] subString,
int ssStart,
int ssLength,
String inStr)
Find the index of a string within another string.
|
static int |
indexOf(char what,
char[] str,
int strStart,
int strLength,
int start,
int options) |
int |
indexOf(int ch) |
int |
indexOf(int ch,
int start) |
boolean |
isNull()
Return if this SubString is null (i.e. it's data is null).
|
int |
lastIndexOf(int ch) |
int |
lastIndexOf(int ch,
int start) |
int |
length()
Get the length of the SubString.
|
void |
replace(char[] what,
char[] with) |
SubString |
set(char[] dt,
int st,
int len) |
SubString |
set(CharArray ca) |
SubString |
set(CharArray ca,
int start,
int end) |
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.
|
int |
split(char separator,
Vector destination,
int destinationStart,
Vector used)
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 SubStrings 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.
|
_getFieldType, _getSetField, copied, copyFrom, equals, getCopy, getDeclaredField, getDeclaredFieldValue, getMyFieldList
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
public SubString()
public Object getNew()
getNew
in interface DataUnit
getNew
in class DataObject
public String toString()
public 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, int st, int len)
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, Vector used)
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.destinationStart.
- This tells which index in the destination Vector to start placing
SubString values into.used
- an optional array containing SubStrings that may be re-used.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.destinationStart.
- This tells which index in the destination Vector to start placing
SubString values into.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[] other, int otherStart, int otherLength, char[] inStr, int strStart, int strLength, int start)
other
- the characters of the smaller String.otherStart
- the start of the smaller String in the array.otherLength
- the number of characters in the smaller String.inStr
- the larger String to search within.strStart
- the start of the larger String characters in the array.strLength
- the number of characters in the larger String.start
- the first location to start looking from (this must be absolute and
not relative to strStart).public static int indexOf(char[] subString, int ssStart, int ssLength, String inStr)
other
- the characters of the smaller String.otherStart
- the start of the smaller String in the array.otherLength
- the number of characters in the smaller String.inStr
- the larger String to search within.public static int indexOf(char what, char[] str, int strStart, int strLength, int start, int options)
public static int compare(char[] one, int oneStart, int oneLength, char[] two, int twoStart, int twoLength)
public int compareTo(Object other)
compareTo
in interface Comparable
compareTo
in class DataObject
other
- 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 int hashCode()
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)
public static SubString getCached()
public SubString getStringChars(String s)
s
- the String to access the char data of.public void cache()
DataObject
cache
in class DataObject
public void cached()
public int indexOf(int ch)
public int indexOf(int ch, int start)
public int lastIndexOf(int ch)
public int lastIndexOf(int ch, int start)