ALox  V. 2402 R. 0
Home ALox for C++ ALox for C# ALox for Java Download
Protected Fields | List of all members
AString Class Reference
Inheritance diagram for AString:
[legend]
Collaboration diagram for AString:
[legend]

Class Description


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.

Attention
The following rules apply to all methods suffixed by _NC:
  • Parameters are not checked for being null.
  • Index, size, length, region start/end and other parameters are not checked to be correct
  • If parameters are incorrect, the result of the methods are undefined and in debug compilations an assertion may be raised.
  • Append methods that in their original version would set a nulled AString to non nulled state in the case that an empty string or string region is appended, are not confirming to this principle in their _NC version. In other words, nulled strings keep being nulled if empty strings are appended.
  • In the Java and C# versions of the AWorx Library, the hash value of an AString object keeps being cached when invoking an _NC method. This may lead to wrong behavior, e.g. when an AString object is used as a key of a hash table. To avoid errors, within a context that makes use of an AStrings' hash value, before each hash code retrieval (C#: GetHashCode(), Java: hashCode()), it has to be certified that at least one of the methods manipulating the object has to be a non _NC method.
  • Apart from the previous points, the behavior and result of invoking an _NC version of a method is the same as of invoking the original version. The only difference is in a higher execution performance.
  • Another note specific to the Java implementation of the AWorx library: the overloaded methods including and not including the _NC prefix sometimes vary in their parameter types. This is because sometimes only generalizations, like replacing an AString parameter with more generalized CharSequence type of corresponding methods exist. The API assures however, that compilation and execution stays correct when removing or adding _NC to an invocation.

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)
 

Constructor & Destructor Documentation

◆ AString() [1/5]

AString ( )

Constructs an empty AString. Does not allocate a buffer.

◆ AString() [2/5]

AString ( int  size)

Constructor allocating a specific buffer size.

Note
This constructor is useful for AString objects whose minimum future string length is predictable to avoid recurring incremental allocations up to the known minimum size.
Parameters
sizeThe initial size of the internal buffer.

◆ AString() [3/5]

AString ( CharSequence  src)

Constructor copying a CharSequence.

Parameters
srcThe source CharSequence to copy from.

◆ AString() [4/5]

AString ( CharSequence  src,
int  regionStart 
)

Constructor copying a region of a CharSequence.

Parameters
srcThe source CharSequence to copy from.
regionStartThe start of the region in src to append. Defaults to 0.

◆ AString() [5/5]

AString ( CharSequence  src,
int  regionStart,
int  regionLength 
)

Constructor copying a region of a CharSequence.

Parameters
srcThe source CharSequence to copy from.
regionStartThe start of the region in src to append. Defaults to 0.
regionLengthThe maximum length of the region in src to append. Defaults to Integer.MAX_VALUE.

Member Function Documentation

◆ __() [1/24]

AString __ ( )

Clear the Buffer. Same as clear(), really just a synonym to allow short code in alignment with the various "Append" methods named _(src)

Returns
this to allow concatenated calls.

◆ __() [2/24]

AString __ ( AString  src)

Append an AString.

Parameters
srcThe AString to append.
Returns
this to allow concatenated calls.

◆ __() [3/24]

AString __ ( char  c)

Append a character.

Parameters
cThe character to append.
Returns
this to allow concatenated calls.

◆ __() [4/24]

AString __ ( char[]  src)

Append a char[].

Parameters
srcThe character array to append.
Returns
this to allow concatenated calls.

◆ __() [5/24]

AString __ ( char[]  src,
int  regionStart 
)

Append char[] beginning with given index.

Parameters
srcThe character array containing the region to append.
regionStartThe start of the region in src to append. Defaults to 0.
Returns
this to allow concatenated calls.

◆ __() [6/24]

AString __ ( char[]  src,
int  regionStart,
int  regionLength 
)

Append a region of a char[].

Parameters
srcThe character containing the region to append.
regionStartThe start of the region in src to append. Defaults to 0.
regionLengthThe maximum length of the region in src to append. Defaults to the length of the array minus the start of the region.
Returns
this to allow concatenated calls.

◆ __() [7/24]

AString __ ( CharSequence  src)

Append a CharSequence.

Parameters
srcThe CharSequence to append.
Returns
this to allow concatenated calls.

◆ __() [8/24]

AString __ ( CharSequence  src,
int  regionStart 
)

Append a region of a CharSequence.

Parameters
srcThe CharSequence to append.
regionStartThe start of the region in src to append. Defaults to 0.
Returns
this to allow concatenated calls.

◆ __() [9/24]

AString __ ( CharSequence  src,
int  regionStart,
int  regionLength 
)

Append a region of a CharSequence.

Parameters
srcThe CharSequence containing the region to append.
regionStartThe start of the region in src to append. Defaults to 0.
regionLengthThe maximum length of the region in src to append. Defaults to Integer.MAX_VALUE.
Returns
this to allow concatenated calls.

◆ __() [10/24]


Append a Substring.

Parameters
srcThe source Substring.
Returns
this to allow concatenated calls.

◆ __() [11/24]

AString __ ( double  value)

Overloaded version of __(double,int,NumberFormat) which provides default parameter(s).

Parameters
valueThe double value to append.
Returns
this to allow concatenated calls.

◆ __() [12/24]

AString __ ( double  value,
int  overrideWidth 
)

Overloaded version of __(double,int,NumberFormat) which provides default parameter(s).

Parameters
valueThe double value to append.
overrideWidthIf not 0 (the default), overrides the output width otherwise specified in field NumberFormat.integralPartMinimumWidth
Returns
this to allow concatenated calls.

◆ __() [13/24]

AString __ ( double  value,
int  overrideWidth,
NumberFormat  numberFormat 
)

Append a double value. See NumberFormat for more information on formatting options.

Parameters
valueThe double value to append.
overrideWidthIf not 0 (the default), overrides the output width otherwise specified in field NumberFormat.integralPartMinimumWidth
numberFormatThe format definition. Defaults to null.
Returns
this to allow concatenated calls.

◆ __() [14/24]

AString __ ( double  value,
NumberFormat  numberFormat 
)

Overloaded version of __(double,int,NumberFormat) which provides default parameter(s).

Parameters
valueThe double value to append.
numberFormatThe format definition. Defaults to null.
Returns
this to allow concatenated calls.

◆ __() [15/24]

AString __ ( int  value)

Overloaded version of __(int,int,NumberFormat) which provides default parameter(s).

Parameters
valueThe value to append.
Returns
this to allow concatenated calls.

◆ __() [16/24]

AString __ ( int  value,
int  overrideWidth 
)

Overloaded version of __(int,int,NumberFormat) which provides default parameter(s).

Parameters
valueThe value to append.
overrideWidthIf not 0 (the default), overrides the output width otherwise specified in field NumberFormat.decMinimumFieldWidth.
Returns
this to allow concatenated calls.

◆ __() [17/24]

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.

Parameters
valueThe value to append.
overrideWidthIf not 0 (the default), overrides the output width otherwise specified in field NumberFormat.decMinimumFieldWidth.
numberFormatThe format definition. Defaults to null.
Returns
this to allow concatenated calls.

◆ __() [18/24]

AString __ ( int  value,
NumberFormat  numberFormat 
)

Overloaded version of __(int,int,NumberFormat) which provides default parameter(s).

Parameters
valueThe value to append.
numberFormatThe format definition. Defaults to null.
Returns
this to allow concatenated calls.

◆ __() [19/24]

AString __ ( long  value)

Overloaded version of __(long,int,NumberFormat) which provides default parameter(s).

