This class is used for defining a region (sub-string) on an existing character array which is provided. This class will not manipulate the underlying data. In particular, there is no terminating zero written into the data.
The represented region is defined by the two fields start and end. The fields are public accessible. In general, while working with a Substring, the size of it should shrink, e.g. by trimming but should not grow. However, if the code using this class is "sure" that enlarging the region does violate the bounds of the buffer, fields start and end might be modified from outside.
If created or set using a reference of class AString, the buffer of AString is not copied. This allows efficient operations on sub-strings of class AString. However, the source string must not be changed (or only in a controlled way) during the use the Substring instance.
Objects of this class can be reused by freshly initializing them using one of the overloaded set methods.
Public Fields | |
char[] | buf |
double | consumedFloat |
long | consumedLong |
int | end |
int | start |
Public Methods | |
Constructors | |
Substring () | |
Substring (Substring substring) | |
Substring (AString src, int regionStart, int regionLength) | |
Substring (AString src, int regionStart) | |
Substring (AString src) | |
Substring (char[] src, int regionStart, int regionLength) | |
Substring (char[] src, int regionStart) | |
Substring (char[] src) | |
Substring (String src, int regionStart, int regionLength) | |
Substring (String src, int regionStart) | |
Substring (String src) | |
Set data | |
Substring | set (Substring src, int regionStart, int regionLength) |
Substring | set (Substring src, int regionStart) |
Substring | set (Substring src) |
Substring | set (AString src, int regionStart, int regionLength) |
Substring | set (AString src, int regionStart) |
Substring | set (AString src) |
Substring | set (char[] src, int regionStart, int regionLength) |
Substring | set (char[] src, int regionStart) |
Substring | set (char[] src) |
Substring | set (String src, int regionStart, int regionLength) |
Substring | set (String src, int regionStart) |
Substring | set (String src) |
State and Character Access | |
int | length () |
void | setNull () |
void | clear () |
boolean | isNull () |
boolean | isNotNull () |
boolean | isEmpty () |
boolean | isNotEmpty () |
char | charAtStart () |
char | charAtEnd () |
char | charAtEnd (int n) |
Consume | |
char | consumeChar () |
char | consumeCharFromEnd () |
int | consumeCharFromEnd (int regionLength, Substring target) |
int | consumeCharFromEnd (int regionLength) |
boolean | consumeChar (char consumable, Case sensitivity, Whitespaces trimBeforeConsume) |
boolean | consumeChar (char consumable, Case sensitivity) |
boolean | consumeChar (char consumable) |
boolean | consumeCharFromEnd (char consumable, Case sensitivity, Whitespaces trimBeforeConsume) |
boolean | consumeCharFromEnd (char consumable, Case sensitivity) |
boolean | consumeCharFromEnd (char consumable) |
int | consumeChars (int regionLength, Substring target) |
int | consumeChars (int regionLength) |
int | consumeToken (Substring target, char separator) |
boolean | consumeString (CharSequence consumable, Case sensitivity, Whitespaces trimBeforeConsume) |
boolean | consumeString (CharSequence consumable, Case sensitivity) |
boolean | consumeString (CharSequence consumable) |
boolean | consumeStringFromEnd (CharSequence consumable, Case sensitivity, Whitespaces trimBeforeConsume) |
boolean | consumeStringFromEnd (CharSequence consumable, Case sensitivity) |
boolean | consumeStringFromEnd (CharSequence consumable) |
int | consumePartOf (String consumable, int minChars, Case sensitivity, Whitespaces trimBeforeConsume) |
int | consumePartOf (String consumable, int minChars, Case sensitivity) |
int | consumePartOf (String consumable, int minChars) |
int | consumePartOf (String consumable) |
Substring | consumeField (char startChar, char endChar, Substring target, Whitespaces trimBeforeConsume) |
Substring | consumeField (char startChar, char endChar, Substring target) |
Substring | split (int position, Substring target, int separatorWidth) |
Comparison | |
int | compareTo (CharSequence cmpString, Case sensitivity, int cmpRegionStart, int cmpRegionLength) |
int | compareTo (CharSequence cmpString, Case sensitivity, int cmpRegionStart) |
int | compareTo (CharSequence cmpString, Case sensitivity) |
int | compareTo (CharSequence cmpString) |
boolean | equals (Object object, Case sensitivity) |
boolean | equals (Object object) |
boolean | equals (AString cmpString, Case sensitivity) |
boolean | equals (AString cmpString) |
boolean | equals (String cmpString, Case sensitivity) |
boolean | equals (String cmpString) |
boolean | equals (Substring cmpString, Case sensitivity) |
boolean | equals (Substring cmpString) |
boolean | equals (CharSequence cmpString, Case sensitivity) |
boolean | equals (CharSequence cmpString) |
boolean | containsAt (CharSequence needle, int pos, Case sensitivity) |
boolean | containsAt (CharSequence needle, int pos) |
boolean | containsAt (AString needle, int pos, Case sensitivity) |
boolean | containsAt (AString needle, int pos) |
boolean | containsAt (Substring needle, int pos, Case sensitivity) |
boolean | containsAt (Substring needle, int pos) |
boolean | startsWith (CharSequence needle, Case sensitivity) |
boolean | startsWith (CharSequence needle) |
boolean | startsWith (AString needle, Case sensitivity) |
boolean | startsWith (AString needle) |
boolean | startsWith (Substring needle, Case sensitivity) |
boolean | startsWith (Substring needle) |
boolean | endsWith (CharSequence needle, Case sensitivity) |
boolean | endsWith (CharSequence needle) |
boolean | endsWith (AString needle, Case sensitivity) |
boolean | endsWith (AString needle) |
boolean | endsWith (Substring needle, Case sensitivity) |
boolean | endsWith (Substring needle) |
Search | |
int | indexOf (char needle, int startIdx) |
int | indexOf (char c) |
int | indexOfOrLength (char needle) |
int | indexOfOrLength (char needle, int startIdx) |
int | indexOf (CharSequence needle, int startIdx, Case sensitivity) |
int | indexOf (CharSequence cs, int startIdx) |
int | indexOf (CharSequence cs) |
int | indexOfFirstDifference (CharSequence needle, Case sensitivity, int startIdx) |
int | indexOfFirstDifference (CharSequence needle, Case sensitivity) |
int | indexOfFirstDifference (CharSequence needle) |
int | indexOfAny (char[] needles, Inclusion inclusion, int startIdx) |
int | indexOfAny (char[] needles, Inclusion inclusion) |
int | lastIndexOfAny (char[] needles, Inclusion inclusion, int startIdx) |
int | lastIndexOfAny (char[] needles, Inclusion inclusion) |
Trim | |
Substring | trimStart (char[] whiteSpaces) |
Substring | trimStart () |
Substring | trimEnd (char[] whiteSpaces) |
Substring | trimEnd () |
Substring | trim (char[] whiteSpaces) |
Substring | trim () |
Conversion | |
void | copyTo (AString target, boolean append) |
void | copyTo (AString target) |
String | toString () |
String | toString (int regionStart, int regionLength) |
String | toString (int regionStart) |
boolean | consumeDecDigits () |
boolean | consumeInt (NumberFormat numberFormat) |
boolean | consumeInt () |
boolean | consumeDec (NumberFormat numberFormat) |
boolean | consumeDec () |
boolean | consumeBin (NumberFormat numberFormat) |
boolean | consumeBin () |
boolean | consumeHex (NumberFormat numberFormat) |
boolean | consumeHex () |
boolean | consumeOct (NumberFormat numberFormat) |
boolean | consumeOct () |
boolean | consumeFloat (NumberFormat numberFormat) |
boolean | consumeFloat () |
Java CharSequence interface implementation | |
char | charAt (int index) |
CharSequence | subSequence (int beginIndex, int endIndex) |
int | hashCode () |
Protected Fields | |
int[] | _adjustedRegion = new int[2] |
Substring | ( | ) |
Empty Constructor. Sets this sub-string to 'null'
Constructs the Substring to be a region of given AString. If the provided values start and length get out of range, they get adjusted.
src | The string we work on. |
regionStart | The start of the region within src. Defaults to 0. |
regionLength | The length of the region within src. Defaults to the length of src. |
Constructs the Substring to be a region of given AString. If the provided values start and length get out of range, they get adjusted.
src | The string we work on. |
regionStart | The start of the region within src. Defaults to 0. |
Substring | ( | char[] | src, |
int | regionStart, | ||
int | regionLength | ||
) |
Constructs the sub-string to work on the provided character array.
src | The string we work on. |
regionStart | The start of the region within src. Defaults to 0. |
regionLength | The length of the region within src. Defaults to the length of src. |
Substring | ( | char[] | src, |
int | regionStart | ||
) |
Constructs the sub-string to work on the provided character array.
src | The string we work on. |
regionStart | The start of the region within src. Defaults to 0. |
Substring | ( | char[] | src | ) |
Constructs the sub-string to work on the provided character array.
src | The character array to work on. |
Substring | ( | String | src, |
int | regionStart, | ||
int | regionLength | ||
) |
Constructs the sub-string to work on the provided String.
src | The string we work on. |
regionStart | The start of the region within src. Defaults to 0. |
regionLength | The length of the region within src. Defaults to the length of src. |
Substring | ( | String | src, |
int | regionStart | ||
) |
Constructs the sub-string to work on the provided String.
src | The string we work on. |
regionStart | The start of the region within src. Defaults to 0. |
Substring | ( | String | src | ) |
Constructs the sub-string to work on the provided String.
src | The String to work on. |
char charAt | ( | int | index | ) |
Returns a character of the sequence.
index | The index of the character to return. |
char charAtEnd | ( | ) |
Retrieve the last character in the substring.
char charAtEnd | ( | int | n | ) |
Retrieve the n-th character in the substring, counted from the end.
n | The offset of the requested character. Attention: n is subtracted from the end. In other words, positive values peek towards the start of the region. |
char charAtStart | ( | ) |
Retrieve the first character in the substring.
void clear | ( | ) |
Sets the represented region to zero length by setting end to start -1.
int compareTo | ( | CharSequence | cmpString | ) |
Compares a given string with this instance.
cmpString | An object of type String, StringBuffer or AString that is compared to this. |
int compareTo | ( | CharSequence | cmpString, |
Case | sensitivity | ||
) |
Compares a given string with this instance.
cmpString | An object of type String, StringBuffer or AString that is compared to this. |
sensitivity | Case sensitivity of the operation. Optional and defaults to Case.Sensitive. |
int compareTo | ( | CharSequence | cmpString, |
Case | sensitivity, | ||
int | cmpRegionStart | ||
) |
Compares a given region of a string with this instance. Regions that are out of bounds get adjusted and then compared.
cmpString | An object of type String, StringBuffer or AString that is compared to this. |
sensitivity | Case sensitivity of the operation. Optional and defaults to Case.Sensitive. |
cmpRegionStart | The start of the substring within the given string that is to be compared to this. Defaults to 0. |
int compareTo | ( | CharSequence | cmpString, |
Case | sensitivity, | ||
int | cmpRegionStart, | ||
int | cmpRegionLength | ||
) |
Compares a given region of a string with this instance. Regions that are out of bounds get adjusted and then compared.
cmpString | An object of type String, StringBuffer or AString that is compared to this. |
sensitivity | Case sensitivity of the operation. Optional and defaults to Case.Sensitive. |
cmpRegionStart | The start of the substring within the given string that is to be compared to this. Defaults to 0. |
cmpRegionLength | The length of the substring within the given string that is to be compared to this. Defaults to Integer.MAX_VALUE. |
boolean consumeBin | ( | ) |
Overloaded version of consumeBin(NumberFormat) providing default value null
for parameter numberFormat (which selects gloabl object NumberFormat.computational).
true
if an value could be parsed, false
otherwise. boolean consumeBin | ( | NumberFormat | numberFormat | ) |
Consumes an unsigned 64-bit integer in binary format at the given position from this string. This is done, by invoking NumberFormat.parseBin on the given numberFormat instance.
Parameter numberFormat defaults null
. This denotes static singleton NumberFormat.computational which is configured to not using - and therefore also not parsing - grouping characters.
For more information on number conversion, see class NumberFormat.
numberFormat | Defines the input format. Optional and defaults to null . |
true
if an integer was found, false
otherwise. char consumeChar | ( | ) |
Retrieve and remove the first character in the substring.
boolean consumeChar | ( | char | consumable | ) |
Overloaded version of original method providing default parameter trimBeforeConsume with value Whitespaces.KEEP and default parameter sensitivity with value Case.SENSITIVE
.
consumable | The consumable character |
true
, if this object was starting with consumable and consequently the string was cut by one. boolean consumeChar | ( | char | consumable, |
Case | sensitivity | ||
) |
Overloaded version of original method providing default parameter trimBeforeConsume with value Whitespaces.KEEP.
consumable | The consumable character |
sensitivity | The sensitivity of the comparison. |
true
, if this object was starting with consumable and consequently the string was cut by one. boolean consumeChar | ( | char | consumable, |
Case | sensitivity, | ||
Whitespaces | trimBeforeConsume | ||
) |
Checks if this object starts with the given character consumable. If it does, this character is cut from this object.
consumable | The consumable character |
sensitivity | The sensitivity of the comparison. |
trimBeforeConsume | Determines if the string should be (left-) trimmed before the consume operation. Defaults to Whitespaces.KEEP. |
true
, if this object was starting with consumable and consequently the string was cut by one. char consumeCharFromEnd | ( | ) |
Retrieve and remove the last character in the substring.
boolean consumeCharFromEnd | ( | char | consumable | ) |
Overloaded version of original method providing default parameter trimBeforeConsume with value Whitespaces.KEEP and default parameter sensitivity with value Case.SENSITIVE
.
consumable | The consumable character |
true
, if this object was starting with consumable and consequently the string was cut by one. boolean consumeCharFromEnd | ( | char | consumable, |
Case | sensitivity | ||
) |
Overloaded version of original method providing default parameter trimBeforeConsume with value Whitespaces.KEEP.
consumable | The consumable character |
sensitivity | The sensitivity of the comparison. |
true
, if this object was starting with consumable and consequently the string was cut by one. boolean consumeCharFromEnd | ( | char | consumable, |
Case | sensitivity, | ||
Whitespaces | trimBeforeConsume | ||
) |
Checks if this object ends with the given character consumable. If it does, this character is cut from the end of object.
consumable | The consumable character |
sensitivity | The sensitivity of the comparison. |
trimBeforeConsume | Determines if the string should be (right-) trimmed before the consume operation. Defaults to Whitespaces.KEEP. |
true
, if this object was starting with consumable and consequently the string was cut by one. int consumeCharFromEnd | ( | int | regionLength | ) |
Cuts the given number of characters from the end of the Substring.
Parameter regionLength is checked to be between 0 and length. If negative, nothing is cut. If regionLength is greater than this objects' length, all contents is cleared.
regionLength | The length of the region at the start to delete. |
int consumeCharFromEnd | ( | int | regionLength, |
Substring | target | ||
) |
Cuts the given number of characters from the end of the Substring and optionally places the portion that was cut in parameter target (if provided).
Parameter regionLength is checked to be between 0 and length. If negative, nothing is cut and target is set empty. If regionLength is greater than this objects' length, all contents is 'moved' to target.
regionLength | The length of the region at the start to delete. |
target | An optional target Substring that receives the portion that is cut from this object. Defaults to null. |
int consumeChars | ( | int | regionLength | ) |
Cuts the given number of characters from the beginning of the Substring.
Parameter regionLength is checked to be between 0 and length. If negative, nothing is cut. If regionLength is greater than this objects' length, all contents cleared.
regionLength | The length of the region at the start to delete. |
int consumeChars | ( | int | regionLength, |
Substring | target | ||
) |
Cuts the given number of characters from the beginning of the Substring and optionally places the portion that was cut in parameter target (if provided).
Parameter regionLength is checked to be between 0 and length. If negative, nothing is cut and target is set empty. If regionLength is greater than this objects' length, all contents is 'moved' to target.
regionLength | The length of the region at the start to delete. |
target | An optional target Substring that receives the portion that is cut from this object. Defaults to null. |
boolean consumeDec | ( | ) |
Overloaded version of consumeDec(NumberFormat) providing default value null
for parameter numberFormat (which selects gloabl object NumberFormat.computational).
true
if an value could be parsed, false
otherwise. boolean consumeDec | ( | NumberFormat | numberFormat | ) |
Consumes an unsigned 64-bit integer in standard decimal format at the given position from the start of this string. This is done, by invoking NumberFormat.parseDec on the given numberFormat instance.
Parameter numberFormat defaults null
. This denotes static singleton NumberFormat.computational which is configured to not using - and therefore also not parsing - grouping characters.
Sign literals '-'
or '+'
are not accepted and parsing will fail. For reading signed integer values, see methods consumeInt, for floating point numbers consumeFloat.
For more information on number conversion, see class NumberFormat.
Long.MAX_VALUE
in this language implementation of ALib.numberFormat | Defines the input format. Optional and defaults to null . |
true
if an integer was found, false
otherwise. boolean consumeDecDigits | ( | ) |
Consumes all characters '0'
to '9'
at the start of this object and stores the number value they represent in consumedLong.
Unlike with consumeInt or consumeDec, no sign, whitespaces or group characters are consumed.
true
if an integer was found, false
otherwise. Overloaded version of original method providing default parameter trimBeforeConsume with value Whitespaces.KEEP.
startChar | The start character of the field to consume. |
endChar | The end character of the field to consume. |
target | The target string to place the field in. |
Substring consumeField | ( | char | startChar, |
char | endChar, | ||
Substring | target, | ||
Whitespaces | trimBeforeConsume | ||
) |
Consumes a field from the beginning of this substring, which is surrounded by given start end end character identifiers. If both are the same, e.g. '"'
, then the first occurrence of the end character is used. If they are not the same, e.g. '<'
and '>'
, then repeated start characters are counted and consumption only ends when a corresponding amount of end characters has been found.
startChar | The start character of the field to consume. |
endChar | The end character of the field to consume. |
target | The target string to place the field in. |
trimBeforeConsume | Determines if the string should be (left-) trimmed before the consume operation. Defaults to Whitespaces.Keep. |
boolean consumeFloat | ( | ) |
Overloaded version of consumeFloat(NumberFormat) providing default value null
for parameter numberFormat (which selects gloabl object NumberFormat.computational).
true
if an value could be parsed, false
otherwise. boolean consumeFloat | ( | NumberFormat | numberFormat | ) |
Consumes a floating point number at the given position from this AString. This is done, by invoking NumberFormat.parseFloat on the given numberFormat instance.
Parameter numberFormat defaults null
. This denotes static singleton NumberFormat.computational which is configured to 'international' settings (not using the locale) and therefore also not parsing - grouping characters.
For more information on parsing options for floating point numbers and number conversion in general, see class NumberFormat.
numberFormat | Defines the input format. Optional and defaults to null . |
true
if a number was found and, false
otherwise. boolean consumeHex | ( | ) |
Overloaded version of consumeHex(NumberFormat) providing default value null
for parameter numberFormat (which selects gloabl object NumberFormat.computational).
true
if an value could be parsed, false
otherwise. boolean consumeHex | ( | NumberFormat | numberFormat | ) |
Reads an unsigned 64-bit integer in hexadecimal format at the given position from this AString. This is done, by invoking NumberFormat.parseHex on the given numberFormat instance.
Parameter numberFormat defaults null
. This denotes static singleton NumberFormat.computational which is configured to not using - and therefore also not parsing - grouping characters.
For more information on number conversion, see class NumberFormat.
numberFormat | Defines the input format. Optional and defaults to null . |
true
if an integer was found, false
otherwise. boolean consumeInt | ( | ) |
Overloaded version of consumeInt(NumberFormat) providing default value null
for parameter numberFormat (which selects gloabl object NumberFormat.computational).
true
if an value could be parsed, false
otherwise. boolean consumeInt | ( | NumberFormat | numberFormat | ) |
Consumes a long integer value in decimal, binary, hexadecimal or octal format from the start of the string by invoking method NumberFormat.parseInt on the given numberFormat instance.
Parameter numberFormat defaults null
. This denotes static singleton NumberFormat.computational which is configured to 'international' settings (not using the locale) and therefore also not parsing grouping characters.
numberFormat | Defines the input format. Optional and defaults to null . |
true
if an integer was found, false
otherwise. boolean consumeOct | ( | ) |
Overloaded version of consumeOct(NumberFormat) providing default value null
for parameter numberFormat (which selects gloabl object NumberFormat.computational).
true
if an value could be parsed, false
otherwise. boolean consumeOct | ( | NumberFormat | numberFormat | ) |
Consumes an unsigned 64-bit integer in octal format at the given position from this string. This is done, by invoking NumberFormat.parseOct on the given numberFormat instance.
Parameter numberFormat defaults null
. This denotes static singleton NumberFormat.computational which is configured to not using - and therefore also not parsing - grouping characters.
For more information on number conversion, see class NumberFormat.
1
.numberFormat | Defines the input format. Optional and defaults to null . |
true
if an integer was found, false
otherwise. int consumePartOf | ( | String | consumable | ) |
Overloaded version of original method providing default parameter trimBeforeConsume with value Whitespaces.KEEP, sensitivity with value Case.Sensitive and minChars with value 1
.
consumable | The consumable string. |
int consumePartOf | ( | String | consumable, |
int | minChars | ||
) |
Overloaded version of original method providing default parameter trimBeforeConsume with value Whitespaces.KEEP and sensitivity with value Case.Sensitive.
consumable | The consumable string. |
minChars | The minimum amount of characters to consume. Optional and defaults to 1 |
int consumePartOf | ( | String | consumable, |
int | minChars, | ||
Case | sensitivity | ||
) |
Overloaded version of original method providing default parameter trimBeforeConsume with value Whitespaces.KEEP.
consumable | The consumable string. |
minChars | The minimum amount of characters to consume. Optional and defaults to 1 |
sensitivity | The sensitivity of the comparison. |
int consumePartOf | ( | String | consumable, |
int | minChars, | ||
Case | sensitivity, | ||
Whitespaces | trimBeforeConsume | ||
) |
Consumes a minimum of minChars of string consumable
from the start of this substring. If the minimum characters could not be found, nothing is consumed, otherwise as much as possible.
This method is useful for example to read commands from a string that may be abbreviated.
consumable | The consumable string. |
minChars | The minimum amount of characters to consume. If 0 or negative, the length of consumable is chosen. Optional and defaults to 1 . |
sensitivity | The sensitivity of the comparison. Defaults to Case.Ignore. |
trimBeforeConsume | Determines if the string should be (left-) trimmed before the first character consume operation. Defaults to Whitespaces.KEEP. |
boolean consumeString | ( | CharSequence | consumable | ) |
Overloaded version of original method providing default parameter trimBeforeConsume with value Whitespaces.KEEP and default parameter sensitivity with value Case.SENSITIVE
.
consumable | The consumable string |
true
, if this object was starting with consumable and consequently the string was cut. boolean consumeString | ( | CharSequence | consumable, |
Case | sensitivity | ||
) |
Overloaded version of original method providing default parameter trimBeforeConsume with value Whitespaces.KEEP.
consumable | The consumable string |
sensitivity | The sensitivity of the comparison. |
true
, if this object was starting with consumable and consequently the string was cut. boolean consumeString | ( | CharSequence | consumable, |
Case | sensitivity, | ||
Whitespaces | trimBeforeConsume | ||
) |
Checks if this object starts with the given string consumable. If it does, this string is cut from this object.
consumable | The consumable string |
sensitivity | The sensitivity of the comparison. |
trimBeforeConsume | Determines if the string should be (left-) trimmed before the consume operation. Defaults to Whitespaces.KEEP. |
true
, if this object was starting with consumable and consequently the string was cut. boolean consumeStringFromEnd | ( | CharSequence | consumable | ) |
Overloaded version of original method providing default parameter trimBeforeConsume with value Whitespaces.KEEP and default parameter sensitivity with value Case.SENSITIVE
.
consumable | The consumable string |
true
, if this object was starting with consumable and consequently the string was cut. boolean consumeStringFromEnd | ( | CharSequence | consumable, |
Case | sensitivity | ||
) |
Overloaded version of original method providing default parameter trimBeforeConsume with value Whitespaces.KEEP.
consumable | The consumable string |
sensitivity | The sensitivity of the comparison. |
true
, if this object was starting with consumable and consequently the string was cut. boolean consumeStringFromEnd | ( | CharSequence | consumable, |
Case | sensitivity, | ||
Whitespaces | trimBeforeConsume | ||
) |
Checks if this object ends with the given string consumable. If it does, this string is cut from the end of object.
consumable | The consumable string |
sensitivity | The sensitivity of the comparison. |
trimBeforeConsume | Determines if the string should be (right-) trimmed before the consume operation. Defaults to Whitespaces.KEEP. |
true
, if this object was starting with consumable and consequently the string was cut. int consumeToken | ( | Substring | target, |
char | separator | ||
) |
Searches separator and cuts the beginning of this string, including the separator. What was consumed is returned, excluding the separator.
If the separator is not found, all of this string is consumed and returned.
target | The target substring. |
separator | The separator to search. Defaults to ',' . |
boolean containsAt | ( | AString | needle, |
int | pos | ||
) |
Checks if a String is located at the given position.
needle | The CharSequence to search. |
pos | The position within this object to look at. |
Checks if an AString is located at the given position.
needle | The AString to search. |
pos | The position within this object to look at. |
sensitivity | Case sensitivity of the operation. Optional and defaults to Case.Sensitive. |
boolean containsAt | ( | CharSequence | needle, |
int | pos | ||
) |
Checks if a CharSequence is located at the given position.
needle | The CharSequence to search. |
pos | The position within this object to look at. |
boolean containsAt | ( | CharSequence | needle, |
int | pos, | ||
Case | sensitivity | ||
) |
Checks if a CharSequence is located at the given position.
needle | The CharSequence to search. |
pos | The position within this object to look at. |
sensitivity | Case sensitivity of the operation. Optional and defaults to Case.Sensitive. |
boolean containsAt | ( | Substring | needle, |
int | pos | ||
) |
Checks if a Substring is located at the given position.
needle | The CharSequence to search. |
pos | The position within this object to look at. |
Checks if a Substring is located at the given position.
needle | The Substring to search. |
pos | The position within this object to look at. |
sensitivity | Case sensitivity of the operation. Optional and defaults to Case.Sensitive. |
void copyTo | ( | AString | target | ) |
void copyTo | ( | AString | target, |
boolean | append | ||
) |
boolean endsWith | ( | AString | needle | ) |
boolean endsWith | ( | CharSequence | needle | ) |
Checks if this Substring ends with the given sequence.
needle | The CharSequence to search. If s is null or empty, false is returned. |
boolean endsWith | ( | CharSequence | needle, |
Case | sensitivity | ||
) |
Checks if this Substring ends with the given sequence.
needle | The CharSequence to search. If s is null or empty, false is returned. |
sensitivity | Case sensitivity of the operation. Optional and defaults to Case.Sensitive. |
boolean endsWith | ( | Substring | needle | ) |
boolean equals | ( | AString | cmpString | ) |
Tests and returns true, if the given AString equals to what this object represents. True is returned if both are zero length or null
.
cmpString | The AString that is compared to this AString. |
Tests and returns true, if the given AString equals to what this object represents. True is returned if both are zero length or null
.
cmpString | The AString that is compared to this AString. |
sensitivity | Case sensitivity of the comparison. Optional and defaults to Case.Sensitive. |
boolean equals | ( | CharSequence | cmpString | ) |
Tests and returns true, if the given CharSequence equals to what this object represents. True is returned if both are zero length or null
.
cmpString | A CharSequence that is compared to this AString. |
boolean equals | ( | CharSequence | cmpString, |
Case | sensitivity | ||
) |
Tests and returns true, if the given CharSequence equals to what this object represents. True is returned if both are zero length or null
.
cmpString | A CharSequence that is compared to this AString. |
sensitivity | Case sensitivity of the comparison. Optional and defaults to Case.Sensitive. |
boolean equals | ( | Object | object | ) |
Compares this to the given object. .
object | The object to compare to this instance. |
boolean equals | ( | Object | object, |
Case | sensitivity | ||
) |
Compares this to the given object. Given object can be of type
object | The object to compare to this instance. |
sensitivity | Case sensitivity of the comparison. Optional and defaults to Case.Sensitive. |
boolean equals | ( | String | cmpString | ) |
Tests and returns true, if the given String equals to what this object represents. True is returned if both are zero length or null
.
cmpString | The AString that is compared to this AString. |
boolean equals | ( | String | cmpString, |
Case | sensitivity | ||
) |
Tests and returns true, if the given String equals to what this object represents. True is returned if both are zero length or null
.
cmpString | The AString that is compared to this AString. |
sensitivity | Case sensitivity of the comparison. Optional and defaults to Case.Sensitive. |
boolean equals | ( | Substring | cmpString | ) |
Tests and returns true, if the given other Substring equals to what this object represents. True is returned if both are zero length or null
.
cmpString | A Substring that is compared to this AString. |
Tests and returns true, if the given other Substring equals to what this object represents. True is returned if both are zero length or null
.
cmpString | A Substring that is compared to this AString. |
sensitivity | Case sensitivity of the comparison. Optional and defaults to Case.Sensitive. |
int hashCode | ( | ) |
Standard Java Object hashCode method.
int indexOf | ( | char | c | ) |
Searches the given character.
c | The character to search. |
-1
if the character is not found. int indexOf | ( | char | needle, |
int | startIdx | ||
) |
Search a character in the buffer.
needle | The character to search. |
startIdx | The index to start the search at. Optional and defaults to 0 . |
int indexOf | ( | CharSequence | cs | ) |
Search a CharSequence in the buffer.
cs | The CharSequence to search. |
int indexOf | ( | CharSequence | cs, |
int | startIdx | ||
) |
Search a CharSequence in the buffer.
cs | The CharSequence to search. |
startIdx | The index to start the search at. Optional and defaults to 0 . |
int indexOf | ( | CharSequence | needle, |
int | startIdx, | ||
Case | sensitivity | ||
) |
Search the given String in the buffer starting at a given position.
needle | The CharSequence to search. |
startIdx | The index to start the search at. Optional and defaults to 0 . |
sensitivity | Case sensitivity of the operation. Optional and defaults to Case.Sensitive. |
int indexOfAny | ( | char[] | needles, |
Inclusion | inclusion | ||
) |
Returns the index of the first character which is included, respectively not included in a given set of characters.
This method searches from left to right. For reverse search, see lastIndexOfAny.
needles | Characters to be searched for. |
inclusion | Denotes whether the search returns the first index that holds a value that is included or that is not excluded in the set of needle characters. |
int indexOfAny | ( | char[] | needles, |
Inclusion | inclusion, | ||
int | startIdx | ||
) |
Returns the index of the first character which is included, respectively not included in a given set of characters.
This method searches from left to right. For reverse search, see lastIndexOfAny.
needles | Characters to be searched for. |
inclusion | Denotes whether the search returns the first index that holds a value that is included or that is not excluded in the set of needle characters. |
startIdx | The index to start the search at. If the given value is less than 0, it is set to 0. If it exceeds the length of the string, the length of the string is returned. Defaults to 0. |
int indexOfFirstDifference | ( | CharSequence | needle | ) |
Overloaded version providing default paramter startIdx with value 0
and sensitivity with value Case.SENSITIVE.
needle | The String to search. |
int indexOfFirstDifference | ( | CharSequence | needle, |
Case | sensitivity | ||
) |
Overloaded version providing default paramter startIdx with value 0
.
needle | The String to search. |
sensitivity | Case sensitivity of the comparison. Optional and defaults to Case.SENSITIVE. |
int indexOfFirstDifference | ( | CharSequence | needle, |
Case | sensitivity, | ||
int | startIdx | ||
) |
Searches the first difference with given string. If this string starts with needle, then the length of needle is returned.
needle | The String to search. |
sensitivity | Case sensitivity of the comparison. Optional and defaults to Case.SENSITIVE. |
startIdx | The index to start the search at. Optional and defaults to 0 . |
int indexOfOrLength | ( | char | needle | ) |
Like indexOf but in case the character is not found, this method returns the length of this string instead of -1
. Depending on the invocation context, the choice for the right version of this method may lead to shorter and more efficient code.
needle | The character to search for. |
int indexOfOrLength | ( | char | needle, |
int | startIdx | ||
) |
Like indexOf but in case the character is not found, this method returns the length of this string instead of -1
. Depending on the invocation context, the choice for the right version of this method may lead to shorter and more efficient code.
needle | The character to search for. |
startIdx | The index in this to start searching the character. |
boolean isEmpty | ( | ) |
Checks if represented region has a length of zero.
boolean isNotEmpty | ( | ) |
Checks if the represented region has a length of more than zero.
boolean isNotNull | ( | ) |
boolean isNull | ( | ) |
int lastIndexOfAny | ( | char[] | needles, |
Inclusion | inclusion | ||
) |
Returns the index of the first character which is included, respectively not included in a given set of characters. The search starts at the end and goes backward. For forward search, see indexOfAny.
needles | Characters to be searched for. |
inclusion | Denotes whether the search returns the first index that holds a value that is included or that is not excluded in the set of needle characters. |
int lastIndexOfAny | ( | char[] | needles, |
Inclusion | inclusion, | ||
int | startIdx | ||
) |
Returns the index of the first character which is included, respectively not included in a given set of characters. The search starts at the given index and goes backward. For forward search, see indexOfAny.
needles | Characters to be searched for. |
inclusion | Denotes whether the search returns the first index that holds a value that is included or that is not excluded in the set of needle characters. |
startIdx | The index to start the search at. The value is cropped to be in the bounds of 0 and the length of this object minus one. Defaults to the length of this object. |
int length | ( | ) |
Resets the sub-string to work on the provided AString.
src | The string to work on. |
this
to allow concatenated calls. Resets the sub-string to work on the provided AString.
src | The string to work on. |
regionStart | The start of the region within src. Defaults to 0. |
this
to allow concatenated calls. Resets the sub-string to work on the provided AString.
src | The string to work on. |
regionStart | The start of the region within src. Defaults to 0. |
regionLength | The length of the region within src. Defaults to the length of src. |
this
to allow concatenated calls. Substring set | ( | char[] | src | ) |
Resets the sub-string to work on the provided character array.
src | The string to work on. |
this
to allow concatenated calls. Substring set | ( | char[] | src, |
int | regionStart | ||
) |
Resets the sub-string to work on the provided character array.
src | The string to work on. |
regionStart | The start of the region within src. Defaults to 0. |
this
to allow concatenated calls. Substring set | ( | char[] | src, |
int | regionStart, | ||
int | regionLength | ||
) |
Resets the sub-string to work on the provided character array.
src | The string to work on. |
regionStart | The start of the region within src. Defaults to 0. |
regionLength | The length of the region within src. Defaults to the length of src. |
this
to allow concatenated calls. Substring set | ( | String | src | ) |
Resets the sub-string to work on the provided String
src | The string to work on. |
this
to allow concatenated calls. Substring set | ( | String | src, |
int | regionStart | ||
) |
Resets the sub-string to work on the provided String
src | The string to work on. |
regionStart | The start of the region within src. Defaults to 0. |
this
to allow concatenated calls. Substring set | ( | String | src, |
int | regionStart, | ||
int | regionLength | ||
) |
Resets the sub-string to work on the provided String
src | The string to work on. |
regionStart | The start of the region within src. Defaults to 0. |
regionLength | The length of the region within src. Defaults to the length of src. |
this
to allow concatenated calls. Sets the substring to be identical to the given substring.
src | The string to work on. |
this
to allow concatenated calls. Sets the substring to represent a region of the given Substring.
src | The string to work on. |
regionStart | The start of the region within src. Defaults to 0. |
this
to allow concatenated calls. Sets the substring to represent a region of the given Substring.
src | The string to work on. |
regionStart | The start of the region within src. Defaults to 0. |
regionLength | The length of the region within src. If negative, length of the provided src is used. Defaults to -1. |
this
to allow concatenated calls. void setNull | ( | ) |
Sets this to null state and in addition to empty state.
Splits this substring into two parts. What remains in this object is the region from 0 to position. target receives the rest. If optional parameter separatorWidth is given, this is subtracted from the front of target.
position | The index where this object is split. |
target | The target substring to receive the right part of the string. |
separatorWidth | This does not change what remains in this object, but defines the number of characters that are cut from the front of the target. Defaults to 0. |
this
to allow concatenated calls. boolean startsWith | ( | AString | needle | ) |
boolean startsWith | ( | CharSequence | needle | ) |
Checks if this Substring starts with the given sequence.
needle | The CharSequence to search. If s is null or empty, false is returned. |
boolean startsWith | ( | CharSequence | needle, |
Case | sensitivity | ||
) |
Checks if this Substring starts with the given sequence.
needle | The CharSequence to search. If s is null or empty, false is returned. |
sensitivity | Case sensitivity of the operation. Optional and defaults to Case.Sensitive. |
boolean startsWith | ( | Substring | needle | ) |
CharSequence subSequence | ( | int | beginIndex, |
int | endIndex | ||
) |
Reports an ALib error (using ReportWriter) and returns null. The reason for this behavior is to disallow the usage of AString within (system) methods that create sub sequences. This would be in contrast to the design goal of AString.
beginIndex | The start of the sequence (not used) |
endIndex | The length of the sequence (not used) |
String toString | ( | ) |
Overrides Object.ToString(). Copies the string region represented by this object into a new string.
String toString | ( | int | regionStart | ) |
Overloaded version providing default parameter regionLength as Integer.MAX_VALUE
.
regionStart | The start index of the region in this to create the string from. |
String toString | ( | int | regionStart, |
int | regionLength | ||
) |
Creates a String containing a copy of a region of the this Substring.
regionStart | The start index of the region in this to create the string from. |
regionLength | The maximum length of the region to create the string from. Defaults to Integer.MAX_VALUE. |
Substring trim | ( | ) |
Invokes trim(char[] whiteSpaces) providing default parameter CString.DEFAULT_WHITESPACES.
this
to allow concatenated calls. Substring trim | ( | char[] | whiteSpaces | ) |
Invokes trimStart and trimEnd.
whiteSpaces | The characters used for trimming. Defaults to CString.DEFAULT_WHITESPACES. |
this
to allow concatenated calls. Substring trimEnd | ( | ) |
Invokes trimEnd(char[] whiteSpaces) providing default parameter CString.DEFAULT_WHITESPACES.
this
to allow concatenated calls. Substring trimEnd | ( | char[] | whiteSpaces | ) |
Moves the start marker to the first character not found in parameter whiteSpaces.
whiteSpaces | The characters used for trimming. Defaults to CString.DEFAULT_WHITESPACES. |
this
to allow concatenated calls. Substring trimStart | ( | ) |
Invokes trimStart(char[] whiteSpaces) providing default parameter CString.DEFAULT_WHITESPACES.
this
to allow concatenated calls. Substring trimStart | ( | char[] | whiteSpaces | ) |
Moves the start marker to the first character not found in parameter whiteSpaces.
whiteSpaces | The characters used for trimming. Defaults to CString.DEFAULT_WHITESPACES. |
this
to allow concatenated calls.
|
protected |
Used as a return value of method CString.adjustRegion
char [] buf |
The character array we work on.
double consumedFloat |
Used as second return value with method consumeFloat.
long consumedLong |
Used as second return value with method various consumeChar methods.
int end |
End marker within buf (points to the last character)
int start |
Start marker within buf