|
Groovy JDK |
Method Summary | |
---|---|
boolean
|
asBoolean()
Coerce a string (an instance of CharSequence) to a boolean value. |
Object
|
asType(Class c)
Provides a method to perform custom 'dynamic' type conversion
to the given class using the |
Pattern
|
bitwiseNegate()
Turns a CharSequence into a regular expression Pattern |
CharSequence
|
capitalize()
Convenience method to capitalize the first letter of a CharSequence. |
CharSequence
|
center(Number numberOfChars)
Pad a CharSequence to a minimum length specified by numberOfChars by adding the space character around it as many times as needed so that it remains centered. |
CharSequence
|
center(Number numberOfChars, CharSequence padding)
Pad a CharSequence to a minimum length specified by numberOfChars, appending the supplied padding CharSequence around the original as many times as needed keeping it centered. |
boolean
|
contains(CharSequence text)
Provide an implementation of contains() like Collection#contains to make CharSequences more polymorphic. |
int
|
count(CharSequence text)
Count the number of occurrences of a sub CharSequence. |
CharSequence
|
denormalize()
Return a CharSequence with lines (separated by LF, CR/LF, or CR) terminated by the platform specific line separator. |
CharSequence
|
drop(int num)
Drops the given number of chars from the head of this CharSequence if they are available. |
CharSequence
|
dropWhile(Closure condition)
Create a suffix of the given CharSequence by dropping as many characters as possible from the front of the original CharSequence such that calling the given closure condition evaluates to true when passed each of the dropped characters. |
Object
|
eachLine(Closure closure)
Iterates through this CharSequence line by line. |
Object
|
eachLine(int firstLine, Closure closure)
Iterates through this CharSequence line by line. |
String
|
eachMatch(CharSequence regex, Closure closure)
Process each regex group matched substring of the given CharSequence. |
String
|
eachMatch(Pattern pattern, Closure closure)
Process each regex group matched substring of the given pattern. |
CharSequence
|
expand()
Expands all tabs into spaces with tabStops of size 8. |
CharSequence
|
expand(int tabStop)
Expands all tabs into spaces. |
CharSequence
|
expandLine(int tabStop)
Expands all tabs into spaces. |
CharSequence
|
find(CharSequence regex)
Finds the first occurrence of a regular expression CharSequence within a CharSequence. |
CharSequence
|
find(CharSequence regex, Closure closure)
Returns the result of calling a closure with the first occurrence of a regular expression found within a CharSequence. |
CharSequence
|
find(Pattern pattern)
Finds the first occurrence of a compiled regular expression Pattern within a CharSequence. |
CharSequence
|
find(Pattern pattern, Closure closure)
Returns the result of calling a closure with the first occurrence of a regular expression found within a CharSequence. |
List
|
findAll(CharSequence regex)
Returns a (possibly empty) list of all occurrences of a regular expression (in CharSequence format) found within a CharSequence. |
List
|
findAll(CharSequence regex, Closure closure)
Finds all occurrences of a capturing regular expression CharSequence within a CharSequence. |
List
|
findAll(Pattern pattern)
Returns a (possibly empty) list of all occurrences of a regular expression (in Pattern format) found within a CharSequence. |
List
|
findAll(Pattern pattern, Closure closure)
Finds all occurrences of a compiled regular expression Pattern within a CharSequence. |
CharSequence
|
getAt(Collection indices)
Select a List of characters from a CharSequence using a Collection to identify the indices to be selected. |
CharSequence
|
getAt(EmptyRange range)
Support the range subscript operator for CharSequence or StringBuffer with EmptyRange |
CharSequence
|
getAt(int index)
Support the subscript operator for CharSequence. |
CharSequence
|
getAt(IntRange range)
Support the range subscript operator for CharSequence or StringBuffer with IntRange |
CharSequence
|
getAt(Range range)
Support the range subscript operator for CharSequence |
char[]
|
getChars()
Converts the given CharSequence into an array of characters. |
boolean
|
isAllWhitespace()
True if a CharSequence only contains whitespace characters. |
boolean
|
isBigDecimal()
Determine if a CharSequence can be parsed as a BigDecimal. |
boolean
|
isBigInteger()
Determine if a CharSequence can be parsed as a BigInteger. |
boolean
|
isCase(Object switchValue)
'Case' implementation for a CharSequence, which simply calls the equivalent method for String. |
boolean
|
isDouble()
Determine if a CharSequence can be parsed as a Double. |
boolean
|
isFloat()
Determine if a CharSequence can be parsed as a Float. |
boolean
|
isInteger()
Determine if a CharSequence can be parsed as an Integer. |
boolean
|
isLong()
Determine if a CharSequence can be parsed as a Long. |
boolean
|
isNumber()
Determine if a CharSequence can be parsed as a Number. |
StringBuilder
|
leftShift(Object value)
Overloads the left shift operator to provide an easy way to append multiple objects as string representations to a CharSequence. |
boolean
|
matches(Pattern pattern)
Tells whether or not a CharSequence matches the given compiled regular expression Pattern. |
CharSequence
|
minus(Object target)
Remove a part of a CharSequence by replacing the first occurrence of target within self with '' and returns the result. |
CharSequence
|
multiply(Number factor)
Repeat a CharSequence a certain number of times. |
CharSequence
|
next()
This method is called by the ++ operator for the class CharSequence. |
CharSequence
|
normalize()
Return a CharSequence with linefeeds and carriage returns normalized to linefeeds. |
CharSequence
|
padLeft(Number numberOfChars)
Pad a CharSequence to a minimum length specified by numberOfChars by adding the space character to the left as many times as needed. |
CharSequence
|
padLeft(Number numberOfChars, CharSequence padding)
Pad a CharSequence to a minimum length specified by numberOfChars, adding the supplied padding CharSequence as many times as needed to the left. |
CharSequence
|
padRight(Number numberOfChars)
Pad a CharSequence to a minimum length specified by numberOfChars by adding the space character to the right as many times as needed. |
CharSequence
|
padRight(Number numberOfChars, CharSequence padding)
Pad a CharSequence to a minimum length specified by numberOfChars, adding the supplied padding CharSequence as many times as needed to the right. |
CharSequence
|
plus(Object value)
Appends the String representation of the given operand to this string. |
CharSequence
|
previous()
This method is called by the -- operator for the class CharSequence. |
List
|
readLines()
Return the lines of a CharSequence as a List of CharSequence. |
CharSequence
|
replaceAll(CharSequence regex, CharSequence replacement)
Replaces each substring of this CharSequence that matches the given regular expression with the given replacement. |
CharSequence
|
replaceAll(CharSequence regex, Closure closure)
Replaces all occurrences of a captured group by the result of a closure on that text. |
CharSequence
|
replaceAll(Pattern pattern, CharSequence replacement)
Replaces all substrings of a CharSequence that match the given compiled regular expression with the given replacement. |
String
|
replaceAll(Pattern pattern, Closure closure)
Replaces all occurrences of a captured group by the result of a closure call on that text. |
String
|
replaceFirst(CharSequence regex, CharSequence replacement)
Replaces the first substring of this CharSequence that matches the given regular expression with the given replacement. |
String
|
replaceFirst(CharSequence regex, Closure closure)
Replaces the first occurrence of a captured group by the result of a closure call on that text. |
CharSequence
|
replaceFirst(Pattern pattern, CharSequence replacement)
Replaces the first substring of a CharSequence that matches the given compiled regular expression with the given replacement. |
String
|
replaceFirst(Pattern pattern, Closure closure)
Replaces the first occurrence of a captured group by the result of a closure call on that text. |
CharSequence
|
reverse()
Creates a new CharSequence which is the reverse (backwards) of this string |
int
|
size()
Provide the standard Groovy size() method for CharSequence .
|
CharSequence[]
|
split()
Convenience method to split a CharSequence (with whitespace as delimiter). |
Object
|
splitEachLine(CharSequence regex, Closure closure)
Iterates through the given CharSequence line by line, splitting each line using the given separator. |
Object
|
splitEachLine(Pattern pattern, Closure closure)
Iterates through the given CharSequence line by line, splitting each line using the given separator Pattern. |
CharSequence
|
stripIndent()
Strip leading spaces from every line in a CharSequence. |
CharSequence
|
stripIndent(int numChars)
Strip numChar leading characters from every line in a CharSequence. |
CharSequence
|
stripMargin()
Strip leading whitespace/control characters followed by '|' from every line in a CharSequence. |
CharSequence
|
stripMargin(char marginChar)
Strip leading whitespace/control characters followed by marginChar from every line in a String. |
String
|
stripMargin(CharSequence marginChar)
Strip leading whitespace/control characters followed by marginChar from every line in a CharSequence. |
CharSequence
|
take(int num)
Returns the first num elements from this CharSequence.
|
CharSequence
|
takeWhile(Closure condition)
Returns the longest prefix of this CharSequence where each element passed to the given closure evaluates to true. |
BigDecimal
|
toBigDecimal()
Parse a CharSequence into a BigDecimal |
BigInteger
|
toBigInteger()
Parse a CharSequence into a BigInteger |
Double
|
toDouble()
Parse a CharSequence into a Double |
Float
|
toFloat()
Parse a CharSequence into a Float |
Integer
|
toInteger()
Parse a CharSequence into an Integer |
List
|
toList()
Converts the given CharSequence into a List of CharSequence of one character. |
Long
|
toLong()
Parse a CharSequence into a Long |
Set
|
toSet()
Converts the given CharSequence into a Set of unique CharSequence of one character. |
Short
|
toShort()
Parse a CharSequence into a Short |
URI
|
toURI()
Transforms a CharSequence representing a URI into a URI object. |
URL
|
toURL()
Transforms a CharSequence representing a URL into a URL object. |
List
|
tokenize()
Tokenize a CharSequence (with a whitespace as the delimiter). |
List
|
tokenize(Character token)
Tokenize a CharSequence based on the given character delimiter. |
List
|
tokenize(CharSequence token)
Tokenize a CharSequence based on the given CharSequence delimiter. |
CharSequence
|
tr(CharSequence sourceSet, CharSequence replacementSet)
Translates a string by replacing characters from the sourceSet with characters from replacementSet. |
CharSequence
|
unexpand()
Replaces sequences of whitespaces with tabs using tabStops of size 8. |
CharSequence
|
unexpand(int tabStop)
Replaces sequences of whitespaces with tabs. |
CharSequence
|
unexpandLine(int tabStop)
Replaces sequences of whitespaces with tabs within a line. |
Method Detail |
---|
public boolean asBoolean()
public Object asType(Class c)
Provides a method to perform custom 'dynamic' type conversion
to the given class using the as
operator.
c
- the desired class.public Pattern bitwiseNegate()
public CharSequence capitalize()
public CharSequence center(Number numberOfChars)
numberOfChars
- the total minimum number of characters of the resulting CharSequence.public CharSequence center(Number numberOfChars, CharSequence padding)
numberOfChars
- the total minimum number of characters of the resulting CharSequence.padding
- the characters used for padding.public boolean contains(CharSequence text)
text
- the CharSequence to look for.public int count(CharSequence text)
text
- a sub CharSequence.public CharSequence denormalize()
public CharSequence drop(int num)
def text = "Groovy" assert text.drop( 0 ) == 'Groovy' assert text.drop( 2 ) == 'oovy' assert text.drop( 7 ) == ''
num
- the number of characters to drop from this iterator.num
ones,
or else an empty String, if this CharSequence has less than num
characters.public CharSequence dropWhile(Closure condition)
def text = "Groovy" assert text.dropWhile{ false } == 'Groovy' assert text.dropWhile{ true } == '' assert text.dropWhile{ it < 'Z' } == 'roovy' assert text.dropWhile{ it != 'v' } == 'vy'
condition
- the closure that while continuously evaluating to true will cause us to drop elements from
the front of the original CharSequence.public Object eachLine(Closure closure)
closure
- a closure.public Object eachLine(int firstLine, Closure closure)
firstLine
- the line number value used for the first line (default is 1, set to 0 to start counting from 0).closure
- a closure (arg 1 is line, optional arg 2 is line number).public String eachMatch(CharSequence regex, Closure closure)
regex
- a Regex CharSequence.closure
- a closure with one parameter or as much parameters as groups.public String eachMatch(Pattern pattern, Closure closure)
pattern
- a regex Pattern.closure
- a closure with one parameter or as much parameters as groups.public CharSequence expand()
public CharSequence expand(int tabStop)
tabStop
- The number of spaces a tab represents.public CharSequence expandLine(int tabStop)
tabStop
- The number of spaces a tab represents.public CharSequence find(CharSequence regex)
regex
- the capturing regex.public CharSequence find(CharSequence regex, Closure closure)
regex
- the capturing regex CharSequence.closure
- the closure that will be passed the full match, plus each of the capturing groups.public CharSequence find(Pattern pattern)
pattern
- the compiled regex Pattern.public CharSequence find(Pattern pattern, Closure closure)
pattern
- the compiled regex Pattern.closure
- the closure that will be passed the full match, plus each of the capturing groups.public List findAll(CharSequence regex)
regex
- the capturing regex CharSequence.public List findAll(CharSequence regex, Closure closure)
regex
- the capturing regex CharSequence.closure
- will be passed the full match plus each of the capturing groups.public List findAll(Pattern pattern)
pattern
- the compiled regex Pattern.public List findAll(Pattern pattern, Closure closure)
pattern
- the compiled regex Pattern.closure
- will be passed the full match plus each of the capturing groups.public CharSequence getAt(Collection indices)
indices
- a Collection of indices.public CharSequence getAt(EmptyRange range)
range
- an EmptyRange.public CharSequence getAt(int index)
index
- the index of the Character to get.public CharSequence getAt(IntRange range)
range
- an IntRange.public CharSequence getAt(Range range)
range
- a Range.public char[] getChars()
public boolean isAllWhitespace()
public boolean isBigDecimal()
public boolean isBigInteger()
public boolean isCase(Object switchValue)
switchValue
- the switch value.public boolean isDouble()
public boolean isFloat()
public boolean isInteger()
public boolean isLong()
public boolean isNumber()
public StringBuilder leftShift(Object value)
value
- an Object.public boolean matches(Pattern pattern)
pattern
- the regex Pattern to which the string of interest is to be matched.public CharSequence minus(Object target)
target
- an object representing the part to remove.public CharSequence multiply(Number factor)
factor
- the number of times the CharSequence should be repeated.public CharSequence next()
public CharSequence normalize()
public CharSequence padLeft(Number numberOfChars)
numberOfChars
- the total minimum number of characters of the resulting CharSequence.public CharSequence padLeft(Number numberOfChars, CharSequence padding)
numberOfChars
- the total minimum number of characters of the resulting CharSequence.padding
- the characters used for padding.public CharSequence padRight(Number numberOfChars)
numberOfChars
- the total minimum number of characters of the resulting string.public CharSequence padRight(Number numberOfChars, CharSequence padding)
numberOfChars
- the total minimum number of characters of the resulting CharSequence.padding
- the characters used for padding.public CharSequence plus(Object value)
value
- any Object.public CharSequence previous()
public List readLines()
public CharSequence replaceAll(CharSequence regex, CharSequence replacement)
regex
- the capturing regex.replacement
- the capturing regex.public CharSequence replaceAll(CharSequence regex, Closure closure)
regex
- the capturing regex.closure
- the closure to apply on each captured group.public CharSequence replaceAll(Pattern pattern, CharSequence replacement)
pattern
- the regex Pattern to which the CharSequence of interest is to be matched.replacement
- the CharSequence to be substituted for the first match.public String replaceAll(Pattern pattern, Closure closure)
pattern
- the capturing regex Pattern.closure
- the closure to apply on each captured group.public String replaceFirst(CharSequence regex, CharSequence replacement)
regex
- the capturing regex.replacement
- the capturing regex.public String replaceFirst(CharSequence regex, Closure closure)
regex
- the capturing regex.closure
- the closure to apply on the first captured group.public CharSequence replaceFirst(Pattern pattern, CharSequence replacement)
pattern
- the regex Pattern to which the CharSequence of interest is to be matched.replacement
- the CharSequence to be substituted for the first match.public String replaceFirst(Pattern pattern, Closure closure)
pattern
- the capturing regex Pattern.closure
- the closure to apply on the first captured group.public CharSequence reverse()
public int size()
size()
method for CharSequence
.public CharSequence[] split()
public Object splitEachLine(CharSequence regex, Closure closure)
regex
- the delimiting regular expression.closure
- a closure.public Object splitEachLine(Pattern pattern, Closure closure)
pattern
- the regular expression Pattern for the delimiter.closure
- a closure.public CharSequence stripIndent()
Strip leading spaces from every line in a CharSequence. The line with the least number of leading spaces determines the number to remove. Lines only containing whitespace are ignored when calculating the number of leading spaces to strip.
public CharSequence stripIndent(int numChars)
Strip numChar leading characters from every line in a CharSequence.
numChars
- The number of characters to strip.public CharSequence stripMargin()
Strip leading whitespace/control characters followed by '|' from every line in a CharSequence.
public CharSequence stripMargin(char marginChar)
Strip leading whitespace/control characters followed by marginChar from every line in a String.
marginChar
- Any character that serves as margin delimiter.public String stripMargin(CharSequence marginChar)
Strip leading whitespace/control characters followed by marginChar from every line in a CharSequence.
marginChar
- Any character that serves as margin delimiter.public CharSequence take(int num)
num
elements from this CharSequence.
def text = "Groovy" assert text.take( 0 ) == '' assert text.take( 2 ) == 'Gr' assert text.take( 7 ) == 'Groovy'
num
- the number of chars to take from this CharSequence.num
chars,
or else the whole CharSequence if it has less then num
elements.public CharSequence takeWhile(Closure condition)
def text = "Groovy" assert text.takeWhile{ it < 'A' } == '' assert text.takeWhile{ it < 'Z' } == 'G' assert text.takeWhile{ it != 'v' } == 'Groo' assert text.takeWhile{ it < 'z' } == 'Groovy'
condition
- the closure that must evaluate to true to
continue taking elements.public BigDecimal toBigDecimal()
public BigInteger toBigInteger()
public Double toDouble()
public Float toFloat()
public Integer toInteger()
public List toList()
public Long toLong()
public Set toSet()
public Short toShort()
public URI toURI()
public URL toURL()
public List tokenize()
public List tokenize(Character token)
token
- the delimiter.public List tokenize(CharSequence token)
token
- the delimiter.public CharSequence tr(CharSequence sourceSet, CharSequence replacementSet)
sourceSet
- the set of characters to translate from.replacementSet
- the set of replacement characters.public CharSequence unexpand()
public CharSequence unexpand(int tabStop)
tabStop
- The number of spaces a tab represents.public CharSequence unexpandLine(int tabStop)
tabStop
- The number of spaces a tab represents.
|
Groovy JDK |