Parameters
valueThe value to append.
Returns
this to allow concatenated calls.

◆ __() [20/24]

AString __ ( long  value,
int  overrideWidth 
)

Overloaded version of __(long,int,NumberFormat) which provides default parameter(s).

Parameters
valueThe value to append.
overrideWidthIf not 0 (the default), overrides the output width otherwise specified in field NumberFormat.decMinimumFieldWidth.
Returns
this to allow concatenated calls.

◆ __() [21/24]

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.

Parameters
valueThe value to append.
overrideWidthIf not 0 (the default), overrides the output width otherwise specified in field NumberFormat.decMinimumFieldWidth.
numberFormatThe format definition. Defaults to null.
Returns
this to allow concatenated calls.

◆ __() [22/24]

AString __ ( long  value,
NumberFormat  numberFormat 
)

Overloaded version of __(long,int,NumberFormat) which provides default parameter(s).

Parameters
valueThe value to append.
numberFormatThe format definition. Defaults to null.
Returns
this to allow concatenated calls.

◆ __() [23/24]

AString __ ( Object  object)

Appends an object by invoking toString on it.

Parameters
objectThe object whose string representation is to be appended.
Returns
this to allow concatenated calls.

◆ __() [24/24]

AString __ ( String  src)

Append a String.

Note
For performance reasons, we overwrite __(CharSequence) here.
Parameters
srcThe CharSequence to append.
Returns
this to allow concatenated calls.

◆ _Bin() [1/4]

AString _Bin ( long  value)

Overloaded version of _Bin(long,int,NumberFormat) which provides default parameter(s).

Parameters
valueThe value to append.
Returns
this to allow concatenated calls.

◆ _Bin() [2/4]

AString _Bin ( long  value,
int  overrideWidth 
)

Overloaded version of _Bin(long,int,NumberFormat) which provides default parameter(s).

Parameters
valueThe value to append.
overrideWidthIf not 0 (the default), overrides the output width otherwise specified in field NumberFormat.binFieldWidth.
Returns
this to allow concatenated calls.

◆ _Bin() [3/4]

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.

Parameters
valueThe value to append.
overrideWidthIf not 0 (the default), overrides the output width otherwise specified in field NumberFormat.binFieldWidth.
numberFormatThe format definition. Defaults to null.
Returns
this to allow concatenated calls.

◆ _Bin() [4/4]

AString _Bin ( long  value,
NumberFormat  numberFormat 
)

Overloaded version of _Bin(long,int,NumberFormat) which provides default parameter(s).

Parameters
valueThe value to append.
numberFormatThe format definition. Defaults to null.
Returns
this to allow concatenated calls.

◆ _Hex() [1/4]

AString _Hex ( long  value)

Overloaded version of _Hex(long,int,NumberFormat) which provides default parameter(s).

Parameters
valueThe value to append.
Returns
this to allow concatenated calls.

◆ _Hex() [2/4]

AString _Hex ( long  value,
int  overrideWidth 
)

Overloaded version of _Hex(long,int,NumberFormat) which provides default parameter(s).

Parameters
valueThe value to append.
overrideWidthIf not 0 (the default), overrides the output width otherwise specified in field NumberFormat.hexFieldWidth.
Returns
this to allow concatenated calls.

◆ _Hex() [3/4]

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.

Parameters
valueThe value to append.
overrideWidthIf not 0 (the default), overrides the output width otherwise specified in field NumberFormat.hexFieldWidth.
numberFormatThe format definition. Defaults to null.
Returns
this to allow concatenated calls.

◆ _Hex() [4/4]

AString _Hex ( long  value,
NumberFormat  numberFormat 
)

Overloaded version of _Hex(long,int,NumberFormat) which provides default parameter(s).

Parameters
valueThe value to append.
numberFormatThe format definition. Defaults to null.
Returns
this to allow concatenated calls.

◆ _NC() [1/7]

AString _NC ( AString  src)

Append an AString.

Attention
Non checking variant of original method. See Non-checking methods for _NC method variants.
Parameters
srcThe source AString.
Returns
this to allow concatenated calls.

◆ _NC() [2/7]

AString _NC ( AString  src,
int  regionStart,
int  regionLength 
)

Append a region of an AString.

Attention
Non checking variant of original method. See Non-checking methods for _NC method variants.
Parameters
srcThe source AString.
regionStartThe start of the region in src to append.
regionLengthThe length of the region in src to append.
Returns
this to allow concatenated calls.

◆ _NC() [3/7]

AString _NC ( char[]  src,
int  regionStart,
int  regionLength 
)

Append a region of a char[].

Attention
Non checking variant of original method. See Non-checking methods for _NC method variants.
Parameters
srcThe character containing the region to append.
regionStartThe start of the region in src to append.
regionLengthThe maximum length of the region in src to append.
Returns
this to allow concatenated calls.

◆ _NC() [4/7]


Append a Substring.

Attention
Non checking variant of original method. See Non-checking methods for _NC method variants.
Parameters
srcThe source Substring.
Returns
this to allow concatenated calls.

◆ _NC() [5/7]

AString _NC ( Object  object)

Appends an object by invoking toString on it.

Attention
Non checking variant of original method. See Non-checking methods for _NC method variants.
Parameters
objectThe object whose string representation is to be appended.
Returns
this to allow concatenated calls.

◆ _NC() [6/7]

AString _NC ( String  src)

Append a String.

Attention
Non checking variant of original method. See Non-checking methods for _NC method variants.
Parameters
srcThe string containing the region to append.
Returns
this to allow concatenated calls.

◆ _NC() [7/7]

AString _NC ( String  src,
int  regionStart,
int  regionLength 
)

Append a region of a String.

Attention
Non checking variant of original method. See Non-checking methods for _NC method variants. *
Parameters
srcThe string containing the region to append.
regionStartThe start of the region in src to append.
regionLengthThe length of the region in src to append.
Returns
this to allow concatenated calls.

◆ _Oct() [1/4]

AString _Oct ( long  value)

Overloaded version of _Oct(long,int,NumberFormat) which provides default parameter(s).

Parameters
valueThe value to append.
Returns
this to allow concatenated calls.

◆ _Oct() [2/4]

AString _Oct ( long  value,
int  overrideWidth 
)

Overloaded version of _Oct(long,int,NumberFormat) which provides default parameter(s).

Parameters
valueThe value to append.
overrideWidthIf not 0 (the default), overrides the output width otherwise specified in field NumberFormat.octFieldWidth.
Returns
this to allow concatenated calls.

◆ _Oct() [3/4]

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.

Parameters
valueThe value to append.
overrideWidthIf not 0 (the default), overrides the output width otherwise specified in field NumberFormat.octFieldWidth.
numberFormatThe format definition. Defaults to null.
Returns
this to allow concatenated calls.

◆ _Oct() [4/4]

AString _Oct ( long  value,
NumberFormat  numberFormat 
)

Overloaded version of _Oct(long,int,NumberFormat) which provides default parameter(s).

Parameters
valueThe value to append.
numberFormatThe format definition. Defaults to null.
Returns
this to allow concatenated calls.

◆ buffer()

char [] buffer ( )

The internal buffer character array. This may, but should not be accessed directly. In case of external modifications be sure to adjust the length of this AString using setLength.

Returns
The internal buffer array.

◆ capacity()

int capacity ( )

Returns the current size of the internal buffer.

Returns
The size of the allocated buffer.

◆ charAt()

char charAt ( int  idx)

Retrieves the character at the given index. A range check is performed. If this fails, '\0' is returned.

Parameters
idxThe index of the character to read.
Returns
The character at the given index, or '\0' if index out of range.

