Return type | Name and parameters |
---|---|
Object
|
asType(Class c)
Provides a method to perform custom 'dynamic' type conversion to the given class using the as operator.
|
String
|
collectReplacements(Closure transform)
Iterate through this String a character at a time collecting either the original character or a transformed replacement String. |
byte[]
|
decodeBase64()
Decode the String from Base64 into a byte array. |
byte[]
|
decodeBase64Url()
Decodes a Base64 URL and Filename Safe encoded String into a byte array. |
byte[]
|
decodeHex()
Decodes a hex string to a byte array. |
String
|
drop(int num)
A String variant of the equivalent CharSequence method. |
String
|
dropRight(int num)
A String variant of the equivalent CharSequence method CharSequence#dropRight(int) |
String
|
eachMatch(String regex, Closure closure)
Process each regex group matched substring of the given string. |
String
|
eachMatch(Pattern pattern, Closure closure)
Process each regex group matched substring of the given pattern. |
Process
|
execute()
Executes the command specified by self as a command-line process.
|
Process
|
execute(String[] envp, File dir)
Executes the command specified by self with environment defined by envp
and under the working directory dir .
|
Process
|
execute(List envp, File dir)
Executes the command specified by self with environment defined
by envp and under the working directory dir .
|
String
|
getAt(IntRange range)
Support the range subscript operator for String with IntRange |
String
|
getAt(Range range)
Support the range subscript operator for String |
String
|
getAt(int index)
Support the subscript operator for String. |
Boolean
|
isAtLeast(String right)
Compare a String representing a number to another. |
StringBuffer
|
leftShift(Object value)
Overloads the left shift operator to provide an easy way to append multiple objects as string representations to a String. |
String
|
plus(CharSequence value)
Appends the String representation of the given operand to this string. |
int
|
size()
Provide the standard Groovy size() method for String .
|
String
|
take(int num)
A String variant of the equivalent CharSequence method. |
String
|
takeAfter(CharSequence searchString)
A String variant of the equivalent CharSequence method CharSequence#takeAfter(CharSequence) |
String
|
takeBefore(String searchString)
A String variant of the equivalent CharSequence method CharSequence#takeBefore(CharSequence) |
String
|
takeBetween(CharSequence enclosure)
A String variant of the equivalent CharSequence method CharSequence#takeBetween(CharSequence) |
String
|
takeBetween(CharSequence enclosure, int occurrence)
A String variant of the equivalent CharSequence method CharSequence#takeBetween(CharSequence, int) |
String
|
takeBetween(CharSequence from, CharSequence to)
A String variant of the equivalent CharSequence method CharSequence#takeBetween(CharSequence, CharSequence) |
String
|
takeBetween(CharSequence from, CharSequence to, int occurrence)
A String variant of the equivalent CharSequence method CharSequence#takeBetween(CharSequence, CharSequence, int) |
String
|
takeRight(int num)
A GString variant of the equivalent CharSequence method CharSequence#takeRight(int) |
Boolean
|
toBoolean()
Converts the given string into a Boolean object. |
Character
|
toCharacter()
Converts the given string into a Character object using the first character in the string. |
URI
|
toURI()
Transforms a String representing a URI into a URI object. |
URL
|
toURL()
Transforms a String representing a URL into a URL object. |
addShutdownHook
, any
, any
, asBoolean
, asType
, average
, collect
, collect
, collect
, contains
, count
, dump
, each
, eachWithIndex
, equals
, every
, every
, find
, find
, findAll
, findAll
, findIndexOf
, findIndexOf
, findIndexValues
, findIndexValues
, findLastIndexOf
, findLastIndexOf
, findResult
, findResult
, flatten
, getAt
, getMetaClass
, getMetaPropertyValues
, getProperties
, grep
, grep
, groupBy
, groupBy
, hasProperty
, identity
, inject
, inject
, inspect
, invokeMethod
, is
, isCase
, iterator
, join
, metaClass
, print
, print
, printf
, printf
, println
, println
, println
, putAt
, respondsTo
, respondsTo
, setMetaClass
, size
, split
, sprintf
, sprintf
, stream
, sum
, sum
, tap
, toArrayString
, toSpreadMap
, toString
, use
, use
, use
, with
, with
, withTraits
asBoolean
, asType
, bitwiseNegate
, capitalize
, center
, center
, contains
, containsIgnoreCase
, count
, denormalize
, digest
, drop
, dropRight
, dropWhile
, eachLine
, eachLine
, eachMatch
, eachMatch
, endsWithAny
, endsWithIgnoreCase
, expand
, expand
, expandLine
, find
, find
, find
, find
, findAll
, findAll
, findAll
, findAll
, getAt
, getAt
, getAt
, getAt
, getAt
, getChars
, isAllWhitespace
, isBigDecimal
, isBigInteger
, isBlank
, isCase
, isDouble
, isFloat
, isInteger
, isLong
, isNumber
, leftShift
, matches
, md5
, minus
, minus
, multiply
, next
, normalize
, padLeft
, padLeft
, padRight
, padRight
, plus
, previous
, readLines
, replace
, replace
, replaceAll
, replaceAll
, replaceAll
, replaceAll
, replaceFirst
, replaceFirst
, replaceFirst
, replaceFirst
, reverse
, sha256
, size
, split
, splitEachLine
, splitEachLine
, startsWithAny
, startsWithIgnoreCase
, stripIndent
, stripIndent
, stripIndent
, stripMargin
, stripMargin
, stripMargin
, take
, takeAfter
, takeBefore
, takeBetween
, takeBetween
, takeBetween
, takeBetween
, takeRight
, takeWhile
, toBigDecimal
, toBigInteger
, toDouble
, toFloat
, toInteger
, toList
, toLong
, toSet
, toShort
, toURI
, toURL
, tokenize
, tokenize
, tokenize
, tr
, uncapitalize
, unexpand
, unexpand
, unexpandLine
Provides a method to perform custom 'dynamic' type conversion
to the given class using the as
operator.
Example: '123' as Double
By default, the following types are supported:
c
- the desired classIterate through this String a character at a time collecting either the
original character or a transformed replacement String. The transform
Closure should return null
to indicate that no transformation is
required for the given character.
assert "Groovy".collectReplacements{ it == 'o' ? '_O_' : null } == 'Gr_O__O_vy' assert "Groovy".collectReplacements{ it.equalsIgnoreCase('O') ? '_O_' : null } == 'Gr_O__O_vy' assert "Groovy".collectReplacements{ char c->
c == 'o' ? '_O_' : null } == 'Gr_O__O_vy' assert "Groovy".collectReplacements{ Character c->
c == 'o' ? '_O_' : null } == 'Gr_O__O_vy' assert "B&W".collectReplacements{it == '&' ? '&' : null
} == 'B&W'
transform
Closure.Decode the String from Base64 into a byte array.
Decodes a Base64 URL and Filename Safe encoded String into a byte array.
Decodes a hex string to a byte array. The hex string can contain either upper case or lower case letters.
A String variant of the equivalent CharSequence method.
num
- the number of characters to drop from this Stringnum
ones,
or else an empty String, if the String has less than num
characters.A String variant of the equivalent CharSequence method CharSequence#dropRight(int)
num
- number of charactersnum
chars and empty of the num
is greater than the
length of the CharSequenceProcess each regex group matched substring of the given string. If the closure parameter takes one argument, an array with all match groups is passed to it. If the closure takes as many arguments as there are match groups, then each parameter will be one match group.
regex
- a Regex stringclosure
- a closure with one parameter or as much parameters as groupsProcess each regex group matched substring of the given pattern. If the closure parameter takes one argument, an array with all match groups is passed to it. If the closure takes as many arguments as there are match groups, then each parameter will be one match group.
pattern
- a regex Patternclosure
- a closure with one parameter or as much parameters as groupsExecutes the command specified by self
as a command-line process.
For more control over Process construction you can use
java.lang.ProcessBuilder
.
Executes the command specified by self
with environment defined by envp
and under the working directory dir
.
For more control over Process construction you can use
java.lang.ProcessBuilder
.
envp
- an array of Strings, each element of which
has environment variable settings in the format
name=value, or
null if the subprocess should inherit
the environment of the current process.dir
- the working directory of the subprocess, or
null if the subprocess should inherit
the working directory of the current process.Executes the command specified by self
with environment defined
by envp
and under the working directory dir
.
For more control over Process construction you can use
java.lang.ProcessBuilder
.
envp
- a List of Objects (converted to Strings using toString), each member of which
has environment variable settings in the format
name=value, or
null if the subprocess should inherit
the environment of the current process.dir
- the working directory of the subprocess, or
null if the subprocess should inherit
the working directory of the current process.Support the range subscript operator for String with IntRange
range
- an IntRangeSupport the range subscript operator for String
range
- a RangeSupport the subscript operator for String.
index
- the index of the Character to getCompare a String representing a number to another.
A fluent api style alias for compareTo
on BigDecimal
.
right
- a String representing a numberOverloads the left shift operator to provide an easy way to append multiple objects as string representations to a String.
value
- an ObjectAppends the String representation of the given operand to this string.
value
- any CharSequenceProvide the standard Groovy size()
method for String
.
A String variant of the equivalent CharSequence method.
num
- the number of chars to take from this Stringnum
chars,
or else the whole String if it has less then num
elements.A String variant of the equivalent CharSequence method CharSequence#takeAfter(CharSequence)
searchString
- String that is searched in this CharSequenceA String variant of the equivalent CharSequence method CharSequence#takeBefore(CharSequence)
searchString
- CharSequence that is searched in this CharSequenceA String variant of the equivalent CharSequence method CharSequence#takeBetween(CharSequence)
enclosure
- Enclosure Stringenclosure
stringsA String variant of the equivalent CharSequence method CharSequence#takeBetween(CharSequence, int)
enclosure
- Enclosure Stringoccurrence
- nth occurrence being returnedenclosure
stringsA String variant of the equivalent CharSequence method CharSequence#takeBetween(CharSequence, CharSequence)
from
- beginning of searchto
- end of searchA String variant of the equivalent CharSequence method CharSequence#takeBetween(CharSequence, CharSequence, int)
from
- beginning of searchto
- end of searchoccurrence
- nth occurrence that is to be returned. 0 represents first onefrom
and to
CharSequences and empty if the unavailable inputs are given.A GString variant of the equivalent CharSequence method CharSequence#takeRight(int)
num
- the number of chars to take from this CharSequence from the rightnum
chars,
or else the whole CharSequence if it has less than num
elements.Converts the given string into a Boolean object. If the trimmed string is "true", "y" or "1" (ignoring case) then the result is true otherwise it is false.
Converts the given string into a Character object using the first character in the string.
Transforms a String representing a URI into a URI object.
Transforms a String representing a URL into a URL object.