| Fields inherited from class | Fields |
|---|---|
class GString |
EMPTY, EMPTY_OBJECT_ARRAY, EMPTY_STRING_ARRAY |
| Constructor and description |
|---|
GStringImpl(Object[] values, String[] strings)Create a new GString with values and strings. |
protected GStringImpl(Object[] values, String[] strings, boolean cacheable, String cachedStringLiteral, boolean frozen)Create a new GString with values and strings. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
build(GroovyObject builder) |
|
protected int |
calcInitialCapacity() |
|
public int |
codePointAt(int index)Returns the Unicode code point at UTF-16 index index in the
rendered text. |
|
public int |
codePointBefore(int index)Returns the Unicode code point that ends just before UTF-16 index index. |
|
public int |
codePointCount(int beginIndex, int endIndex)Returns how many Unicode code points lie in the rendered text from beginIndex inclusive to endIndex exclusive. |
|
public int |
compareTo(String anotherString)Orders the rendered text against anotherString by UTF-16
code unit, using the same ordering as String.compareTo. |
|
public int |
compareToIgnoreCase(String str)Orders the rendered text against str by UTF-16 code unit
after case folding. |
|
public String |
concat(String str)Returns the rendered text followed by str. |
|
public boolean |
contains(CharSequence s)Reports whether s occurs in the rendered text.
|
|
public boolean |
contentEquals(StringBuffer sb)Reports whether the rendered text and sb have the same
length and the same characters. |
|
public boolean |
contentEquals(CharSequence cs)Reports whether the rendered text and cs have the same
length and the same characters. |
|
public boolean |
endsWith(String suffix)Reports whether the rendered text ends with suffix.
|
|
public boolean |
equalsIgnoreCase(String anotherString)Reports whether the rendered text and anotherString are
equal ignoring case. |
|
public GString |
freeze()
|
|
public byte[] |
getBytes(Charset charset)Encodes the rendered text with charset into a new byte array. |
|
public void |
getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)Copies UTF-16 code units from the rendered text into dst.
|
|
public String[] |
getStrings()Get the strings of this GString. |
|
public Object[] |
getValues() |
|
public int |
indexOf(int ch)Returns the UTF-16 index of the first occurrence of code point ch in the rendered text, or -1 when it does not
occur. |
|
public int |
indexOf(int ch, int fromIndex)Returns the UTF-16 index of the first occurrence of code point ch at or after fromIndex, or -1 when it
does not occur. |
|
public int |
indexOf(String str)Returns the UTF-16 index of the first occurrence of str
in the rendered text, or -1 when it does not occur. |
|
public int |
indexOf(String str, int fromIndex)Returns the UTF-16 index of the first occurrence of str
at or after fromIndex, or -1 when it does not
occur. |
|
public String |
intern()Returns the pooled instance of the rendered text. |
|
public boolean |
isBlank()Returns true if the string is empty or contains only
white space codepoints,
otherwise false. |
|
public boolean |
isEmpty()Reports whether the rendered text contains no code units. |
|
public int |
lastIndexOf(int ch)Returns the UTF-16 index of the last occurrence of code point ch in the rendered text, or -1 when it does not
occur. |
|
public int |
lastIndexOf(int ch, int fromIndex)Returns the UTF-16 index of the last occurrence of code point ch at or before fromIndex, or -1 when it
does not occur. |
|
public int |
lastIndexOf(String str)Returns the UTF-16 index of the last occurrence of str
in the rendered text, or -1 when it does not occur. |
|
public int |
lastIndexOf(String str, int fromIndex)Returns the UTF-16 index of the last occurrence of str
at or before fromIndex, or -1 when it does not
occur. |
|
public Stream<String> |
lines()Returns a stream of lines extracted from this string, separated by line terminators. |
|
public boolean |
matches(String regex)Reports whether regex matches the whole rendered text.
|
|
public int |
offsetByCodePoints(int index, int codePointOffset)Returns the UTF-16 index reached by moving codePointOffset
code points from index. |
|
public GString |
plus(GString that) |
|
public boolean |
regionMatches(int toffset, String other, int ooffset, int len)Compares len UTF-16 code units of the rendered text starting
at toffset with len code units of other
starting at ooffset. |
|
public boolean |
regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len)Compares len UTF-16 code units of the rendered text starting
at toffset with the same number of units of other
starting at ooffset. |
|
public String |
repeat(int count)Returns a string whose value is the concatenation of this string repeated count times. |
|
public String |
replace(char oldChar, char newChar)Returns the rendered text with every oldChar replaced by
newChar. |
|
public String |
replace(CharSequence target, CharSequence replacement)Returns the rendered text with every occurrence of the literal sequence target replaced by replacement. |
|
public String |
replaceAll(String regex, String replacement)Returns the rendered text with every substring matched by regex replaced by replacement. |
|
public String |
replaceFirst(String regex, String replacement)Returns the rendered text with the first substring matched by regex replaced by replacement. |
|
public String[] |
split(String regex, int limit)Splits the rendered text around matches of regex. |
|
public String[] |
split(String regex)Splits the rendered text around matches of regex and
drops trailing empty strings. |
|
public boolean |
startsWith(String prefix, int toffset)Reports whether prefix occurs in the rendered text at
UTF-16 index toffset. |
|
public boolean |
startsWith(String prefix)Reports whether the rendered text begins with prefix.
|
|
public String |
strip()Returns a string whose value is this string, with all leading and trailing white space removed. |
|
public String |
stripLeading()Returns a string whose value is this string, with all leading white space removed. |
|
public String |
stripTrailing()Returns a string whose value is this string, with all trailing white space removed. |
|
public String |
substring(int beginIndex)Returns the tail of the rendered text from beginIndex
inclusive through the last code unit. |
|
public String |
substring(int beginIndex, int endIndex)Returns the slice of the rendered text from beginIndex
inclusive to endIndex exclusive. |
|
public char[] |
toCharArray()Copies the UTF-16 code units of the rendered text into a new array. |
|
public String |
toLowerCase(Locale locale)Returns the rendered text converted to lower case with the case-mapping rules of locale. |
|
public String |
toLowerCase()Returns the rendered text converted to lower case with the case-mapping rules of Locale.getDefault at the time of the call. |
|
public String |
toString() |
|
public String |
toUpperCase(Locale locale)Returns the rendered text converted to upper case with the case-mapping rules of locale. |
|
public String |
toUpperCase()Returns the rendered text converted to upper case with the case-mapping rules of Locale.getDefault at the time of the call. |
|
public String |
trim()Returns the rendered text with every leading and trailing UTF-16 code unit whose value is at most U+0020 removed. |
|
public Writer |
writeTo(Writer out) |
| Methods inherited from class | Name |
|---|---|
class GString |
build, calcInitialCapacity, charAt, compareTo, equals, equals, getBytes, getBytes, getStrings, getValue, getValueCount, getValues, hashCode, invokeMethod, length, negate, plus, plus, subSequence, toString, writeTo |
class GroovyObjectSupport |
getMetaClass, setMetaClass |
Create a new GString with values and strings.
Each value is prefixed by a string, after the last value
an additional String might be used, hence the following constraint is expected to hold:
strings.length == values.length || strings.length == values.length + 1
.
NOTE: The lengths are not checked but using arrays with lengths which violate the above constraint could result in unpredictable behaviour.
values - the value partsstrings - the string partsCreate a new GString with values and strings.
Each value is prefixed by a string, after the last value
an additional String might be used, hence the following constraint is expected to hold:
strings.length == values.length || strings.length == values.length + 1
.
NOTE: The lengths are not checked but using arrays with lengths which violate the above constraint could result in unpredictable behaviour.
values - the value partsstrings - the string partsfrozen - creates a GStringImpl which is not subject to mutation and hence more amenable to caching Returns the Unicode code point at UTF-16 index index in the
rendered text. A high surrogate at that index followed by a low
surrogate is returned as one supplementary code point; any other
code unit, including an unpaired surrogate, is returned as its own
value.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws StringIndexOutOfBoundsException if index is negative or not less than the
rendered length.
index - UTF-16 index of the code unit to read, counting from zeroindex Returns the Unicode code point that ends just before UTF-16 index
index. When the code unit at index - 1 is a low
surrogate and the unit before it is a high surrogate, the
supplementary code point of that pair is returned; otherwise the
single code unit at index - 1 is returned.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws StringIndexOutOfBoundsException if index is less than 1 or greater than
the rendered length.
index - UTF-16 index just after the code point to readindex Returns how many Unicode code points lie in the rendered text from
beginIndex inclusive to endIndex exclusive. An
unpaired surrogate counts as one code point.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws IndexOutOfBoundsException if beginIndex is negative, endIndex is
greater than the rendered length, or beginIndex is greater than endIndex.
beginIndex - first UTF-16 index of the range, inclusiveendIndex - UTF-16 index at which the range stops, exclusive Orders the rendered text against anotherString by UTF-16
code unit, using the same ordering as String.compareTo.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if anotherString is null.
anotherString - string the rendered text is ordered againstanotherString Orders the rendered text against str by UTF-16 code unit
after case folding. Each unit is folded with
Character.toUpperCase and then
Character.toLowerCase. No locale is consulted. When
one folded text is a prefix of the other, the shorter one sorts first.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if str is null.
str - string the rendered text is ordered againststr Returns the rendered text followed by str. An empty
str returns the rendered string itself.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if str is null.
str - text appended after the rendered textstr appended, or the rendered
string when str is empty Reports whether s occurs in the rendered text.
An empty sequence occurs at the start.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if s is null.
s - sequence to search fortrue when s occurs in the rendered text Reports whether the rendered text and sb have the same
length and the same characters. The buffer is locked while its
length and characters are read.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if sb is null.
sb - buffer whose current contents are comparedtrue when both sides have the same length and characters Reports whether the rendered text and cs have the same
length and the same characters. A String is compared with
String.equals. A StringBuffer is locked
for the read. A StringBuilder is compared without a lock.
Any other sequence is walked with its length and charAt.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if cs is null.
cs - sequence compared with the rendered texttrue when both sides have the same length and characters Reports whether the rendered text ends with suffix.
An empty suffix matches.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if suffix is null.
suffix - sequence the rendered text must end withtrue when suffix is a suffix of the rendered text Reports whether the rendered text and anotherString are
equal ignoring case. The lengths must already match, and each
UTF-16 code unit is then folded with
Character.toUpperCase and, when those differ,
Character.toLowerCase. No locale is consulted, so
the result can disagree with folding both sides through
String.toLowerCase. A null argument yields false.
The text comes from toString(). When this instance may cache its rendering, the stored text is reused; otherwise the literal segments and values are interpolated on every call.
anotherString - string compared with the rendered texttrue when the two texts match under that case folding
Encodes the rendered text with charset into a new byte array.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if charset is null.
charset - encoding used to turn the rendered text into bytes Copies UTF-16 code units from the rendered text into dst.
The copied range starts at srcBegin inclusive and stops at
srcEnd exclusive, and the first copied unit is written at
dstBegin.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if dst is null.
Throws StringIndexOutOfBoundsException if the source range falls
outside the rendered text, or if dst has no room for the copied
units starting at dstBegin.
srcBegin - first rendered index to copy, inclusivesrcEnd - rendered index at which copying stops, exclusivedst - array that receives the copied code unitsdstBegin - index in dst of the first copied unitGet the strings of this GString.
This method returns the same array as used in the constructor. Changing the values will result in changes of the GString. It is generally not recommended to do so.
Returns the UTF-16 index of the first occurrence of code point
ch in the rendered text, or -1 when it does not
occur. A basic-plane value matches one code unit, a supplementary
code point matches its surrogate pair, and any other int
does not occur. The search starts at the first code unit.
The text comes from toString(). When this instance may cache its rendering, the stored text is reused; otherwise the literal segments and values are interpolated on every call.
ch - code point to search for-1 when there is none Returns the UTF-16 index of the first occurrence of code point
ch at or after fromIndex, or -1 when it
does not occur. A negative fromIndex starts at the
beginning, and a fromIndex at or beyond the rendered
length yields -1. A basic-plane value matches one code
unit, a supplementary code point matches its surrogate pair, and
any other int does not occur.
The text comes from toString(). When this instance may cache its rendering, the stored text is reused; otherwise the literal segments and values are interpolated on every call.
ch - code point to search forfromIndex - UTF-16 index at which the search startsfromIndex,
or -1 when there is none Returns the UTF-16 index of the first occurrence of str
in the rendered text, or -1 when it does not occur. The
empty string occurs at index zero.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if str is null.
str - exact sequence to search for-1 when there is none Returns the UTF-16 index of the first occurrence of str
at or after fromIndex, or -1 when it does not
occur. A negative fromIndex starts at the beginning. The
empty string occurs at fromIndex clamped into the range
from zero through the rendered length.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if str is null.
str - exact sequence to search forfromIndex - UTF-16 index at which the search startsfromIndex,
or -1 when there is noneReturns the pooled instance of the rendered text. The rendering is installed in the pool when no equal string is already there, and an equal string that was already pooled is the object returned.
The text comes from toString(). When this instance may cache its rendering, the stored text is reused; otherwise the literal segments and values are interpolated on every call.
Returns true if the string is empty or contains only
white space codepoints,
otherwise false.
true if the string is empty or contains only
white space codepoints,
otherwise falseReports whether the rendered text contains no code units.
The text comes from toString(). When this instance may cache its rendering, the stored text is reused; otherwise the literal segments and values are interpolated on every call.
true when the rendered length is zero Returns the UTF-16 index of the last occurrence of code point
ch in the rendered text, or -1 when it does not
occur. A basic-plane value matches one code unit, a supplementary
code point matches its surrogate pair, and any other int
does not occur. The search starts at the last code unit.
The text comes from toString(). When this instance may cache its rendering, the stored text is reused; otherwise the literal segments and values are interpolated on every call.
ch - code point to search for-1 when there is none Returns the UTF-16 index of the last occurrence of code point
ch at or before fromIndex, or -1 when it
does not occur. A negative fromIndex yields -1.
A fromIndex past the end searches the whole rendered text.
A basic-plane value matches one code unit, a supplementary code
point matches its surrogate pair, and any other int does
not occur.
The text comes from toString(). When this instance may cache its rendering, the stored text is reused; otherwise the literal segments and values are interpolated on every call.
ch - code point to search forfromIndex - UTF-16 index at which the backward search startsfromIndex,
or -1 when there is none Returns the UTF-16 index of the last occurrence of str
in the rendered text, or -1 when it does not occur. The
empty string occurs at the rendered length.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if str is null.
str - exact sequence to search for-1 when there is none Returns the UTF-16 index of the last occurrence of str
at or before fromIndex, or -1 when it does not
occur. A negative fromIndex yields -1, and a
fromIndex past the end searches the whole rendered text.
The empty string occurs at fromIndex when that index is
in range, and at the rendered length when fromIndex is
past the end.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if str is null.
str - exact sequence to search forfromIndex - UTF-16 index at which the backward search startsfromIndex,
or -1 when there is noneReturns a stream of lines extracted from this string, separated by line terminators.
A line terminator is one of the following:
a line feed character "\n" (U+000A),
a carriage return character "\r" (U+000D),
or a carriage return followed immediately by a line feed
"\r\n" (U+000D U+000A).
A line is either a sequence of zero or more characters followed by a line terminator, or it is a sequence of one or more characters followed by the end of the string. A line does not include the line terminator.
The stream returned by this method contains the lines from this string in the order in which they occur.
API Note: This definition of line implies that an empty string has zero lines and that there is no empty line following a line terminator at the end of a string.
Implementation Note: This method provides better performance than
split("\R") by supplying elements lazily and
by faster search of new line terminators.
Reports whether regex matches the whole rendered text.
A pattern that matches only a substring yields false.
The pattern is compiled for this call.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if regex is null.
Throws PatternSyntaxException if regex cannot be compiled.
regex - regular expression matched against the entire renderingtrue when the pattern matches the whole rendered text Returns the UTF-16 index reached by moving codePointOffset
code points from index. An unpaired surrogate counts as one
code point. index may equal the rendered length, and a zero
offset then stays on that length.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws IndexOutOfBoundsException if index is negative or greater than the
rendered length, or if the walk would pass either end of the text.
index - UTF-16 index at which the walk starts, from zero through
the rendered length inclusivecodePointOffset - number of code points to move. Positive moves
toward the end and negative moves toward the start Compares len UTF-16 code units of the rendered text starting
at toffset with len code units of other
starting at ooffset. A negative offset, or a region that
does not fit in either text, yields false. A negative
len compares no units and yields true when both
offsets are non-negative.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if other is null.
toffset - first rendered index of the regionother - string that supplies the region to compare againstooffset - first index of the region in otherlen - number of UTF-16 code units to comparetrue when the compared units match, or when len
is negative and both offsets are non-negative Compares len UTF-16 code units of the rendered text starting
at toffset with the same number of units of other
starting at ooffset. When ignoreCase is true, each
unit is folded with Character.toUpperCase and, when
those differ, Character.toLowerCase; otherwise the
units are compared unchanged. A negative offset, or a region that
does not fit in either text, yields false. A negative
len compares no units and yields true when both
offsets are non-negative.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if other is null.
ignoreCase - true to fold case before comparing unitstoffset - first rendered index of the regionother - string that supplies the region to compare againstooffset - first index of the region in otherlen - number of UTF-16 code units to comparetrue when the regions match under that comparison, or
when len is negative and both offsets are non-negative Returns a string whose value is the concatenation of this
string repeated count times.
If this string is empty or count is zero then the empty string is returned.
count is
negative.count - number of times to repeatcount times or the empty string if this
string is empty or count is zero Returns the rendered text with every oldChar replaced by
newChar. When oldChar does not occur, or the two
characters are equal, the rendered string is returned unchanged.
The text comes from toString(). When this instance may cache its rendering, the stored text is reused; otherwise the literal segments and values are interpolated on every call.
oldChar - code unit to replacenewChar - code unit written in its place Returns the rendered text with every occurrence of the literal
sequence target replaced by replacement. The
search is not a regular expression, so a dollar sign in
replacement stays a dollar sign. An empty target
is written between every code unit, including both ends. A
target that does not occur returns the rendered string
unchanged.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if target or replacement is null.
target - literal sequence to replacereplacement - literal sequence written in its place Returns the rendered text with every substring matched by
regex replaced by replacement. A dollar sign or
backslash in replacement is a matcher substitution, not
a literal character. A pattern that matches nothing returns the
rendered string unchanged.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if regex or replacement is null.
Throws PatternSyntaxException if regex cannot be compiled.
regex - regular expression whose matches are replacedreplacement - text written over each match, with matcher
substitution of dollar signs and backslashes Returns the rendered text with the first substring matched by
regex replaced by replacement. A dollar sign or
backslash in replacement is a matcher substitution, not
a literal character. A pattern that matches nothing returns the
rendered string unchanged.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if regex or replacement is null.
Throws PatternSyntaxException if regex cannot be compiled.
regex - regular expression whose first match is replacedreplacement - text written over that match, with matcher
substitution of dollar signs and backslashes Splits the rendered text around matches of regex. A
positive limit applies the pattern at most
limit - 1 times and leaves the unmatched tail in the last
element. A limit of zero applies the pattern as many times as
possible and drops trailing empty strings. A negative limit
applies the pattern as many times as possible and keeps trailing
empty strings. When the pattern matches nothing, the result is a
one-element array holding the rendered text.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if regex is null.
Throws PatternSyntaxException if regex cannot be compiled.
regex - regular expression that separates the rendered textlimit - maximum number of applications of the pattern, with
the zero and negative cases above Splits the rendered text around matches of regex and
drops trailing empty strings. The split uses a limit of zero.
When the pattern matches nothing, the result is a one-element
array holding the rendered text.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if regex is null.
Throws PatternSyntaxException if regex cannot be compiled.
regex - regular expression that separates the rendered text Reports whether prefix occurs in the rendered text at
UTF-16 index toffset. An empty prefix matches when
toffset lies between zero and the rendered length,
inclusive. A negative offset, or a prefix that would extend past
the end, yields false.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if prefix is null.
prefix - sequence that must occur at toffsettoffset - UTF-16 index at which prefix must starttrue when the rendered text has prefix there Reports whether the rendered text begins with prefix.
An empty prefix matches. The comparison starts at the first code unit.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if prefix is null.
prefix - sequence the rendered text must begin withtrue when prefix is a prefix of the rendered textReturns a string whose value is this string, with all leading and trailing white space removed.
If this String object represents an empty string,
or if all code points in this string are
white space, then an empty string
is returned.
Otherwise, returns a substring of this string beginning with the first code point that is not a white space up to and including the last code point that is not a white space.
This method may be used to strip white space from the beginning and end of a string.
Returns a string whose value is this string, with all leading white space removed.
If this String object represents an empty string,
or if all code points in this string are
white space, then an empty string
is returned.
Otherwise, returns a substring of this string beginning with the first code point that is not a white space up to and including the last code point of this string.
This method may be used to trim white space from the beginning of a string.
Returns a string whose value is this string, with all trailing white space removed.
If this String object represents an empty string,
or if all characters in this string are
white space, then an empty string
is returned.
Otherwise, returns a substring of this string beginning with the first code point of this string up to and including the last code point that is not a white space.
This method may be used to trim white space from the end of a string.
Returns the tail of the rendered text from beginIndex
inclusive through the last code unit. An index of zero returns the
rendered string itself, and an index equal to the length returns
an empty string.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws StringIndexOutOfBoundsException if beginIndex is negative or greater than
the rendered length.
beginIndex - first rendered index to keep, inclusivebeginIndex is zero Returns the slice of the rendered text from beginIndex
inclusive to endIndex exclusive. A range that covers the
whole rendering returns that rendered string itself.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws StringIndexOutOfBoundsException if beginIndex is negative, endIndex is greater than the rendered length, or beginIndex is greater than endIndex.
beginIndex - first rendered index to keep, inclusiveendIndex - rendered index at which the slice stops, exclusiveCopies the UTF-16 code units of the rendered text into a new array. Later writes to that array do not change this GString or the rendered string.
The text comes from toString(). When this instance may cache its rendering, the stored text is reused; otherwise the literal segments and values are interpolated on every call.
Returns the rendered text converted to lower case with the
case-mapping rules of locale. Those rules can change the
length of the text.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if locale is null.
locale - locale whose case mappings are appliedReturns the rendered text converted to lower case with the case-mapping rules of Locale.getDefault at the time of the call. Those rules can change the length of the text.
The text comes from toString(). When this instance may cache its rendering, the stored text is reused; otherwise the literal segments and values are interpolated on every call.
Returns the rendered text converted to upper case with the
case-mapping rules of locale. Those rules can change the
length of the text.
The text comes from toString(). When this instance may cache
its rendering, the stored text is reused; otherwise the literal segments
and values are interpolated on every call.
Throws NullPointerException if locale is null.
locale - locale whose case mappings are appliedReturns the rendered text converted to upper case with the case-mapping rules of Locale.getDefault at the time of the call. Those rules can change the length of the text.
The text comes from toString(). When this instance may cache its rendering, the stored text is reused; otherwise the literal segments and values are interpolated on every call.
Returns the rendered text with every leading and trailing UTF-16
code unit whose value is at most U+0020 removed. When neither
end has a code unit at or below that bound, the rendered string is
returned unchanged.
The text comes from toString(). When this instance may cache its rendering, the stored text is reused; otherwise the literal segments and values are interpolated on every call.
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.