◆ charAt_NC()

char charAt_NC ( int  idx)

Retrieves the character at the given index.

Attention
Non checking variant of original method. See Non-checking methods for _NC method variants.
Parameters
idxThe index of the character to read.
Returns
The character at the given index.

◆ charAtEnd()

char charAtEnd ( )

Retrieve the last character. In case of an empty string, '\0' is returned.

Returns
The last character in the AString. If this instance's length is zero, '\0' is returned.

◆ charAtEnd_NC()

char charAtEnd_NC ( )

Retrieve the last character.

Attention
Non checking variant of original method. See Non-checking methods for _NC method variants.
Returns
The first character in the AString. If this instance's length is zero, '\0' is returned.

◆ charAtStart()

char charAtStart ( )

Retrieve the first character. In case of an empty string, '\0' is returned.

Returns
The first character in the AString. If this instance's length is zero, '\0' is returned.

◆ charAtStart_NC()

char charAtStart_NC ( )

Retrieve the first character.

Attention
Non checking variant of original method. See Non-checking methods for _NC method variants.
Returns
The first character in the AString. If this instance's length is zero, '\0' is returned.

◆ clear()

AString clear ( )

Clear the Buffer. Same as delete (0, Length()) but without internal region checks.

Returns
this to allow concatenated calls.

◆ compareTo() [1/6]

int compareTo ( CharSequence  cmpString)

Compares a given string with this instance.

Parameters
cmpStringAn object of type String, StringBuffer or AString that is compared to this.
Returns
0 if string are equal. -1 if the instance precedes given string, 1 the instance follows the given string (same as String.CompareTo), or if given string in null.

◆ compareTo() [2/6]

int compareTo ( CharSequence  cmpString,
Case  sensitivity 
)

Compares a given string with this instance.

Parameters
cmpStringAn object of type String, StringBuffer or AString that is compared to this.
sensitivityCase sensitivity of the operation. Optional and defaults to Case.Sensitive.
Returns
0 if string are equal. -1 if the instance precedes given string, 1 the instance follows the given string (same as String.CompareTo), or if given string in null.

◆ compareTo() [3/6]

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.

Parameters
cmpStringAn object of type String, StringBuffer or AString that is compared to this.
sensitivityCase sensitivity of the operation. Optional and defaults to Case.Sensitive.
cmpRegionStartThe start of the substring within the given string that is to be compared to this. Defaults to 0.
Returns
0 if the contents of the string regions are equal (or if both regions are empty or out of range).
-1 if the instance is less than the given string.
+1 if the instance is greater than the given string or if given string is null.

◆ compareTo() [4/6]

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.

Parameters
cmpStringAn object of type String, StringBuffer or AString that is compared to this.
sensitivityCase sensitivity of the operation. Optional and defaults to Case.Sensitive.
cmpRegionStartThe start of the substring within the given string that is to be compared to this. Defaults to 0.
cmpRegionLengthThe length of the substring within the given string that is to be compared to this. Defaults to Integer.MAX_VALUE.
Returns
0 if the contents of this string and the region of the given string are equal (or if this object and the given region are empty).
-1 if the instance is less than the given string.
+1 if the instance is greater than the given string or if given string is null.

◆ compareTo() [5/6]

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.

Parameters
cmpStringAn object of type String, StringBuffer or AString that is compared to this.
sensitivityCase sensitivity of the operation. Optional and defaults to Case.Sensitive.
cmpRegionStartThe start of the substring within the given string that is to be compared to this. Defaults to 0.
cmpRegionLengthThe length of the substring within the given string that is to be compared to this. Defaults to Integer.MAX_VALUE.
regionStartThe start of the substring within this string that is to be compared. Defaults to 0.
Returns
0 if the contents of the string regions are equal (or if both regions are empty or out of range).
-1 if the instance is less than the given string.
+1 if the instance is greater than the given string or if given string is null.

◆ compareTo() [6/6]

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.

Parameters
cmpStringAn object of type String, StringBuffer or AString that is compared to this.
sensitivityCase sensitivity of the operation. Optional and defaults to Case.Sensitive.
cmpRegionStartThe start of the substring within the given string that is to be compared to this. Defaults to 0.
cmpRegionLengthThe length of the substring within the given string that is to be compared to this. Defaults to Integer.MAX_VALUE.
regionStartThe start of the substring within this string that is to be compared. Defaults to 0.
regionLengthThe length of the substring within this string that is to be compared. Defaults to Integer.MAX_VALUE.
Returns
0 if the contents of the string regions are equal (or if both regions are empty or out of range).
-1 if the instance is less than the given string.
+1 if the instance is greater than the given string or if given string is null.

◆ containsAt() [1/6]

boolean containsAt ( AString  needle,
int  pos 
)

Checks if a String is located at the given position.

Parameters
needleThe CharSequence to search.
posThe position within this object to look at.
Returns
True if given sequence is found at the given position. False otherwise .

◆ containsAt() [2/6]

boolean containsAt ( AString  needle,
int  pos,
Case  sensitivity 
)

Checks if an AString is located at the given position.

Parameters
needleThe AString to search.
posThe position within this object to look at.
sensitivityCase sensitivity of the operation. Optional and defaults to Case.Sensitive.
Returns
True if the sequence is found at the given position. False otherwise .

◆ containsAt() [3/6]

boolean containsAt ( CharSequence  needle,
int  pos 
)

Checks if a CharSequence is located at the given position.

Parameters
needleThe CharSequence to search.
posThe position within this object to look at.
Returns
True if the sequence is found at the given position. False otherwise .

◆ containsAt() [4/6]

boolean containsAt ( CharSequence  needle,
int  pos,
Case  sensitivity 
)

Checks if a CharSequence is located at the given position.

Parameters
needleThe CharSequence to search.
posThe position within this object to look at.
sensitivityCase sensitivity of the operation. Optional and defaults to Case.Sensitive.
Returns
True if the sequence is found at the given position. False otherwise .

◆ containsAt() [5/6]

boolean containsAt ( com.aworx.lib.strings.Substring  needle,
int  pos 
)

Checks if a Substring is located at the given position.

Parameters
needleThe CharSequence to search.
posThe position within this object to look at.
Returns
True if the sequence is found at the given position. False otherwise .

◆ containsAt() [6/6]

boolean containsAt ( com.aworx.lib.strings.Substring  needle,
int  pos,
Case  sensitivity 
)

Checks if a Substring is located at the given position.

Parameters
needleThe Substring to search.
posThe position within this object to look at.
sensitivityCase sensitivity of the operation. Optional and defaults to Case.Sensitive.
Returns
True if the sequence is found at the given position. False otherwise .

◆ delete() [1/2]

AString delete ( int  regionStart)

Overloaded version of delete(int,int) that provides the default value Integer.MAX_VALUE as parameter regionLength.

Parameters
regionStartThe start of the region to delete.
Returns
this to allow concatenated calls.

◆ delete() [2/2]

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.

Note
See also methods clear, deleteStart, deleteStart_NC, deleteEnd and deleteEnd_NC.
Parameters
regionStartThe start of the region to delete.
regionLengthThe length of the region to delete. Defaults to Integer.MAX_VALUE.
Returns
this to allow concatenated calls.

◆ delete_NC()

AString delete_NC ( int  regionStart,
int  regionLength 
)

Cuts out a region from the Buffer.

Note
See also methods clear, deleteStart, deleteStart_NC, deleteEnd and deleteEnd_NC.
Attention
Non checking variant of original method. See Non-checking methods for _NC method variants. Like with method delete(int, int), it is allowed that the sum of parameters regionStart and regionLength is longer than the length of this AString. In this case, this string is cut starting from index regionStart.
Parameters
regionStartThe start of the region to delete.
regionLengthThe length of the region to delete.
Returns
this to allow concatenated calls.

