A mutable string, that provides public access to its internal buffer and fields. First of all, the existence of this class is motivated to reach a certain level of compatibility between source code that uses the ALib across different languages (currently Java, C# and C++) whose implementations share a similar AString class.
As the given C#/Java StringBuilder/Buffer classes are either "sealed" and/or do not provide direct access to the internal buffer, to avoid conversion to new immutable strings in certain situations, the A-Worx Library implements its own string class. More complex functions, like extended formatting operations are not supported and remain the domain of the language specific class libraries.
Null-state:
Class AString is 'nullable', which means, that an instance may have no internal character array allocated. If constructed with zero size, a null pointer or another AString which is 'nulled' (but not a non-null, zero length string object of any type), the allocation size is 0. Nevertheless, method buffer will return a valid empty char[] (a static singleton). This has the advantage that in many situations the null-state is not needed to handled specially (those cases where the difference between a nulled and an empty string is irrelevant). Consequently, it makes a difference if an AString is constructed using AString() or "AString(\""). This allows to differentiate between 'nulled' AStrings and empty AStrings, which is quite handy in certain situations. An object that was filled already can be reset to represent null by either assigning a nulled AString, by invoking setBuffer(0) or by invoking setNull on the instance. See also methods isNull, isNotNull and capacity. The methods equals and compareTo allow null
comparisons. e.g. an nulled AString equals to another nulled AString but not to a zero length, not nulled AString.
Non-checking methods
In general, AString methods are internally checking the provided parameters. For example, method __( CharSequence src, int regionStart, int regionLength ) is adjusting the provided region information to fit to the size of the provided AString (in Java CharSequence).
Chances are high, that the code invoking this method "knows" about the correctness of the region. In this case, the checks are redundant.
For avoiding unnecessary checks, various methods are provided by AString that omit such checks. These methods share the same name as the standard one, with the suffix "_NC" appended (NC stands for "no checks").
In the sample above, if the calling code was sure about the parameters regionStart and regionLength being in the bounds of src, method _NC( AString src, int regionStart, int regionLength ) can be used.
Public Methods | |
Constructors and Destructor | |
AString () | |
AString (int size) | |
AString (CharSequence src) | |
AString (CharSequence src, int regionStart) | |
AString (CharSequence src, int regionStart, int regionLength) | |
Memory allocation and buffer access | |
char[] | buffer () |
void | setBuffer (int newCapacity) |
void | ensureRemainingCapacity (int spaceNeeded) |
int | capacity () |
void | setNull () |
boolean | isNull () |
boolean | isNotNull () |
int | length () |
int | setLength (int newLength) |
void | setLength_NC (int newLength) |
boolean | isEmpty () |
boolean | isNotEmpty () |
Insert and Delete | |
AString | clear () |
AString | __ () |
AString | insertAt (CharSequence src, int pos) |
AString | insertChars (char c, int qty, int pos) |
AString | insertChars (char c, int qty) |
AString | replaceSubstring (CharSequence src, int regionStart, int regionLength) |
AString | replaceRegion (char c, int regionStart, int regionLength) |
AString | delete (int regionStart, int regionLength) |
AString | delete (int regionStart) |
AString | delete_NC (int regionStart, int regionLength) |
AString | deleteStart (int regionLength) |
AString | deleteStart_NC (int regionLength) |
AString | deleteEnd (int regionLength) |
AString | deleteEnd_NC (int regionLength) |
AString | trim (char[] trimChars) |
AString | trim () |
int | trimAt (int idx, char[] trimChars) |
int | trimAt (int index) |
AString | trimStart (char[] trimChars) |
AString | trimStart () |
AString | trimEnd (char[] trimChars) |
AString | trimEnd () |
Basic formatting | |
AString | newLine () |
AString | tab (int tabSize, int minPad, char tabChar) |
AString | tab (int tabSize, int minPad) |
AString | tab (int tabSize) |
AString | field (int size, Alignment alignment, char padChar, int fieldStart) |
AString | field (int size, Alignment alignment, char padChar) |
AString | field (int size, Alignment alignment) |
AString | field (int size) |
AString | field () |
Appending characters and strings | |
AString | __ (char[] src, int regionStart, int regionLength) |
AString | __ (char[] src, int regionStart) |
AString | __ (char[] src) |
AString | _NC (char[] src, int regionStart, int regionLength) |
AString | __ (CharSequence src, int regionStart, int regionLength) |
AString | __ (CharSequence src, int regionStart) |
AString | __ (CharSequence src) |
AString | __ (AString src) |
AString | _NC (AString src) |
AString | _NC (AString src, int regionStart, int regionLength) |
AString | __ (com.aworx.lib.strings.Substring src) |
AString | _NC (com.aworx.lib.strings.Substring src) |
AString | __ (String src) |
AString | _NC (String src) |
AString | _NC (String src, int regionStart, int regionLength) |
AString | __ (char c) |
AString | __ (Object object) |
AString | _NC (Object object) |
Character access | |
char | charAt (int idx) |
char | charAt_NC (int idx) |
void | setCharAt (int idx, char c) |
void | setCharAt_NC (int idx, char c) |
char | charAtStart () |
char | charAtStart_NC () |
char | charAtEnd () |
char | charAtEnd_NC () |
Comparison | |
int | compareTo (CharSequence cmpString, Case sensitivity, int cmpRegionStart, int cmpRegionLength, int regionStart, int regionLength) |
int | compareTo (CharSequence cmpString, Case sensitivity, int cmpRegionStart, int cmpRegionLength, int regionStart) |
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 | 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 (com.aworx.lib.strings.Substring needle, int pos, Case sensitivity) |
boolean | containsAt (com.aworx.lib.strings.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 (com.aworx.lib.strings.Substring needle, Case sensitivity) |
boolean | startsWith (com.aworx.lib.strings.Substring needle) |
boolean | endsWith (CharSequence needle, Case sensitivity) |
boolean | endsWith (CharSequence needle) |
boolean | endsWith (AString needle, Case sensitivity) |
boolean | endsWith (AString needle) |
boolean | endsWith (com.aworx.lib.strings.Substring needle, Case sensitivity) |
boolean | endsWith (com.aworx.lib.strings.Substring needle) |
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 (com.aworx.lib.strings.Substring cmpString, Case sensitivity) |
boolean | equals (com.aworx.lib.strings.Substring cmpString) |
boolean | equals (CharSequence cmpString, Case sensitivity) |
boolean | equals (CharSequence cmpString) |
Search | |
int | indexOf (char c, 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 | indexOfAny (char[] needles, Inclusion inclusion, int startIdx) |
int | indexOfAny (char[] needles, Inclusion inclusion) |
int | lastIndexOf (char needle, int startIndex) |
int | lastIndexOf (char needle) |
int | lastIndexOfAny (char[] needles, Inclusion inclusion, int startIdx) |
int | lastIndexOfAny (char[] needles, Inclusion inclusion) |
Replace | |
int | searchAndReplace (char needle, char replacement, int startIdx) |
int | searchAndReplace (char needle, char replacement) |
int | searchAndReplace (CharSequence searchStr, CharSequence newStr, int startIdx, int maxReplacements, Case sensitivity) |
int | searchAndReplace (CharSequence searchStr, CharSequence newStr, int startIdx, int maxReplacements) |
int | searchAndReplace (CharSequence searchStr, CharSequence newStr, int startIdx) |
int | searchAndReplace (CharSequence searchStr, CharSequence newStr) |
AString | searchAndReplaceAll (CharSequence searchStr, CharSequence newStr) |
AString | toUpper (int regionStart, int regionLength) |
AString | toUpper (int regionStart) |
AString | toUpper () |
AString | toLower (int regionStart, int regionLength) |
AString | toLower (int regionStart) |
AString | toLower () |
AString | escape (Switch escape, int regionStart, int regionLength) |
AString | escape (Switch escape, int regionStart) |
AString | escape (Switch escape) |
AString | escape () |
Conversion | |
AString | __ (int value, int overrideWidth, NumberFormat numberFormat) |
AString | __ (int value, int overrideWidth) |
AString | __ (int value) |
AString | __ (int value, NumberFormat numberFormat) |
AString | __ (long value, int overrideWidth, NumberFormat numberFormat) |
AString | __ (long value, int overrideWidth) |
AString | __ (long value) |
AString | __ (long value, NumberFormat numberFormat) |
AString | _Bin (long value, int overrideWidth, NumberFormat numberFormat) |
AString | _Bin (long value, int overrideWidth) |
AString | _Bin (long value) |
AString | _Bin (long value, NumberFormat numberFormat) |
AString | _Hex (long value, int overrideWidth, NumberFormat numberFormat) |
AString | _Hex (long value, int overrideWidth) |
AString | _Hex (long value) |
AString | _Hex (long value, NumberFormat numberFormat) |
AString | _Oct (long value, int overrideWidth, NumberFormat numberFormat) |
AString | _Oct (long value, int overrideWidth) |
AString | _Oct (long value) |
AString | _Oct (long value, NumberFormat numberFormat) |
AString | __ (double value, int overrideWidth, NumberFormat numberFormat) |
AString | __ (double value, int overrideWidth) |
AString | __ (double value) |
AString | __ (double value, NumberFormat numberFormat) |
String | toString (int regionStart, int regionLength) |
String | toString (int regionStart) |
String | toString () |
StringBuilder | toString (StringBuilder result, int regionStart, int regionLength, boolean appendMode) |
long | parseDecDigits (int startIdx, int[] newIdx) |
long | parseInt (int startIdx, NumberFormat numberFormat, int[] newIdx) |
long | parseInt (int startIdx, NumberFormat numberFormat) |
long | parseInt (int startIdx) |
long | parseInt () |
long | parseInt (int startIdx, int[] newIdx) |
long | parseInt (NumberFormat numberFormat, int[] newIdx) |
long | parseInt (NumberFormat numberFormat) |
long | parseInt (int[] newIdx) |
long | parseDec (int startIdx, NumberFormat numberFormat, int[] newIdx) |
long | parseDec (int startIdx, NumberFormat numberFormat) |
long | parseDec (int startIdx) |
long | parseDec () |
long | parseDec (int startIdx, int[] newIdx) |
long | parseDec (NumberFormat numberFormat, int[] newIdx) |
long | parseDec (NumberFormat numberFormat) |
long | parseDec (int[] newIdx) |
long | parseBin (int startIdx, NumberFormat numberFormat, int[] newIdx) |
long | parseBin (int startIdx, NumberFormat numberFormat) |
long | parseBin (int startIdx) |
long | parseBin () |
long | parseBin (int startIdx, int[] newIdx) |
long | parseBin (NumberFormat numberFormat, int[] newIdx) |
long | parseBin (NumberFormat numberFormat) |
long | parseBin (int[] newIdx) |
long | parseHex (int startIdx, NumberFormat numberFormat, int[] newIdx) |
long | parseHex (int startIdx, NumberFormat numberFormat) |
long | parseHex (int startIdx) |
long | parseHex () |
long | parseHex (int startIdx, int[] newIdx) |
long | parseHex (NumberFormat numberFormat, int[] newIdx) |
long | parseHex (NumberFormat numberFormat) |
long | parseHex (int[] newIdx) |
long | parseOct (int startIdx, NumberFormat numberFormat, int[] newIdx) |
long | parseOct (int startIdx, NumberFormat numberFormat) |
long | parseOct (int startIdx) |
long | parseOct () |
long | parseOct (int startIdx, int[] newIdx) |
long | parseOct (NumberFormat numberFormat, int[] newIdx) |
long | parseOct (NumberFormat numberFormat) |
long | parseOct (int[] newIdx) |
double | parseFloat (int startIdx, NumberFormat numberFormat, int[] newIdx) |
double | parseFloat (int startIdx, NumberFormat numberFormat) |
double | parseFloat (int startIdx) |
double | parseFloat () |
double | parseFloat (int startIdx, int[] newIdx) |
double | parseFloat (NumberFormat numberFormat, int[] newIdx) |
double | parseFloat (NumberFormat numberFormat) |
double | parseFloat (int[] newIdx) |
Protected Fields | |
int[] | _adjustedRegion = new int[2] |
char[] | buffer = com.aworx.lib.strings.CString.nullBuffer |
int | fieldReference =0 |
int | hash =0 |
int | length =0 |
int | tabReference =0 |
Java std library interface implementation | |
int | hashCode () |
CharSequence | subSequence (int beginIndex, int endIndex) |
boolean | resizeRegion (int regionStart, int regionLength, int newLength) |
AString | ( | int | size | ) |
Constructor allocating a specific buffer size.
size | The initial size of the internal buffer. |
AString | ( | CharSequence | src | ) |
Constructor copying a CharSequence.
src | The source CharSequence to copy from. |
AString | ( | CharSequence | src, |
int | regionStart | ||
) |
Constructor copying a region of a CharSequence.
src | The source CharSequence to copy from. |
regionStart | The start of the region in src to append. Defaults to 0. |
AString | ( | CharSequence | src, |
int | regionStart, | ||
int | regionLength | ||
) |
Constructor copying a region of a CharSequence.
src | The source CharSequence to copy from. |
regionStart | The start of the region in src to append. Defaults to 0. |
regionLength | The maximum length of the region in src to append. Defaults to Integer.MAX_VALUE. |
AString __ | ( | ) |
Clear the Buffer. Same as clear(), really just a synonym to allow short code in alignment with the various "Append" methods named _(src)
this
to allow concatenated calls. Append an AString.
src | The AString to append. |
this
to allow concatenated calls. AString __ | ( | char | c | ) |
Append a character.
c | The character to append. |
this
to allow concatenated calls. AString __ | ( | char[] | src | ) |
Append a char[].
src | The character array to append. |
this
to allow concatenated calls. AString __ | ( | char[] | src, |
int | regionStart | ||
) |
Append char[] beginning with given index.
src | The character array containing the region to append. |
regionStart | The start of the region in src to append. Defaults to 0. |
this
to allow concatenated calls. AString __ | ( | char[] | src, |
int | regionStart, | ||
int | regionLength | ||
) |
Append a region of a char[].
src | The character containing the region to append. |
regionStart | The start of the region in src to append. Defaults to 0. |
regionLength | The maximum length of the region in src to append. Defaults to the length of the array minus the start of the region. |
this
to allow concatenated calls. AString __ | ( | CharSequence | src | ) |
Append a CharSequence.
src | The CharSequence to append. |
this
to allow concatenated calls. AString __ | ( | CharSequence | src, |
int | regionStart | ||
) |
Append a region of a CharSequence.
src | The CharSequence to append. |
regionStart | The start of the region in src to append. Defaults to 0. |
this
to allow concatenated calls. AString __ | ( | CharSequence | src, |
int | regionStart, | ||
int | regionLength | ||
) |
Append a region of a CharSequence.
src | The CharSequence containing the region to append. |
regionStart | The start of the region in src to append. Defaults to 0. |
regionLength | The maximum length of the region in src to append. Defaults to Integer.MAX_VALUE. |
this
to allow concatenated calls. AString __ | ( | com.aworx.lib.strings.Substring | src | ) |
AString __ | ( | double | value | ) |
Overloaded version of __(double,int,NumberFormat) which provides default parameter(s).
value | The double value to append. |
this
to allow concatenated calls. AString __ | ( | double | value, |
int | overrideWidth | ||
) |
Overloaded version of __(double,int,NumberFormat) which provides default parameter(s).
value | The double value to append. |
overrideWidth | If not 0 (the default), overrides the output width otherwise specified in field NumberFormat.integralPartMinimumWidth |
this
to allow concatenated calls. AString __ | ( | double | value, |
int | overrideWidth, | ||
NumberFormat | numberFormat | ||
) |
Append a double value. See NumberFormat for more information on formatting options.
value | The double value to append. |
overrideWidth | If not 0 (the default), overrides the output width otherwise specified in field NumberFormat.integralPartMinimumWidth |
numberFormat | The format definition. Defaults to null . |
this
to allow concatenated calls. AString __ | ( | double | value, |
NumberFormat | numberFormat | ||
) |
Overloaded version of __(double,int,NumberFormat) which provides default parameter(s).
value | The double value to append. |
numberFormat | The format definition. Defaults to null . |
this
to allow concatenated calls. AString __ | ( | int | value | ) |
Overloaded version of __(int,int,NumberFormat) which provides default parameter(s).
value | The value to append. |
this
to allow concatenated calls. AString __ | ( | int | value, |
int | overrideWidth | ||
) |
Overloaded version of __(int,int,NumberFormat) which provides default parameter(s).
value | The value to append. |
overrideWidth | If not 0 (the default), overrides the output width otherwise specified in field NumberFormat.decMinimumFieldWidth. |
this
to allow concatenated calls. AString __ | ( | int | value, |
int | overrideWidth, | ||
NumberFormat | numberFormat | ||
) |
Format and append a 32-Bit integer value.
Parameter numberFormat defaults to null
, which denotes this method to use the static singleton found in NumberFormat.computational. To generate output better readable for humans, provide NumberFormat.global, or a customized object of that type.
See NumberFormat for more information on formatting options.
value | The value to append. |
overrideWidth | If not 0 (the default), overrides the output width otherwise specified in field NumberFormat.decMinimumFieldWidth. |
numberFormat | The format definition. Defaults to null . |
this
to allow concatenated calls. AString __ | ( | int | value, |
NumberFormat | numberFormat | ||
) |
Overloaded version of __(int,int,NumberFormat) which provides default parameter(s).
value | The value to append. |
numberFormat | The format definition. Defaults to null . |
this
to allow concatenated calls. AString __ | ( | long | value | ) |
Overloaded version of __(long,int,NumberFormat) which provides default parameter(s).
value | The value to append. |
this
to allow concatenated calls. AString __ | ( | long | value, |
int | overrideWidth | ||
) |
Overloaded version of __(long,int,NumberFormat) which provides default parameter(s).
value | The value to append. |
overrideWidth | If not 0 (the default), overrides the output width otherwise specified in field NumberFormat.decMinimumFieldWidth. |
this
to allow concatenated calls. AString __ | ( | long | value, |
int | overrideWidth, | ||
NumberFormat | numberFormat | ||
) |
Format and append a 64-Bit integer value.
Parameter numberFormat defaults to null
, which denotes this method to use the static singleton found in NumberFormat.computational. To generate output better readable for humans, provide NumberFormat.global, or a customized object of that type.
See NumberFormat for more information on formatting options.
value | The value to append. |
overrideWidth | If not 0 (the default), overrides the output width otherwise specified in field NumberFormat.decMinimumFieldWidth. |
numberFormat | The format definition. Defaults to null . |
this
to allow concatenated calls. AString __ | ( | long | value, |
NumberFormat | numberFormat | ||
) |
Overloaded version of __(long,int,NumberFormat) which provides default parameter(s).
value | The value to append. |
numberFormat | The format definition. Defaults to null . |
this
to allow concatenated calls. AString __ | ( | Object | object | ) |
Appends an object by invoking toString
on it.
object | The object whose string representation is to be appended. |
this
to allow concatenated calls. AString __ | ( | String | src | ) |
Append a String.
src | The CharSequence to append. |
this
to allow concatenated calls. AString _Bin | ( | long | value | ) |
Overloaded version of _Bin(long,int,NumberFormat) which provides default parameter(s).
value | The value to append. |
this
to allow concatenated calls. AString _Bin | ( | long | value, |
int | overrideWidth | ||
) |
Overloaded version of _Bin(long,int,NumberFormat) which provides default parameter(s).
value | The value to append. |
overrideWidth | If not 0 (the default), overrides the output width otherwise specified in field NumberFormat.binFieldWidth. |
this
to allow concatenated calls. AString _Bin | ( | long | value, |
int | overrideWidth, | ||
NumberFormat | numberFormat | ||
) |
Append a 64-Bit integer value in binary format.
Parameter numberFormat defaults to null
, which denotes this method to use the static singleton found in NumberFormat.computational. To generate output better readable for humans, provide NumberFormat.global, or a customized object of that type.
See NumberFormat for more information on formatting options.
value | The value to append. |
overrideWidth | If not 0 (the default), overrides the output width otherwise specified in field NumberFormat.binFieldWidth. |
numberFormat | The format definition. Defaults to null . |
this
to allow concatenated calls. AString _Bin | ( | long | value, |
NumberFormat | numberFormat | ||
) |
Overloaded version of _Bin(long,int,NumberFormat) which provides default parameter(s).
value | The value to append. |
numberFormat | The format definition. Defaults to null . |
this
to allow concatenated calls. AString _Hex | ( | long | value | ) |
Overloaded version of _Hex(long,int,NumberFormat) which provides default parameter(s).
value | The value to append. |
this
to allow concatenated calls. AString _Hex | ( | long | value, |
int | overrideWidth | ||
) |
Overloaded version of _Hex(long,int,NumberFormat) which provides default parameter(s).
value | The value to append. |
overrideWidth | If not 0 (the default), overrides the output width otherwise specified in field NumberFormat.hexFieldWidth. |
this
to allow concatenated calls. AString _Hex | ( | long | value, |
int | overrideWidth, | ||
NumberFormat | numberFormat | ||
) |
Append a 64-Bit integer value in hexadecimal format.
Parameter numberFormat defaults to null
, which denotes this method to use the static singleton found in NumberFormat.computational. To generate output better readable for humans, provide NumberFormat.global, or a customized object of that type.
See NumberFormat for more information on formatting options.
value | The value to append. |
overrideWidth | If not 0 (the default), overrides the output width otherwise specified in field NumberFormat.hexFieldWidth. |
numberFormat | The format definition. Defaults to null . |
this
to allow concatenated calls. AString _Hex | ( | long | value, |
NumberFormat | numberFormat | ||
) |
Overloaded version of _Hex(long,int,NumberFormat) which provides default parameter(s).
value | The value to append. |
numberFormat | The format definition. Defaults to null . |
this
to allow concatenated calls. Append an AString.
src | The source AString. |
this
to allow concatenated calls. Append a region of an AString.
src | The source AString. |
regionStart | The start of the region in src to append. |
regionLength | The length of the region in src to append. |
this
to allow concatenated calls. AString _NC | ( | char[] | src, |
int | regionStart, | ||
int | regionLength | ||
) |
Append a region of a char[].
src | The character containing the region to append. |
regionStart | The start of the region in src to append. |
regionLength | The maximum length of the region in src to append. |
this
to allow concatenated calls. AString _NC | ( | com.aworx.lib.strings.Substring | src | ) |
Append a Substring.
src | The source Substring. |
this
to allow concatenated calls. AString _NC | ( | Object | object | ) |
Appends an object by invoking toString
on it.
object | The object whose string representation is to be appended. |
this
to allow concatenated calls. AString _NC | ( | String | src | ) |
Append a String.
src | The string containing the region to append. |
this
to allow concatenated calls. AString _NC | ( | String | src, |
int | regionStart, | ||
int | regionLength | ||
) |
Append a region of a String.
src | The string containing the region to append. |
regionStart | The start of the region in src to append. |
regionLength | The length of the region in src to append. |
this
to allow concatenated calls. AString _Oct | ( | long | value | ) |
Overloaded version of _Oct(long,int,NumberFormat) which provides default parameter(s).
value | The value to append. |
this
to allow concatenated calls. AString _Oct | ( | long | value, |
int | overrideWidth | ||
) |
Overloaded version of _Oct(long,int,NumberFormat) which provides default parameter(s).
value | The value to append. |
overrideWidth | If not 0 (the default), overrides the output width otherwise specified in field NumberFormat.octFieldWidth. |
this
to allow concatenated calls. AString _Oct | ( | long | value, |
int | overrideWidth, | ||
NumberFormat | numberFormat | ||
) |
Append a 64-Bit integer value in octal format.
Parameter numberFormat defaults to null
, which denotes this method to use the static singleton found in NumberFormat.computational. To generate output better readable for humans, provide NumberFormat.global, or a customized object of that type.
See NumberFormat for more information on formatting options.
value | The value to append. |
overrideWidth | If not 0 (the default), overrides the output width otherwise specified in field NumberFormat.octFieldWidth. |
numberFormat | The format definition. Defaults to null . |
this
to allow concatenated calls. AString _Oct | ( | long | value, |
NumberFormat | numberFormat | ||
) |
Overloaded version of _Oct(long,int,NumberFormat) which provides default parameter(s).
value | The value to append. |
numberFormat | The format definition. Defaults to null . |
this
to allow concatenated calls. char [] buffer | ( | ) |
int capacity | ( | ) |
Returns the current size of the internal buffer.
char charAt | ( | int | idx | ) |
Retrieves the character at the given index. A range check is performed. If this fails, '\0' is returned.
idx | The index of the character to read. |
char charAt_NC | ( | int | idx | ) |
Retrieves the character at the given index.
idx | The index of the character to read. |
char charAtEnd | ( | ) |
Retrieve the last character. In case of an empty string, '\0' is returned.
char charAtEnd_NC | ( | ) |
Retrieve the last character.
char charAtStart | ( | ) |
Retrieve the first character. In case of an empty string, '\0' is returned.
char charAtStart_NC | ( | ) |
Retrieve the first character.
AString clear | ( | ) |
Clear the Buffer. Same as delete (0, Length()) but without internal region checks.
this
to allow concatenated calls. 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. If the given region start is out of bounds in respect to the given string, it gets 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. If the given region is out of bounds in respect to the given string, it 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. |
int compareTo | ( | CharSequence | cmpString, |
Case | sensitivity, | ||
int | cmpRegionStart, | ||
int | cmpRegionLength, | ||
int | regionStart | ||
) |
Compares a given region of a string with a region of 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. |
regionStart | The start of the substring within this string that is to be compared. Defaults to 0. |
int compareTo | ( | CharSequence | cmpString, |
Case | sensitivity, | ||
int | cmpRegionStart, | ||
int | cmpRegionLength, | ||
int | regionStart, | ||
int | regionLength | ||
) |
Compares a given region of a string with a region of 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. |
regionStart | The start of the substring within this string that is to be compared. Defaults to 0. |
regionLength | The length of the substring within this string that is to be compared. Defaults to Integer.MAX_VALUE. |
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 | ( | com.aworx.lib.strings.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. |
boolean containsAt | ( | com.aworx.lib.strings.Substring | needle, |
int | pos, | ||
Case | sensitivity | ||
) |
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. |
AString delete | ( | int | regionStart | ) |
Overloaded version of delete(int,int) that provides the default value Integer.MAX_VALUE as parameter regionLength.
regionStart | The start of the region to delete. |
this
to allow concatenated calls. AString delete | ( | int | regionStart, |
int | regionLength | ||
) |
Cuts out a region from the Buffer. A range check is performed and the region is cut to fit to the string.
regionStart | The start of the region to delete. |
regionLength | The length of the region to delete. Defaults to Integer.MAX_VALUE. |
this
to allow concatenated calls. AString delete_NC | ( | int | regionStart, |
int | regionLength | ||
) |
Cuts out a region from the Buffer.
regionStart | The start of the region to delete. |
regionLength | The length of the region to delete. |
this
to allow concatenated calls. AString deleteEnd | ( | int | regionLength | ) |
Deletes the given number of characters from the end of the string. The given region length is checked to be between 0 and length.
regionLength | The length of the region at the end to delete. |
this
to allow concatenated calls. AString deleteEnd_NC | ( | int | regionLength | ) |
Deletes the given number of characters from the end of the string.
regionLength | The length of the region at the end to delete. |
this
to allow concatenated calls. AString deleteStart | ( | int | regionLength | ) |
Deletes the given number of characters from the start of the string. The given region length is checked to be between 0 and length.
regionLength | The length of the region at the start to delete. |
this
to allow concatenated calls. AString deleteStart_NC | ( | int | regionLength | ) |
Deletes the given number of characters from the start of the string. Does not check and correct the parameters.
regionLength | The length of the region at the start to delete. |
this
to allow concatenated calls. boolean endsWith | ( | AString | needle | ) |
boolean endsWith | ( | CharSequence | needle | ) |
Checks if this AString 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 AString 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 | ( | com.aworx.lib.strings.Substring | needle | ) |
boolean endsWith | ( | com.aworx.lib.strings.Substring | needle, |
Case | sensitivity | ||
) |
void ensureRemainingCapacity | ( | int | spaceNeeded | ) |
Ensures that the capacity of the internal buffer meets or exceeds the actual length plus the given growth value.
spaceNeeded | The desired growth of the length of the string represented by this. |
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 | ( | com.aworx.lib.strings.Substring | cmpString | ) |
boolean equals | ( | com.aworx.lib.strings.Substring | cmpString, |
Case | sensitivity | ||
) |
Tests and returns true, if the given 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. |
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. |
AString escape | ( | ) |
Overloaded version providing default parameter(s).
this
to allow concatenated calls. Overloaded version providing default parameter(s).
escape | Switch.On escapes ascii characters (the default), Switch.Off converts escaped strings to ascii codes. |
this
to allow concatenated calls. Overloaded version providing default parameter(s).
escape | Switch.On escapes ascii characters (the default), Switch.Off converts escaped strings to ascii codes. |
regionStart | The start of the region to convert. |
this
to allow concatenated calls. Escapes non-printable characters in the given region, or converts such escaped characters to their ASCII values.
If the new region length is needed to be known, it can be calculated as the sum of the old region length and the difference of the string before and after the operation.
escape | Switch.On escapes ascii characters (the default), Switch.Off converts escaped strings to ascii codes. |
regionStart | The start of the region to convert. |
regionLength | The length of the region to convert. |
this
to allow concatenated calls. AString field | ( | ) |
Marks the start of a field. See variants of this method for more information.
this
to allow concatenated calls. AString field | ( | int | size | ) |
Closes and formats a field of the given size. Contents is aligned right. The Field is fill with spaces to reach the size. See variants of this method for more information.
size | The field size in relation to the starting index of the field, defined by using Field() prior to this invocation. |
this
to allow concatenated calls. Closes and formats a field of the given size. Contents is aligned as specified. The Field is fill with spaces to reach the size. See variants of this method for more information.
size | The field size in relation to the starting index of the field, defined by using Field() prior to this invocation. |
alignment | The alignment of the contents within the field. Defaults to ALIB.Align.RIGHT. Other options are ALIB.Align.LEFT and ALIB.Align.CENTER. |
this
to allow concatenated calls. Closes and formats a field of the given size. Contents is aligned as specified. The Field is fill with the character provided. See variants of this method for more information.
size | The field size in relation to the starting index of the field, defined either by using Field() prior to this invocation or by providing the parameter fieldStart. The field gets filled with the given pad character to meet the size while the content gets aligned left, right or centered. If the content exceeds the size, then no alignment takes place. |
alignment | The alignment of the contents within the field. Defaults to ALIB.Align.RIGHT. Other options are ALIB.Align.LEFT and ALIB.Align.CENTER. |
padChar | The character used to fill the field up to its size. Defaults to ' ' (space). |
this
to allow concatenated calls. If invoked without parameters, the start of a field is marked at the current end of the string. Otherwise the end of a field is set and the contents between the field start marker and the current end of the string is aligned within the field using the given pad character.
size | The field size in relation to the starting index of the field, defined either by using Field() prior to this invocation or by providing the parameter fieldStart. The field gets filled with the given pad character to meet the size while the content gets aligned left, right or centered. If the content exceeds the size, then no alignment takes place. |
alignment | The alignment of the contents within the field. Defaults to ALIB.Align.RIGHT. Other options are ALIB.Align.LEFT and ALIB.Align.CENTER. |
padChar | The character used to fill the field up to its size. Defaults to ' ' (space). |
fieldStart | This parameter, if given, overwrites the start index of the field. The invocation of field can be omitted, when this value is explicitly provided. Defaults to Integer.MAX_VALUE. |
this
to allow concatenated calls. int hashCode | ( | ) |
Calculates the hash value using the same formula as java.lang.String.
int indexOf | ( | char | c | ) |
Search a character in the buffer.
c | The character to search. |
int indexOf | ( | char | c, |
int | startIdx | ||
) |
Search a character in the buffer.
c | 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 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. |
AString insertAt | ( | CharSequence | src, |
int | pos | ||
) |
Inserts a string at a given position. If the given position is out of range, nothing is inserted.
src | The CharSequence to insert characters from. |
pos | The position in this object insert the portion of src. |
this
to allow concatenated calls. AString insertChars | ( | char | c, |
int | qty | ||
) |
Inserts the given character n-times at the end of this string (appends).
c | The character to append. |
qty | The quantity of characters to append. |
this
to allow concatenated calls. AString insertChars | ( | char | c, |
int | qty, | ||
int | pos | ||
) |
Inserts the given character n-times at a given position. If the given position is out of range, nothing is inserted.
c | The character to insert qty times. |
qty | The quantity of characters to insert. |
pos | The index in this object where c is inserted qty times. |
this
to allow concatenated calls. boolean isEmpty | ( | ) |
Returns true if the actual length equals zero.
boolean isNotEmpty | ( | ) |
Returns true if the actual length does not equal zero.
boolean isNotNull | ( | ) |
Returns false if no buffer space is allocated, true otherwise. This might be the case, if constructed with AString() or AString(0), by invoking setBuffer(0) or setNull.
boolean isNull | ( | ) |
Returns true if no buffer space is allocated, false otherwise. This might be the case, if constructed with AString() or AString(0), by invoking setBuffer(0) or setNull.
int lastIndexOf | ( | char | needle | ) |
Searches a character backwards from the end or a given start index.
needle | The character to search for. |
int lastIndexOf | ( | char | needle, |
int | startIndex | ||
) |
Searches a character backwards from the given start index.
needle | The character to search for. |
startIndex | The index in this to start searching the character. Defaults to the end of this string. |
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 given index and goes backward. For forward search, see indexOfAny(char[] p,Inclusion,int) "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(char[] p,Inclusion,int) "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 AString minus one. Defaults to the length of this AString. |
int length | ( | ) |
Gets the length of the sequence.
AString newLine | ( | ) |
Appends platform specific new line character(s). ( "\\r\\n", "\\r", etc.). The new length of the string is recorded as the reference position for tab.
this
to allow concatenated calls. long parseBin | ( | ) |
Overloaded version of parseBin providing default values for omitted parameters.
long parseBin | ( | int | startIdx | ) |
Overloaded version of parseBin providing default values for omitted parameters.
startIdx | The start index from where the integer value is tried to be parsed. Optional and defaults to 0 . |
long parseBin | ( | int | startIdx, |
int[] | newIdx | ||
) |
Overloaded version of parseBin providing default values for omitted parameters.
startIdx | The start index from where the integer value is tried to be parsed. Optional and defaults to 0 . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the float number that was parsed. On failure, it will be set to the initial value startIdx. |
long parseBin | ( | int | startIdx, |
NumberFormat | numberFormat | ||
) |
Overloaded version of parseBin providing default values for omitted parameters.
startIdx | The start index for parsing. Optional and defaults to 0 . |
numberFormat | The format definition. Defaults to null . |
long parseBin | ( | int | startIdx, |
NumberFormat | numberFormat, | ||
int[] | newIdx | ||
) |
Reads an unsigned 64-bit integer in binary format at the given position from this AString. 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.
Optional output parameter newIdx may be used to detect if parsing was successful. If not, it receives the value of startIdx, even if leading whitespaces had been read.
For more information on number conversion, see class NumberFormat. All of its interface methods have a corresponding implementation within class AString.
startIdx | The start index for parsing. Optional and defaults to 0 . | |
numberFormat | The format definition. Defaults to null . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value startIdx. |
long parseBin | ( | int[] | newIdx | ) |
Overloaded version of parseBin providing default values for omitted parameters.
[out] | newIdx | Optional output variable that will point to the first character in this string after the float number that was parsed. On failure, it will be set to the initial value 0 . |
long parseBin | ( | NumberFormat | numberFormat | ) |
Overloaded version of parseBin providing default values for omitted parameters.
numberFormat | The format definition. Defaults to null . |
long parseBin | ( | NumberFormat | numberFormat, |
int[] | newIdx | ||
) |
Overloaded version of parseBin providing default values for omitted parameters.
numberFormat | The format definition. | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the float number that was parsed. On failure, it will be set to the initial value 0 . |
long parseDec | ( | ) |
Overloaded version of parseDec providing default values for omitted parameters.
long parseDec | ( | int | startIdx | ) |
Overloaded version of parseDec providing default values for omitted parameters.
startIdx | The start index from where the integer value is tried to be parsed. Optional and defaults to 0 . |
long parseDec | ( | int | startIdx, |
int[] | newIdx | ||
) |
Overloaded version of parseDec providing default values for omitted parameters.
startIdx | The start index from where the integer value is tried to be parsed. Optional and defaults to 0 . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the float number that was parsed. On failure, it will be set to the initial value startIdx. |
long parseDec | ( | int | startIdx, |
NumberFormat | numberFormat | ||
) |
Overloaded version of parseDec providing default values for omitted parameters.
startIdx | The start index for parsing. Optional and defaults to 0 . |
numberFormat | The format definition. Defaults to null . |
long parseDec | ( | int | startIdx, |
NumberFormat | numberFormat, | ||
int[] | newIdx | ||
) |
Reads an unsigned 64-bit integer in standard decimal format at the given position from this AString. 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.
Optional output parameter newIdx may be used to detect if parsing was successful. If not, it receives the value of startIdx, even if leading whitespaces had been read.
Sign literals '-'
or '+'
are not accepted and parsing will fail. For reading signed integer values, see methods parseInt, for floating point numbers parseFloat.
For more information on number conversion, see class NumberFormat. All of its interface methods have a corresponding implementation within class AString.
Long.MAX_VALUE
in this language implementation of ALib.startIdx | The start index for parsing. Optional and defaults to 0 . | |
numberFormat | The format definition. Defaults to null . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value startIdx. |
long parseDec | ( | int[] | newIdx | ) |
Overloaded version of parseDec providing default values for omitted parameters.
[out] | newIdx | Optional output variable that will point to the first character in this string after the float number that was parsed. On failure, it will be set to the initial value 0 . |
long parseDec | ( | NumberFormat | numberFormat | ) |
Overloaded version of parseDec providing default values for omitted parameters.
numberFormat | The format definition. Defaults to null . |
long parseDec | ( | NumberFormat | numberFormat, |
int[] | newIdx | ||
) |
Overloaded version of parseDec providing default values for omitted parameters.
numberFormat | The format definition. Defaults to null . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the float number that was parsed. On failure, it will be set to the initial value 0 . |
long parseDecDigits | ( | int | startIdx, |
int[] | newIdx | ||
) |
Parses an integer value consisting of characters '0'
to '9'
from this string.
Unlike with parseInt or parseDec, no sign, whitespaces or group characters are accepted.
startIdx | The start index for parsing. Optional and defaults to 0 . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value startIdx. |
double parseFloat | ( | ) |
Overloaded version of parseFloat providing default values for omitted parameters.
double parseFloat | ( | int | startIdx | ) |
Overloaded version of parseFloat providing default values for omitted parameters.
startIdx | The start index from where the integer value is tried to be parsed. Optional and defaults to 0 . |
double parseFloat | ( | int | startIdx, |
int[] | newIdx | ||
) |
Overloaded version of parseFloat providing default values for omitted parameters.
startIdx | The start index from where the integer value is tried to be parsed. Optional and defaults to 0 . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the float number that was parsed. On failure, it will be set to the initial value startIdx. |
double parseFloat | ( | int | startIdx, |
NumberFormat | numberFormat | ||
) |
Overloaded version of parseFloat providing default values for omitted parameters.
startIdx | The start index for parsing. Optional and defaults to 0 . |
numberFormat | The format definition. Defaults to null . |
double parseFloat | ( | int | startIdx, |
NumberFormat | numberFormat, | ||
int[] | newIdx | ||
) |
Reads 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.
Optional output parameter newIdx may be used to detect if parsing was successful. If not, it receives the value of startIdx, even if leading whitespaces had been read.
For more information on parsing options for floating point numbers and number conversion in general, see class NumberFormat. All of its interface methods have a corresponding implementation within class AString.
startIdx | The start index for parsing. Optional and defaults to 0 . | |
numberFormat | The format definition. Defaults to null . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value startIdx. |
double parseFloat | ( | int[] | newIdx | ) |
Overloaded version of parseFloat providing default values for omitted parameters.
[out] | newIdx | Optional output variable that will point to the first character in this string after the float number that was parsed. On failure, it will be set to the initial value 0 . |
double parseFloat | ( | NumberFormat | numberFormat | ) |
Overloaded version of parseFloat providing default values for omitted parameters.
numberFormat | The format definition. Defaults to null . |
double parseFloat | ( | NumberFormat | numberFormat, |
int[] | newIdx | ||
) |
Overloaded version of parseFloat providing default values for omitted parameters.
numberFormat | The format definition. Defaults to null . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the float number that was parsed. On failure, it will be set to the initial value 0 . |
long parseHex | ( | ) |
Overloaded version of parseHex providing default values for omitted parameters.
long parseHex | ( | int | startIdx | ) |
Overloaded version of parseHex providing default values for omitted parameters.
startIdx | The start index from where the integer value is tried to be parsed. Optional and defaults to 0 . |
long parseHex | ( | int | startIdx, |
int[] | newIdx | ||
) |
Overloaded version of parseHex providing default values for omitted parameters.
startIdx | The start index from where the integer value is tried to be parsed. Optional and defaults to 0 . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the float number that was parsed. On failure, it will be set to the initial value startIdx. |
long parseHex | ( | int | startIdx, |
NumberFormat | numberFormat | ||
) |
Overloaded version of parseHex providing default values for omitted parameters.
startIdx | The start index for parsing. Optional and defaults to 0 . |
numberFormat | The format definition. Defaults to null . |
long parseHex | ( | int | startIdx, |
NumberFormat | numberFormat, | ||
int[] | newIdx | ||
) |
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.
Optional output parameter newIdx may be used to detect if parsing was successful. If not, it receives the value of startIdx, even if leading whitespaces had been read.
For more information on number conversion, see class NumberFormat. All of its interface methods have a corresponding implementation within class AString.
startIdx | The start index for parsing. Optional and defaults to 0 . | |
numberFormat | The format definition. Defaults to null . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value startIdx. |
long parseHex | ( | int[] | newIdx | ) |
Overloaded version of parseHex providing default values for omitted parameters.
[out] | newIdx | Optional output variable that will point to the first character in this string after the float number that was parsed. On failure, it will be set to the initial value 0 . |
long parseHex | ( | NumberFormat | numberFormat | ) |
Overloaded version of parseHex providing default values for omitted parameters.
numberFormat | The format definition. Defaults to null . |
long parseHex | ( | NumberFormat | numberFormat, |
int[] | newIdx | ||
) |
Overloaded version of parseHex providing default values for omitted parameters.
numberFormat | The format definition. Defaults to null . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the float number that was parsed. On failure, it will be set to the initial value 0 . |
long parseInt | ( | ) |
Overloaded version of parseInt providing default values for omitted parameters.
long parseInt | ( | int | startIdx | ) |
Overloaded version of parseInt providing default values for omitted parameters.
startIdx | The start index from where the integer value is tried to be parsed. Optional and defaults to 0 . |
long parseInt | ( | int | startIdx, |
int[] | newIdx | ||
) |
Overloaded version of parseInt providing default values for omitted parameters.
startIdx | The start index from where the integer value is tried to be parsed. Optional and defaults to 0 . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the float number that was parsed. On failure, it will be set to the initial value startIdx. |
long parseInt | ( | int | startIdx, |
NumberFormat | numberFormat | ||
) |
Overloaded version of parseInt providing default values for omitted parameters.
startIdx | The start index for parsing. Optional and defaults to 0 . |
numberFormat | The format definition. Defaults to null . |
long parseInt | ( | int | startIdx, |
NumberFormat | numberFormat, | ||
int[] | newIdx | ||
) |
Parses a long integer value in decimal, binary, hexadecimal or octal format from 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.
Optional output parameter newIdx may be used to detect if parsing was successful. If not, it receives the value of startIdx, even if leading whitespaces had been read.
For more information on number conversion, see class NumberFormat. All of its interface methods have a corresponding implementation within class AString.
startIdx | The start index for parsing. Optional and defaults to 0 . | |
numberFormat | The format definition. Defaults to null . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value startIdx. |
long parseInt | ( | int[] | newIdx | ) |
Overloaded version of parseInt providing default values for omitted parameters.
[out] | newIdx | Optional output variable that will point to the first character in this string after the float number that was parsed. On failure, it will be set to the initial value 0 . |
long parseInt | ( | NumberFormat | numberFormat | ) |
Overloaded version of parseInt providing default values for omitted parameters.
numberFormat | The format definition. Defaults to null . |
long parseInt | ( | NumberFormat | numberFormat, |
int[] | newIdx | ||
) |
Overloaded version of parseInt providing default values for omitted parameters.
numberFormat | The format definition. Defaults to null . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the float number that was parsed. On failure, it will be set to the initial value 0 . |
long parseOct | ( | ) |
Overloaded version of parseOct providing default values for omitted parameters.
long parseOct | ( | int | startIdx | ) |
Overloaded version of parseOct providing default values for omitted parameters.
startIdx | The start index from where the integer value is tried to be parsed. Optional and defaults to 0 . |
long parseOct | ( | int | startIdx, |
int[] | newIdx | ||
) |
Overloaded version of parseOct providing default values for omitted parameters.
startIdx | The start index from where the integer value is tried to be parsed. Optional and defaults to 0 . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the float number that was parsed. On failure, it will be set to the initial value startIdx. |
long parseOct | ( | int | startIdx, |
NumberFormat | numberFormat | ||
) |
Overloaded version of parseOct providing default values for omitted parameters.
startIdx | The start index for parsing. Optional and defaults to 0 . |
numberFormat | The format definition. Defaults to null . |
long parseOct | ( | int | startIdx, |
NumberFormat | numberFormat, | ||
int[] | newIdx | ||
) |
Reads an unsigned 64-bit integer in octal format at the given position from this AString. 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.
Optional output parameter newIdx may be used to detect if parsing was successful. If not, it receives the value of startIdx, even if leading whitespaces had been read.
For more information on number conversion, see class NumberFormat. All of its interface methods have a corresponding implementation within class AString.
1
.startIdx | The start index for parsing. Optional and defaults to 0 . | |
numberFormat | The format definition. Defaults to null . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the number parsed. On failure, it will be set to the initial value startIdx. |
long parseOct | ( | int[] | newIdx | ) |
Overloaded version of parseOct providing default values for omitted parameters.
[out] | newIdx | Optional output variable that will point to the first character in this string after the float number that was parsed. On failure, it will be set to the initial value 0 . |
long parseOct | ( | NumberFormat | numberFormat | ) |
Overloaded version of parseOct providing default values for omitted parameters.
numberFormat | The format definition. Defaults to null . |
long parseOct | ( | NumberFormat | numberFormat, |
int[] | newIdx | ||
) |
Overloaded version of parseOct providing default values for omitted parameters.
numberFormat | The format definition. Defaults to null . | |
[out] | newIdx | Optional output variable that will point to the first character in this string after the float number that was parsed. On failure, it will be set to the initial value 0 . |
AString replaceRegion | ( | char | c, |
int | regionStart, | ||
int | regionLength | ||
) |
Replaces a region in the string with the given character. The region is adjusted to fit into the current length. In other words, the length of this instances remains the same.
c | The character to set in the region. |
regionStart | The start of the region |
regionLength | The length of the region |
this
to allow concatenated calls. AString replaceSubstring | ( | CharSequence | src, |
int | regionStart, | ||
int | regionLength | ||
) |
Replaces a substring in this object by a given string. If the region does not fit to this object, then nothing is done.
src | The replacement CharSequence. |
regionStart | The start of the region. |
regionLength | The length of the region. |
this
to allow concatenated calls.
|
protected |
Protected method that resizes a region into the Buffer. The region contents is undefined.
regionStart | The start of the region to insert. If this is out of the string bounds (hence less than 0 or greater then length), nothing is done. |
regionLength | The current length of the region. |
newLength | The desired length of the region. |
true
, if the parameters were OK and the region was resized, false
otherwise. int searchAndReplace | ( | char | needle, |
char | replacement | ||
) |
Replaces one or more occurrences of one character by another character.
needle | The terminatable string to be replaced. |
replacement | The replacement string (does not need to be zero terminatable). |
int searchAndReplace | ( | char | needle, |
char | replacement, | ||
int | startIdx | ||
) |
Replaces one or more occurrences of one character by another character.
needle | The terminatable string to be replaced. |
replacement | The replacement string (does not need to be zero terminatable). |
startIdx | The index where the search starts. Optional and defaults 0. |
int searchAndReplace | ( | CharSequence | searchStr, |
CharSequence | newStr | ||
) |
Replace one or more occurrences of a string by another string. Returns the number of replacements.
searchStr | The CharSequence to be replaced. |
newStr | The replacement string. |
int searchAndReplace | ( | CharSequence | searchStr, |
CharSequence | newStr, | ||
int | startIdx | ||
) |
Replace one or more occurrences of a string by another string. Returns the number of replacements.
searchStr | The CharSequence to be replaced. |
newStr | The replacement string. |
startIdx | The index where the search starts. Optional and defaults to 0 . |
int searchAndReplace | ( | CharSequence | searchStr, |
CharSequence | newStr, | ||
int | startIdx, | ||
int | maxReplacements | ||
) |
Replace one or more occurrences of a string by another string. Returns the number of replacements.
searchStr | The CharSequence to be replaced. |
newStr | The replacement string. |
startIdx | The index where the search starts. Optional and defaults to 0 . |
maxReplacements | The maximum number of replacements to perform. Optional and defaults to Integer.MAX_VALUE . |
int searchAndReplace | ( | CharSequence | searchStr, |
CharSequence | newStr, | ||
int | startIdx, | ||
int | maxReplacements, | ||
Case | sensitivity | ||
) |
Replace one or more occurrences of a string by another string. Returns the number of replacements.
searchStr | The CharSequence to be replaced. |
newStr | The replacement string. |
startIdx | The index where the search starts. Optional and defaults to 0 . |
maxReplacements | The maximum number of replacements to perform. Optional and defaults to Integer.MAX_VALUE . |
sensitivity | Case sensitivity of the operation. Optional and defaults to Case.Sensitive. |
AString searchAndReplaceAll | ( | CharSequence | searchStr, |
CharSequence | newStr | ||
) |
Replace one or more occurrences of a string by another string.
searchStr | The CharSequence to be replaced. |
newStr | The replacement string. |
this
to allow concatenated calls. void setBuffer | ( | int | newCapacity | ) |
Resizes the internal buffer to meet exactly the given size.
The following rules apply:
newCapacity | The new capacity of the internal buffer. |
void setCharAt | ( | int | idx, |
char | c | ||
) |
Sets the character at the given index. A range check is performed. If this fails, nothing is done.
idx | The index of the character to write. |
c | The character to write. |
void setCharAt_NC | ( | int | idx, |
char | c | ||
) |
Sets the character at the given index.
idx | The index of the character to write. |
c | The character to write. |
int setLength | ( | int | newLength | ) |
Set the actual length of the stored string. Using this method, the string can only be shortened. To change the internal allocation size, see setBuffer.
newLength | The new length of the AString. Must be smaller than the current length. |
void setLength_NC | ( | int | newLength | ) |
Set the actual length of the stored string. Using this method, the string can only be shortened. To change the internal allocation size, see setBuffer.
newLength | The new length of the AString. Must be between 0 and the current length. |
void setNull | ( | ) |
Invokes setBuffer(0) or setNull.
boolean startsWith | ( | AString | needle | ) |
boolean startsWith | ( | CharSequence | needle | ) |
Checks if this AString 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 AString 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 | ( | com.aworx.lib.strings.Substring | needle | ) |
boolean startsWith | ( | com.aworx.lib.strings.Substring | needle, |
Case | sensitivity | ||
) |
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) |
AString tab | ( | int | tabSize | ) |
Overloaded method of tab(int, int, char), providing ' ' (space) as default value for parameter tabChar and 1 as default value for parameter minPad.
tabSize | The tab positions are multiples of this parameter. |
this
to allow concatenated calls. AString tab | ( | int | tabSize, |
int | minPad | ||
) |
Overloaded method of tab(int, int, char), providing ' ' (space) as default value for parameter tabChar.
tabSize | The tab positions are multiples of this parameter. |
minPad | The minimum pad characters to add. Defaults to 1. |
this
to allow concatenated calls. AString tab | ( | int | tabSize, |
int | minPad, | ||
char | tabChar | ||
) |
Go to the next tab stop by filling in pad characters repeatedly. The tab position is relative the start of the current line within the string (if no calls to newLine where performed, yet, this is always the start of the string).
tabSize | The tab positions are multiples of this parameter. |
minPad | (Optional) The minimum pad characters to add. Defaults to 1. |
tabChar | (Optional) The character to insert to reach the that position. Defaults to ' ' (space). |
this
to allow concatenated calls. AString toLower | ( | ) |
Converts all characters in the buffer to lower case.
this
to allow concatenated calls. AString toLower | ( | int | regionStart | ) |
Converts characters in the buffer to lower case.
regionStart | Start of the region to be converted. Defaults to 0 |
this
to allow concatenated calls. AString toLower | ( | int | regionStart, |
int | regionLength | ||
) |
Converts all or a region of characters in the buffer to lower case.
regionStart | Start of the region to be converted. Defaults to 0 |
regionLength | Length of the region to be converted. Defaults to int.MaxValue. |
this
to allow concatenated calls. String toString | ( | ) |
Creates a String containing a copy of the contents of this AString.
String toString | ( | int | regionStart | ) |
String toString | ( | int | regionStart, |
int | regionLength | ||
) |
Creates a String containing a copy of a region of the contents of this AString.
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. |
StringBuilder toString | ( | StringBuilder | result, |
int | regionStart, | ||
int | regionLength, | ||
boolean | appendMode | ||
) |
Copies a region of the contents of this AString into the given StringBuilder.
result | A result StringBuilder to copy the specified region into. If null , a new String builder is created |
regionStart | The start index of the region to be copied. |
regionLength | The maximum length of the region to be copied. |
appendMode | If true, any contents in the result is preserved. Otherwise such content gets replaced. |
AString toUpper | ( | ) |
Converts all characters in the buffer to upper case.
this
to allow concatenated calls. AString toUpper | ( | int | regionStart | ) |
Converts characters in the buffer to upper case.
regionStart | Start of the region to be converted. Defaults to 0 |
this
to allow concatenated calls. AString toUpper | ( | int | regionStart, |
int | regionLength | ||
) |
Converts all or a region of characters in the buffer to upper case.
regionStart | Start of the region to be converted. Defaults to 0 |
regionLength | Length of the region to be converted. Defaults to int.MaxValue. |
this
to allow concatenated calls. AString trim | ( | ) |
All characters in CString.DEFAULT_WHITESPACES are removed at the beginning and at the end of this AString. See method trimAt to remove whitespaces anywhere in the string.
this
to allow concatenated calls. AString trim | ( | char[] | trimChars | ) |
All characters defined in given set are removed at the beginning and at the end of this AString.
See method trimAt to remove whitespaces anywhere in the string.
trimChars | The set of characters to be omitted. Defaults to null which causes this method to use CString.DEFAULT_WHITESPACES. |
this
to allow concatenated calls. int trimAt | ( | int | idx, |
char[] | trimChars | ||
) |
All characters defined in given set at, left of and right of the given index are removed from the string.
The method returns index of the first character of those characters that were behind the trimmed region. With legal index given, this value can only be smaller or equal to index. If index is out of bounds, the length of the string is returned.
idx | The index to perform the trim operation at. Has to be between zero and Length() -1. |
trimChars | Pointer to a zero terminated set of characters to be omitted. Defaults to CString.DEFAULT_WHITESPACES. |
int trimAt | ( | int | index | ) |
Overloaded method providing default CString.DEFAULT_WHITESPACES value for parameter trimChars.
index | The index to perform the trim operation at. Has to be between zero and Length() -1. |
AString trimEnd | ( | ) |
All characters in CString.DEFAULT_WHITESPACES at the end of this string are removed.
this
to allow concatenated calls. AString trimEnd | ( | char[] | trimChars | ) |
All characters defined in given set are removed at the end of this string.
trimChars | The set of characters to be omitted. Defaults to CString.DEFAULT_WHITESPACES. |
this
to allow concatenated calls. AString trimStart | ( | ) |
All characters in CString.DEFAULT_WHITESPACES at the beginning of this string are removed.
this
to allow concatenated calls. AString trimStart | ( | char[] | trimChars | ) |
All characters defined in given set are removed at the beginning of this string.
trimChars | The set of characters to be omitted. Defaults to CString.DEFAULT_WHITESPACES. |
this
to allow concatenated calls.
|
protected |
Used as a return value of method CString.adjustRegion
|
protected |
The Buffer array. This may but should not be accessed directly. In case of external modifications the field hash has to be set to dirty (0).
|
protected |
A marker for the start of the actual field.
|
protected |
The hash value. Has to be set dirty (0) whenever String is changed from outside!.
|
protected |
The actual length of the string stored in the Buffer. In case of external modifications the field hash has to be set to dirty (0).
|
protected |
The tab reference position. This is set when newLine is invoked.