◆ deleteEnd()

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.

Parameters
regionLengthThe length of the region at the end to delete.
Returns
this to allow concatenated calls.

◆ deleteEnd_NC()

AString deleteEnd_NC ( int  regionLength)

Deletes the given number of characters from the end of the string.

Attention
Non checking variant of original method. See Non-checking methods for _NC method variants.
Parameters
regionLengthThe length of the region at the end to delete.
Returns
this to allow concatenated calls.

◆ deleteStart()

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.

Parameters
regionLengthThe length of the region at the start to delete.
Returns
this to allow concatenated calls.

◆ deleteStart_NC()

AString deleteStart_NC ( int  regionLength)

Deletes the given number of characters from the start of the string. Does not check and correct the parameters.

Attention
Non checking variant of original method. See Non-checking methods for _NC method variants.
Parameters
regionLengthThe length of the region at the start to delete.
Returns
this to allow concatenated calls.

◆ endsWith() [1/6]

boolean endsWith ( AString  needle)

Checks if this AString ends with the given sequence.

Parameters
needleThe AString to search. If s is null or empty, false is returned.
Returns
true if this starts with the given sequence, false if not.

◆ endsWith() [2/6]

boolean endsWith ( AString  needle,
Case  sensitivity 
)

Checks if this AString ends with the given sequence.

Parameters
needleThe AString to search. If s is null or empty, false is returned.
sensitivityCase sensitivity of the operation. Optional and defaults to Case.Sensitive.
Returns
true if this starts with the given sequence, false if not.

◆ endsWith() [3/6]

boolean endsWith ( CharSequence  needle)

Checks if this AString ends with the given sequence.

Parameters
needleThe CharSequence to search. If s is null or empty, false is returned.
Returns
true if this starts with the given sequence, false if not.

◆ endsWith() [4/6]

boolean endsWith ( CharSequence  needle,
Case  sensitivity 
)

Checks if this AString ends with the given sequence.

Parameters
needleThe CharSequence to search. If s is null or empty, false is returned.
sensitivityCase sensitivity of the operation. Optional and defaults to Case.Sensitive.
Returns
true if this starts with the given sequence, false if not.

◆ endsWith() [5/6]

boolean endsWith ( com.aworx.lib.strings.Substring  needle)

Checks if this AString ends with the given sequence.

Parameters
needleThe Substring to search. If s is null or empty, false is returned.
Returns
true if this starts with the given sequence, false if not.

◆ endsWith() [6/6]

boolean endsWith ( com.aworx.lib.strings.Substring  needle,
Case  sensitivity 
)

Checks if this AString ends with the given sequence.

Parameters
needleThe Substring to search. If s is null or empty, false is returned.
sensitivityCase sensitivity of the operation. Optional and defaults to Case.Sensitive.
Returns
true if this starts with the given sequence, false if not.

◆ ensureRemainingCapacity()

void ensureRemainingCapacity ( int  spaceNeeded)

Ensures that the capacity of the internal buffer meets or exceeds the actual length plus the given growth value.

Parameters
spaceNeededThe desired growth of the length of the string represented by this.

◆ equals() [1/10]

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.

Parameters
cmpStringThe AString that is compared to this AString.
Returns
true, if contents of this and the given AString are equal

◆ equals() [2/10]

boolean equals ( AString  cmpString,
Case  sensitivity 
)

Tests and returns true, if the given AString equals to what this object represents. True is returned if both are zero length or null.

Parameters
cmpStringThe AString that is compared to this AString.
sensitivityCase sensitivity of the comparison. Optional and defaults to Case.Sensitive.
Returns
true, if contents of this and the given AString are equal

◆ equals() [3/10]

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.

Parameters
cmpStringA CharSequence that is compared to this AString.
Returns
true, if contents of this and the given AString are equal

◆ equals() [4/10]

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.

Parameters
cmpStringA CharSequence that is compared to this AString.
sensitivityCase sensitivity of the comparison. Optional and defaults to Case.Sensitive.
Returns
true, if contents of this and the given AString are equal

◆ equals() [5/10]

boolean equals ( com.aworx.lib.strings.Substring  cmpString)

Tests and returns true, if the given Substring equals to what this object represents. True is returned if both are zero length or null.

Parameters
cmpStringA Substring that is compared to this AString.
Returns
true, if contents of this and the given AString are equal

◆ equals() [6/10]

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.

Parameters
cmpStringA Substring that is compared to this AString.
sensitivityCase sensitivity of the comparison. Optional and defaults to Case.Sensitive.
Returns
true, if contents of this and the given AString are equal

◆ equals() [7/10]

boolean equals ( Object  object)

Compares this to the given object. .

Parameters
objectThe object to compare to this instance.
Returns
True if given object equals this.

◆ equals() [8/10]

boolean equals ( Object  object,
Case  sensitivity 
)

Compares this to the given object. Given object can be of type

Parameters
objectThe object to compare to this instance.
sensitivityCase sensitivity of the comparison. Optional and defaults to Case.Sensitive.
Returns
True if given object equals this.

◆ equals() [9/10]

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.

Parameters
cmpStringThe AString that is compared to this AString.
Returns
true, if contents of this and the given AString are equal

◆ equals() [10/10]

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.

Parameters
cmpStringThe AString that is compared to this AString.
sensitivityCase sensitivity of the comparison. Optional and defaults to Case.Sensitive.
Returns
true, if contents of this and the given AString are equal

◆ escape() [1/4]

AString escape ( )

Overloaded version providing default parameter(s).

Returns
this to allow concatenated calls.

◆ escape() [2/4]

AString escape ( Switch  escape)

Overloaded version providing default parameter(s).

Parameters
escapeSwitch.On escapes ascii characters (the default), Switch.Off converts escaped strings to ascii codes.
Returns
this to allow concatenated calls.

◆ escape() [3/4]

AString escape ( Switch  escape,
int  regionStart 
)

Overloaded version providing default parameter(s).

Parameters
escapeSwitch.On escapes ascii characters (the default), Switch.Off converts escaped strings to ascii codes.
regionStartThe start of the region to convert.
Returns
this to allow concatenated calls.

◆ escape() [4/4]

AString escape ( Switch  escape,
int  regionStart,
int  regionLength 
)

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.

Parameters
escapeSwitch.On escapes ascii characters (the default), Switch.Off converts escaped strings to ascii codes.
regionStartThe start of the region to convert.
regionLengthThe length of the region to convert.
Returns
this to allow concatenated calls.

◆ field() [1/5]

AString field ( )

Marks the start of a field. See variants of this method for more information.

Returns
this to allow concatenated calls.

◆ field() [2/5]

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.

Parameters
sizeThe field size in relation to the starting index of the field, defined by using Field() prior to this invocation.
Returns
this to allow concatenated calls.

◆ field() [3/5]

AString field ( int  size,
Alignment  alignment 
)

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.

Parameters
sizeThe field size in relation to the starting index of the field, defined by using Field() prior to this invocation.
alignmentThe alignment of the contents within the field. Defaults to ALIB.Align.RIGHT. Other options are ALIB.Align.LEFT and ALIB.Align.CENTER.
Returns
this to allow concatenated calls.

◆ field() [4/5]

AString field ( int  size,
Alignment  alignment,
char  padChar 
)

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.

Parameters
sizeThe 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.
alignmentThe alignment of the contents within the field. Defaults to ALIB.Align.RIGHT. Other options are ALIB.Align.LEFT and ALIB.Align.CENTER.
padCharThe character used to fill the field up to its size. Defaults to ' ' (space).
Returns
this to allow concatenated calls.

◆ field() [5/5]

AString field ( int  size,
Alignment  alignment,
char  padChar,
int  fieldStart 
)

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.

Note
To implement nested fields, the outer fields have to be set by providing the start marker by using the parameter fieldStart. Hence, only the starting points of the most inner fields can be set using this method without parameters.
Parameters
sizeThe 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.
alignmentThe alignment of the contents within the field. Defaults to ALIB.Align.RIGHT. Other options are ALIB.Align.LEFT and ALIB.Align.CENTER.
padCharThe character used to fill the field up to its size. Defaults to ' ' (space).
fieldStartThis 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.
Returns
this to allow concatenated calls.

◆ hashCode()

int hashCode ( )

Calculates the hash value using the same formula as java.lang.String.

Returns
A hash value for this object.

◆ indexOf() [1/5]

int indexOf ( char  c)

Search a character in the buffer.

Parameters
cThe character to search.
Returns
-1 if the character is not found. Otherwise the index of first occurrence.

◆ indexOf() [2/5]

int indexOf ( char  c,
int  startIdx 
)

Search a character in the buffer.

Parameters
cThe character to search.
startIdxThe index to start the search at. Optional and defaults to 0.
Returns
-1 if the character is not found. Otherwise the index of first occurrence.

◆ indexOf() [3/5]

int indexOf ( CharSequence  cs)

Search a CharSequence in the buffer.

Parameters
csThe CharSequence to search.
Returns
-1 if the String is not found. Otherwise the index of first occurrence.

◆ indexOf() [4/5]

int indexOf ( CharSequence  cs,
int  startIdx 
)

Search a CharSequence in the buffer.

Parameters
csThe CharSequence to search.
startIdxThe index to start the search at. Optional and defaults to 0.
Returns
-1 if the String is not found. Otherwise the index of first occurrence.

◆ indexOf() [5/5]

int indexOf ( CharSequence  needle,
int  startIdx,
Case  sensitivity 
)

Search the given String in the buffer starting at a given position.

Parameters
needleThe CharSequence to search.
startIdxThe index to start the search at. Optional and defaults to 0.
sensitivityCase sensitivity of the operation. Optional and defaults to Case.Sensitive.
Returns
-1 if the String is not found. Otherwise the index of first occurrence.

◆ indexOfAny() [1/2]

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.

Parameters
needlesCharacters to be searched for.
inclusionDenotes 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.
Returns
The index of the first character found which is included, respectively not included, in the given set of characters. If nothing is found, -1 is returned.

◆ indexOfAny() [2/2]

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.

Parameters
needlesCharacters to be searched for.
inclusionDenotes 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.
startIdxThe 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.
Returns
The index of the first character found which is included, respectively not included, in the given set of characters. If nothing is found, -1 is returned.

◆ indexOfOrLength() [1/2]

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.

Parameters
needleThe character to search for.
Returns
This strings length if the character needle is not found. Otherwise the index of first occurrence.

◆ indexOfOrLength() [2/2]

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.

Parameters
needleThe character to search for.
startIdxThe index in this to start searching the character.
Returns
This strings length if the character needle is not found. Otherwise the index of first occurrence.

◆ insertAt()

AString insertAt ( CharSequence  src,
int  pos 
)

Inserts a string at a given position. If the given position is out of range, nothing is inserted.

Note
To insert a string with replacing a different one at the same time, use one of the overloaded methods replaceSubstring.
Parameters
srcThe CharSequence to insert characters from.
posThe position in this object insert the portion of src.
Returns
this to allow concatenated calls.

◆ insertChars() [1/2]

AString insertChars ( char  c,
int  qty 
)

Inserts the given character n-times at the end of this string (appends).

Parameters
cThe character to append.
qtyThe quantity of characters to append.
Returns
this to allow concatenated calls.

◆ insertChars() [2/2]

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.

Parameters
cThe character to insert qty times.
qtyThe quantity of characters to insert.
posThe index in this object where c is inserted qty times.
Returns
this to allow concatenated calls.

◆ isEmpty()

boolean isEmpty ( )

Returns true if the actual length equals zero.

Returns
true if the actual length equals zero.

◆ isNotEmpty()

boolean isNotEmpty ( )

Returns true if the actual length does not equal zero.

Returns
true if the actual length does not equal zero.

◆ isNotNull()

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.

Returns
true if no buffer is allocated.

◆ isNull()

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.

Returns
true if no buffer is allocated.

◆ lastIndexOf() [1/2]

int lastIndexOf ( char  needle)

Searches a character backwards from the end or a given start index.

Parameters
needleThe character to search for.
Returns
-1 if the character needle is not found. Otherwise the index of its last occurrence relative to the start index.

◆ lastIndexOf() [2/2]

int lastIndexOf ( char  needle,
int  startIndex 
)

Searches a character backwards from the given start index.

Parameters
needleThe character to search for.
startIndexThe index in this to start searching the character. Defaults to the end of this string.
Returns
-1 if the character needle is not found. Otherwise the index of its last occurrence relative to the start index.

◆ lastIndexOfAny() [1/2]

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".

Parameters
needlesCharacters to be searched for.
inclusionDenotes 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.
Returns
The index of the first character found which is included, respectively not included, in the given set of characters. If nothing is found, -1 is returned.

◆ lastIndexOfAny() [2/2]

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".

Parameters
needlesCharacters to be searched for.
inclusionDenotes 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.
startIdxThe 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.
Returns
The index of the first character found which is included, respectively not included, in the given set of characters. If nothing is found, -1 is returned.

◆ length()

int length ( )

Gets the length of the sequence.

Returns
The length of the sequence.

◆ newLine()

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.

Returns
this to allow concatenated calls.

◆ parseBin() [1/8]

long parseBin ( )

Overloaded version of parseBin providing default values for omitted parameters.

Returns
The parsed value.

◆ parseBin() [2/8]

long parseBin ( int  startIdx)

Overloaded version of parseBin providing default values for omitted parameters.

Parameters
startIdxThe start index from where the integer value is tried to be parsed. Optional and defaults to 0.
Returns
The parsed value.

◆ parseBin() [3/8]

long parseBin ( int  startIdx,
int[]  newIdx 
)

Overloaded version of parseBin providing default values for omitted parameters.

Parameters
startIdxThe start index from where the integer value is tried to be parsed. Optional and defaults to 0.
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseBin() [4/8]

long parseBin ( int  startIdx,
NumberFormat  numberFormat 
)

Overloaded version of parseBin providing default values for omitted parameters.

Parameters
startIdxThe start index for parsing. Optional and defaults to 0.
numberFormatThe format definition. Defaults to null.
Returns
The parsed value.

◆ parseBin() [5/8]

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.

Note
Although Java does not support unsigned integer, the value that is read with this method is correct in respect to the bits set in the signed value returned. In other words, if the most significant bit (#64), is set, the return value is negative.
Parameters
startIdxThe start index for parsing. Optional and defaults to 0.
numberFormatThe format definition. Defaults to null.
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseBin() [6/8]

long parseBin ( int[]  newIdx)

Overloaded version of parseBin providing default values for omitted parameters.

Parameters
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseBin() [7/8]

long parseBin ( NumberFormat  numberFormat)

Overloaded version of parseBin providing default values for omitted parameters.

Parameters
numberFormatThe format definition. Defaults to null.
Returns
The parsed value.

◆ parseBin() [8/8]

long parseBin ( NumberFormat  numberFormat,
int[]  newIdx 
)

Overloaded version of parseBin providing default values for omitted parameters.

Parameters
numberFormatThe format definition.
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseDec() [1/8]

long parseDec ( )

Overloaded version of parseDec providing default values for omitted parameters.

Returns
The parsed value.

◆ parseDec() [2/8]

long parseDec ( int  startIdx)

Overloaded version of parseDec providing default values for omitted parameters.

Parameters
startIdxThe start index from where the integer value is tried to be parsed. Optional and defaults to 0.
Returns
The parsed value.

◆ parseDec() [3/8]

long parseDec ( int  startIdx,
int[]  newIdx 
)

Overloaded version of parseDec providing default values for omitted parameters.

Parameters
startIdxThe start index from where the integer value is tried to be parsed. Optional and defaults to 0.
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseDec() [4/8]

long parseDec ( int  startIdx,
NumberFormat  numberFormat 
)

Overloaded version of parseDec providing default values for omitted parameters.

Parameters
startIdxThe start index for parsing. Optional and defaults to 0.
numberFormatThe format definition. Defaults to null.
Returns
The parsed value.

◆ parseDec() [5/8]

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.

Note
Because Java does not support unsigned integer, the value to read is limited to Long.MAX_VALUE in this language implementation of ALib.
Parameters
startIdxThe start index for parsing. Optional and defaults to 0.
numberFormatThe format definition. Defaults to null.
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseDec() [6/8]

long parseDec ( int[]  newIdx)

Overloaded version of parseDec providing default values for omitted parameters.

Parameters
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseDec() [7/8]

long parseDec ( NumberFormat  numberFormat)

Overloaded version of parseDec providing default values for omitted parameters.

Parameters
numberFormatThe format definition. Defaults to null.
Returns
The parsed value.

◆ parseDec() [8/8]

long parseDec ( NumberFormat  numberFormat,
int[]  newIdx 
)

Overloaded version of parseDec providing default values for omitted parameters.

Parameters
numberFormatThe format definition. Defaults to null.
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseDecDigits()

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.

Parameters
startIdxThe start index for parsing. Optional and defaults to 0.
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseFloat() [1/8]

double parseFloat ( )

Overloaded version of parseFloat providing default values for omitted parameters.

Returns
The parsed value.

◆ parseFloat() [2/8]

double parseFloat ( int  startIdx)

Overloaded version of parseFloat providing default values for omitted parameters.

Parameters
startIdxThe start index from where the integer value is tried to be parsed. Optional and defaults to 0.
Returns
The parsed value.

◆ parseFloat() [3/8]

double parseFloat ( int  startIdx,
int[]  newIdx 
)

Overloaded version of parseFloat providing default values for omitted parameters.

Parameters
startIdxThe start index from where the integer value is tried to be parsed. Optional and defaults to 0.
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseFloat() [4/8]

double parseFloat ( int  startIdx,
NumberFormat  numberFormat 
)

Overloaded version of parseFloat providing default values for omitted parameters.

Parameters
startIdxThe start index for parsing. Optional and defaults to 0.
numberFormatThe format definition. Defaults to null.
Returns
The parsed value.

◆ parseFloat() [5/8]

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.

Parameters
startIdxThe start index for parsing. Optional and defaults to 0.
numberFormatThe format definition. Defaults to null.
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind any found float number.

◆ parseFloat() [6/8]

double parseFloat ( int[]  newIdx)

Overloaded version of parseFloat providing default values for omitted parameters.

Parameters
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseFloat() [7/8]

double parseFloat ( NumberFormat  numberFormat)

Overloaded version of parseFloat providing default values for omitted parameters.

Parameters
numberFormatThe format definition. Defaults to null.
Returns
The parsed value.

◆ parseFloat() [8/8]

double parseFloat ( NumberFormat  numberFormat,
int[]  newIdx 
)

Overloaded version of parseFloat providing default values for omitted parameters.

Parameters
numberFormatThe format definition. Defaults to null.
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseHex() [1/8]

long parseHex ( )

Overloaded version of parseHex providing default values for omitted parameters.

Returns
The parsed value.

◆ parseHex() [2/8]

long parseHex ( int  startIdx)

Overloaded version of parseHex providing default values for omitted parameters.

Parameters
startIdxThe start index from where the integer value is tried to be parsed. Optional and defaults to 0.
Returns
The parsed value.

◆ parseHex() [3/8]

long parseHex ( int  startIdx,
int[]  newIdx 
)

Overloaded version of parseHex providing default values for omitted parameters.

Parameters
startIdxThe start index from where the integer value is tried to be parsed. Optional and defaults to 0.
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseHex() [4/8]

long parseHex ( int  startIdx,
NumberFormat  numberFormat 
)

Overloaded version of parseHex providing default values for omitted parameters.

Parameters
startIdxThe start index for parsing. Optional and defaults to 0.
numberFormatThe format definition. Defaults to null.
Returns
The parsed value.

◆ parseHex() [5/8]

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.

Note
Although Java does not support unsigned integer, the value that is read with this method is correct in respect to the bits set in the signed value returned. In other words, if the most significant bit (#64), is set, the return value is negative. For this, 16 hexadecimal digits need to be read and the first of them needs to be greater or equal to 0x8.
Parameters
startIdxThe start index for parsing. Optional and defaults to 0.
numberFormatThe format definition. Defaults to null.
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseHex() [6/8]

long parseHex ( int[]  newIdx)

Overloaded version of parseHex providing default values for omitted parameters.

Parameters
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseHex() [7/8]

long parseHex ( NumberFormat  numberFormat)

Overloaded version of parseHex providing default values for omitted parameters.

Parameters
numberFormatThe format definition. Defaults to null.
Returns
The parsed value.

◆ parseHex() [8/8]

long parseHex ( NumberFormat  numberFormat,
int[]  newIdx 
)

Overloaded version of parseHex providing default values for omitted parameters.

Parameters
numberFormatThe format definition. Defaults to null.
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseInt() [1/8]

long parseInt ( )

Overloaded version of parseInt providing default values for omitted parameters.

Returns
The parsed value.

◆ parseInt() [2/8]

long parseInt ( int  startIdx)

Overloaded version of parseInt providing default values for omitted parameters.

Parameters
startIdxThe start index from where the integer value is tried to be parsed. Optional and defaults to 0.
Returns
The parsed value.

◆ parseInt() [3/8]

long parseInt ( int  startIdx,
int[]  newIdx 
)

Overloaded version of parseInt providing default values for omitted parameters.

Parameters
startIdxThe start index from where the integer value is tried to be parsed. Optional and defaults to 0.
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseInt() [4/8]

long parseInt ( int  startIdx,
NumberFormat  numberFormat 
)

Overloaded version of parseInt providing default values for omitted parameters.

Parameters
startIdxThe start index for parsing. Optional and defaults to 0.
numberFormatThe format definition. Defaults to null.
Returns
The parsed value.

◆ parseInt() [5/8]

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.

Parameters
startIdxThe start index for parsing. Optional and defaults to 0.
numberFormatThe format definition. Defaults to null.
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseInt() [6/8]

long parseInt ( int[]  newIdx)

Overloaded version of parseInt providing default values for omitted parameters.

Parameters
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseInt() [7/8]

long parseInt ( NumberFormat  numberFormat)

Overloaded version of parseInt providing default values for omitted parameters.

Parameters
numberFormatThe format definition. Defaults to null.
Returns
The parsed value.

◆ parseInt() [8/8]

long parseInt ( NumberFormat  numberFormat,
int[]  newIdx 
)

Overloaded version of parseInt providing default values for omitted parameters.

Parameters
numberFormatThe format definition. Defaults to null.
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseOct() [1/8]

long parseOct ( )

Overloaded version of parseOct providing default values for omitted parameters.

Returns
The parsed value.

◆ parseOct() [2/8]

long parseOct ( int  startIdx)

Overloaded version of parseOct providing default values for omitted parameters.

Parameters
startIdxThe start index from where the integer value is tried to be parsed. Optional and defaults to 0.
Returns
The parsed value.

◆ parseOct() [3/8]

long parseOct ( int  startIdx,
int[]  newIdx 
)

Overloaded version of parseOct providing default values for omitted parameters.

Parameters
startIdxThe start index from where the integer value is tried to be parsed. Optional and defaults to 0.
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseOct() [4/8]

long parseOct ( int  startIdx,
NumberFormat  numberFormat 
)

Overloaded version of parseOct providing default values for omitted parameters.

Parameters
startIdxThe start index for parsing. Optional and defaults to 0.
numberFormatThe format definition. Defaults to null.
Returns
The parsed value.

◆ parseOct() [5/8]

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.

Note
Although Java does not support unsigned integer, the value that is read with this method is correct in respect to the bits set in the signed value returned. In other words, if the most significant bit (#64), is set, the return value is negative. For this, 22 octal digits need to be read with the first being 1.
Parameters
startIdxThe start index for parsing. Optional and defaults to 0.
numberFormatThe format definition. Defaults to null.
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseOct() [6/8]

long parseOct ( int[]  newIdx)

Overloaded version of parseOct providing default values for omitted parameters.

Parameters
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ parseOct() [7/8]

long parseOct ( NumberFormat  numberFormat)

Overloaded version of parseOct providing default values for omitted parameters.

Parameters
numberFormatThe format definition. Defaults to null.
Returns
The parsed value.

◆ parseOct() [8/8]

long parseOct ( NumberFormat  numberFormat,
int[]  newIdx 
)

Overloaded version of parseOct providing default values for omitted parameters.

Parameters
numberFormatThe format definition. Defaults to null.
[out]newIdxOptional 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.
Returns
The parsed value. In addition, the output parameter newIdx is set to point to the first character behind the parsed number.

◆ replaceRegion()

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.

Note
To replace a region with a single character (by shrinking the region to this character) use replaceSubstring( " + c, regionStart, regionLength)".
Parameters
cThe character to set in the region.
regionStartThe start of the region
regionLengthThe length of the region
Returns
this to allow concatenated calls.

◆ replaceSubstring()

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.

Parameters
srcThe replacement CharSequence.
regionStartThe start of the region.
regionLengthThe length of the region.
Returns
this to allow concatenated calls.

◆ resizeRegion()

boolean resizeRegion ( int  regionStart,
int  regionLength,
int  newLength 
)
protected

Protected method that resizes a region into the Buffer. The region contents is undefined.

Parameters
regionStartThe 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.
regionLengthThe current length of the region.
newLengthThe desired length of the region.
Returns
true, if the parameters were OK and the region was resized, false otherwise.

◆ searchAndReplace() [1/6]

int searchAndReplace ( char  needle,
char  replacement 
)

Replaces one or more occurrences of one character by another character.

Parameters
needleThe terminatable string to be replaced.
replacementThe replacement string (does not need to be zero terminatable).
Returns
The number of replacements that where performed.

◆ searchAndReplace() [2/6]

int searchAndReplace ( char  needle,
char  replacement,
int  startIdx 
)

Replaces one or more occurrences of one character by another character.

Parameters
needleThe terminatable string to be replaced.
replacementThe replacement string (does not need to be zero terminatable).
startIdxThe index where the search starts. Optional and defaults 0.
Returns
The number of replacements that where performed.

◆ searchAndReplace() [3/6]

int searchAndReplace ( CharSequence  searchStr,
CharSequence  newStr 
)

Replace one or more occurrences of a string by another string. Returns the number of replacements.

Parameters
searchStrThe CharSequence to be replaced.
newStrThe replacement string.
Returns
The number of replacements that where performed.

◆ searchAndReplace() [4/6]

int searchAndReplace ( CharSequence  searchStr,
CharSequence  newStr,
int  startIdx 
)

Replace one or more occurrences of a string by another string. Returns the number of replacements.

Parameters
searchStrThe CharSequence to be replaced.
newStrThe replacement string.
startIdxThe index where the search starts. Optional and defaults to 0.
Returns
The number of replacements that where performed.

◆ searchAndReplace() [5/6]

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.

Parameters
searchStrThe CharSequence to be replaced.
newStrThe replacement string.
startIdxThe index where the search starts. Optional and defaults to 0.
maxReplacementsThe maximum number of replacements to perform. Optional and defaults to Integer.MAX_VALUE .
Returns
The number of replacements that where performed.

◆ searchAndReplace() [6/6]

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.

Parameters
searchStrThe CharSequence to be replaced.
newStrThe replacement string.
startIdxThe index where the search starts. Optional and defaults to 0.
maxReplacementsThe maximum number of replacements to perform. Optional and defaults to Integer.MAX_VALUE .
sensitivityCase sensitivity of the operation. Optional and defaults to Case.Sensitive.
Returns
The number of replacements that where performed.

◆ searchAndReplaceAll()

AString searchAndReplaceAll ( CharSequence  searchStr,
CharSequence  newStr 
)

Replace one or more occurrences of a string by another string.

Note
The difference to searchAndReplace is that this method returns this to allow concatenated calls.
Parameters
searchStrThe CharSequence to be replaced.
newStrThe replacement string.
Returns
this to allow concatenated calls.

◆ setBuffer()

void setBuffer ( int  newCapacity)

Resizes the internal buffer to meet exactly the given size.

The following rules apply:

  • The string represented by this instance is copied to the new buffer. If this is larger than the new buffer size, the string is cut at the end to fit.
  • If the desired new size is 0, then the currently allocated buffer will be released. In this case method buffer will still return an empty constant character array (using an internal singleton) but method isNull will return true.
Note
Any methods of this class that extend the length of the string represented, will invoke this method if the current buffer size is not sufficient. If a future string length of an AString is predictable, then it is advisable to allocate such size upfront to avoid recurring allocations.
Parameters
newCapacityThe new capacity of the internal buffer.

◆ setCharAt()

void setCharAt ( int  idx,
char  c 
)

Sets the character at the given index. A range check is performed. If this fails, nothing is done.

Note
Access to the characters without index check is provided with method charAt_NC.
Parameters
idxThe index of the character to write.
cThe character to write.

◆ setCharAt_NC()

void setCharAt_NC ( int  idx,
char  c 
)

Sets the character at the given index.

Attention
Non checking variant of original method. See Non-checking methods for _NC method variants.
Parameters
idxThe index of the character to write.
cThe character to write.

◆ setLength()

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.

Parameters
newLengthThe new length of the AString. Must be smaller than the current length.
Returns
The new length of the string represented by this.

◆ setLength_NC()

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.

Attention
Non checking variant of original method. See Non-checking methods for _NC method variants.
Parameters
newLengthThe new length of the AString. Must be between 0 and the current length.

◆ setNull()

void setNull ( )

Invokes setBuffer(0) or setNull.

◆ startsWith() [1/6]

boolean startsWith ( AString  needle)

Checks if this AString starts with the given sequence.

Parameters
needleThe AString to search. If s is null or empty, false is returned.
Returns
true if this starts with the given sequence, false if not.

◆ startsWith() [2/6]

boolean startsWith ( AString  needle,
Case  sensitivity 
)

Checks if this AString starts with the given sequence.

Parameters
needleThe AString to search. If s is null or empty, false is returned.
sensitivityCase sensitivity of the operation. Optional and defaults to Case.Sensitive.
Returns
true if this starts with the given sequence, false if not.

◆ startsWith() [3/6]

boolean startsWith ( CharSequence  needle)

Checks if this AString starts with the given sequence.

Parameters
needleThe CharSequence to search. If s is null or empty, false is returned.
Returns
true if this starts with the given sequence, false if not.

◆ startsWith() [4/6]

boolean startsWith ( CharSequence  needle,
Case  sensitivity 
)

Checks if this AString starts with the given sequence.

Parameters
needleThe CharSequence to search. If s is null or empty, false is returned.
sensitivityCase sensitivity of the operation. Optional and defaults to Case.Sensitive.
Returns
true if this starts with the given sequence, false if not.

◆ startsWith() [5/6]

boolean startsWith ( com.aworx.lib.strings.Substring  needle)

Checks if this AString starts with the given sequence.

Parameters
needleThe Substring to search. If s is null or empty, false is returned.
Returns
true if this starts with the given sequence, false if not.

◆ startsWith() [6/6]

boolean startsWith ( com.aworx.lib.strings.Substring  needle,
Case  sensitivity 
)

Checks if this AString starts with the given sequence.

Parameters
needleThe Substring to search. If s is null or empty, false is returned.
sensitivityCase sensitivity of the operation. Optional and defaults to Case.Sensitive.
Returns
true if this starts with the given sequence, false if not.

◆ subSequence()

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.

Parameters
beginIndexThe start of the sequence (not used)
endIndexThe length of the sequence (not used)
Returns
null (!).

◆ tab() [1/3]

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.

Parameters
tabSizeThe tab positions are multiples of this parameter.
Returns
this to allow concatenated calls.

◆ tab() [2/3]

AString tab ( int  tabSize,
int  minPad 
)

Overloaded method of tab(int, int, char), providing ' ' (space) as default value for parameter tabChar.

Parameters
tabSizeThe tab positions are multiples of this parameter.
minPadThe minimum pad characters to add. Defaults to 1.
Returns
this to allow concatenated calls.

◆ tab() [3/3]

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).

Note
While any append operation is allowed, manipulations like delete or insertAt will not correct the internal tab reference position to match the index of the then current start of the last line in this string.
Parameters
tabSizeThe 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).
Returns
this to allow concatenated calls.

◆ toLower() [1/3]

AString toLower ( )

Converts all characters in the buffer to lower case.

Returns
this to allow concatenated calls.

◆ toLower() [2/3]

AString toLower ( int  regionStart)

Converts characters in the buffer to lower case.

Parameters
regionStartStart of the region to be converted. Defaults to 0
Returns
this to allow concatenated calls.

◆ toLower() [3/3]

AString toLower ( int  regionStart,
int  regionLength 
)

Converts all or a region of characters in the buffer to lower case.

Parameters
regionStartStart of the region to be converted. Defaults to 0
regionLengthLength of the region to be converted. Defaults to int.MaxValue.
Returns
this to allow concatenated calls.

◆ toString() [1/4]

String toString ( )

Creates a String containing a copy of the contents of this AString.

Returns
A string that represents this object.

◆ toString() [2/4]

String toString ( int  regionStart)

Creates a String containing a copy of the ending of the AString.

Parameters
regionStartThe start point from where on the remainder of this AString is copied.
Returns
A string that represents the specified sub region of this object

◆ toString() [3/4]

String toString ( int  regionStart,
int  regionLength 
)

Creates a String containing a copy of a region of the contents of this AString.

Parameters
regionStartThe start index of the region in this to create the string from.
regionLengthThe maximum length of the region to create the string from. Defaults to Integer.MAX_VALUE.
Returns
A string that represents the specified sub region of this object

◆ toString() [4/4]

StringBuilder toString ( StringBuilder  result,
int  regionStart,
int  regionLength,
boolean  appendMode 
)

Copies a region of the contents of this AString into the given StringBuilder.

Parameters
resultA result StringBuilder to copy the specified region into. If null, a new String builder is created
regionStartThe start index of the region to be copied.
regionLengthThe maximum length of the region to be copied.
appendModeIf true, any contents in the result is preserved. Otherwise such content gets replaced.
Returns
The (modified) result that was provided (for concatenation of calls).

◆ toUpper() [1/3]

AString toUpper ( )

Converts all characters in the buffer to upper case.

Returns
this to allow concatenated calls.

◆ toUpper() [2/3]

AString toUpper ( int  regionStart)

Converts characters in the buffer to upper case.

Parameters
regionStartStart of the region to be converted. Defaults to 0
Returns
this to allow concatenated calls.

◆ toUpper() [3/3]

AString toUpper ( int  regionStart,
int  regionLength 
)

Converts all or a region of characters in the buffer to upper case.

Parameters
regionStartStart of the region to be converted. Defaults to 0
regionLengthLength of the region to be converted. Defaults to int.MaxValue.
Returns
this to allow concatenated calls.

◆ trim() [1/2]

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.

Returns
this to allow concatenated calls.

◆ trim() [2/2]

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.

Parameters
trimCharsThe set of characters to be omitted. Defaults to null which causes this method to use CString.DEFAULT_WHITESPACES.
Returns
this to allow concatenated calls.

◆ trimAt() [1/2]

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.

Parameters
idxThe index to perform the trim operation at. Has to be between zero and Length() -1.
trimCharsPointer to a zero terminated set of characters to be omitted. Defaults to CString.DEFAULT_WHITESPACES.
Returns
The index of the first character of those characters that were behind the trimmed region.

◆ trimAt() [2/2]

int trimAt ( int  index)

Overloaded method providing default CString.DEFAULT_WHITESPACES value for parameter trimChars.

Parameters
indexThe index to perform the trim operation at. Has to be between zero and Length() -1.
Returns
The index of the first character of those characters that were behind the trimmed region.

◆ trimEnd() [1/2]

AString trimEnd ( )

All characters in CString.DEFAULT_WHITESPACES at the end of this string are removed.

Returns
this to allow concatenated calls.

◆ trimEnd() [2/2]

AString trimEnd ( char[]  trimChars)

All characters defined in given set are removed at the end of this string.

See also
Method trimAt to remove whitespaces at arbitrary places in the string.
Parameters
trimCharsThe set of characters to be omitted. Defaults to CString.DEFAULT_WHITESPACES.
Returns
this to allow concatenated calls.

◆ trimStart() [1/2]

AString trimStart ( )

All characters in CString.DEFAULT_WHITESPACES at the beginning of this string are removed.

Returns
this to allow concatenated calls.

◆ trimStart() [2/2]

AString trimStart ( char[]  trimChars)

All characters defined in given set are removed at the beginning of this string.

See also
Method trimAt to remove whitespaces at arbitrary places in the string.
Parameters
trimCharsThe set of characters to be omitted. Defaults to CString.DEFAULT_WHITESPACES.
Returns
this to allow concatenated calls.

Member Data Documentation

◆ _adjustedRegion

int [] _adjustedRegion = new int[2]
protected

Used as a return value of method CString.adjustRegion

◆ buffer

char [] buffer = com.aworx.lib.strings.CString.nullBuffer
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).

◆ fieldReference

int fieldReference =0
protected

A marker for the start of the actual field.

◆ hash

int hash =0
protected

The hash value. Has to be set dirty (0) whenever String is changed from outside!.

◆ length

int length =0
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).

◆ tabReference

int tabReference =0
protected

The tab reference position. This is set when newLine is invoked.


The documentation for this class was generated from the following file: