Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.runtime
[Java] Class StringGroovyMethods

    java.lang.Object
      org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport
          org.codehaus.groovy.runtime.StringGroovyMethods

    public class StringGroovyMethods
    extends DefaultGroovyMethodsSupport

This class defines new groovy methods which appear on String-related JDK classes (String, CharSequence, Matcher) inside the Groovy environment. Static methods are used with the first parameter being the destination class, e.g.. `public static String reverse(String self)` provides a `reverse()` method for `String`.

NOTE: While this class contains many 'public' static methods, it is primarily regarded as an internal class (its internal package name suggests this also). We value backwards compatibility of these methods when used within Groovy but value less backwards compatibility at the Java method call level. I.e. future versions of Groovy may remove or move a method call in this file but would normally aim to keep the method available from within Groovy.

Authors:
  James Strachan
  Jeremy Rayner
  Sam Pullara
  Rod Cope
  Guillaume Laforge
  John Wilson
  Hein Meling
  Dierk Koenig
  Pilho Kim
  Marc Guillemot
  Russel Winder
  bing ran
  Jochen Theodorou
  Paul King
  Michael Baehr
  Joachim Baumann
  Alex Tkachman
  Ted Naleid
  Brad Long
  Jim Jagielski
  Rodolfo Velasco
  jeremi Joslin
  Hamlet D'Arcy
  Cedric Champeau
  Tim Yates
  Dinko Srkoc
  Pascal Lombard
  Christophe Charles

Method Summary
`static boolean` | `asBoolean(java.lang.CharSequence string)` Coerce a string (an instance of CharSequence) to a boolean value.
`static boolean` | `asBoolean(java.util.regex.Matcher matcher)` Coerce a Matcher instance to a boolean value.
`static java.lang.Object` | `asType(java.lang.CharSequence self, java.lang.Class c)`
`static java.lang.Object` | `asType(GString self, java.lang.Class c)` Converts the GString to a File, or delegates to the default DefaultGroovyMethods.asType
`static java.lang.Object` | `asType(java.lang.String self, java.lang.Class c)`
`static java.util.regex.Pattern` | `bitwiseNegate(java.lang.CharSequence self)` Turns a CharSequence into a regular expression Pattern
`static java.util.regex.Pattern` | `bitwiseNegate(java.lang.String self)` Turns a String into a regular expression Pattern
`static java.lang.CharSequence` | `capitalize(java.lang.CharSequence self)` Convenience method to capitalize the first letter of a CharSequence.
`static java.lang.String` | `capitalize(java.lang.String self)` Convenience method to capitalize the first letter of a string (typically the first letter of a word).
`static java.lang.CharSequence` | `center(java.lang.CharSequence self, java.lang.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.
`static java.lang.CharSequence` | `center(java.lang.CharSequence self, java.lang.Number numberOfChars, java.lang.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.
`static java.lang.String` | `center(java.lang.String self, java.lang.Number numberOfChars)` Pad a String to a minimum length specified by `numberOfChars` by adding the space character around it as many times as needed so that it remains centered.
`static java.lang.String` | `center(java.lang.String self, java.lang.Number numberOfChars, java.lang.String padding)` Pad a String to a minimum length specified by `numberOfChars`, appending the supplied padding String around the original as many times as needed keeping it centered.
`static boolean` | `contains(java.lang.CharSequence self, java.lang.CharSequence text)` Provide an implementation of contains() like java.util.Collection#contains(Object) to make CharSequences more polymorphic.
`static boolean` | `contains(java.lang.String self, java.lang.String text)` Provide an implementation of contains() like java.util.Collection#contains(Object) to make Strings more polymorphic.
`static int` | `count(java.lang.CharSequence self, java.lang.CharSequence text)` Count the number of occurrences of a sub CharSequence.
`static int` | `count(java.lang.String self, java.lang.String text)` Count the number of occurrences of a substring.
`static java.lang.CharSequence` | `denormalize(java.lang.CharSequence self)` Return a CharSequence with lines (separated by LF, CR/LF, or CR) terminated by the platform specific line separator.
`static java.lang.String` | `denormalize(java.lang.String self)` Return a String with lines (separated by LF, CR/LF, or CR) terminated by the platform specific line separator.
`static java.lang.CharSequence` | `drop(java.lang.CharSequence self, int num)` Drops the given number of chars from the head of this CharSequence if they are available.
`static java.lang.CharSequence` | `dropWhile(java.lang.CharSequence self, 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.
`static java.lang.Object` | `eachLine(java.lang.CharSequence self, Closure closure)` Iterates through this CharSequence line by line.
`static java.lang.Object` | `eachLine(java.lang.CharSequence self, int firstLine, Closure closure)`
`static java.lang.Object` | `eachLine(java.lang.String self, Closure closure)`
`static java.lang.Object` | `eachLine(java.lang.String self, int firstLine, Closure closure)`
`static java.lang.String` | `eachMatch(java.lang.CharSequence self, java.lang.CharSequence regex, Closure closure)` Process each regex group matched substring of the given CharSequence.
`static java.lang.String` | `eachMatch(java.lang.CharSequence self, java.util.regex.Pattern pattern, Closure closure)`
`static java.lang.String` | `eachMatch(java.lang.String self, java.util.regex.Pattern pattern, Closure closure)`
`static java.lang.String` | `eachMatch(java.lang.String self, java.lang.String regex, Closure closure)`
`static java.lang.CharSequence` | `expand(java.lang.CharSequence self)`
`static java.lang.CharSequence` | `expand(java.lang.CharSequence self, int tabStop)`
`static java.lang.String` | `expand(java.lang.String self)`
`static java.lang.String` | `expand(java.lang.String self, int tabStop)`
`static java.lang.CharSequence` | `expandLine(java.lang.CharSequence self, int tabStop)` Expands all tabs into spaces.
`static java.lang.String` | `expandLine(java.lang.String self, int tabStop)`
`static java.lang.CharSequence` | `find(java.lang.CharSequence self, java.lang.CharSequence regex)` Finds the first occurrence of a regular expression CharSequence within a CharSequence.
`static java.lang.CharSequence` | `find(java.lang.CharSequence self, java.lang.CharSequence regex, Closure closure)`
`static java.lang.CharSequence` | `find(java.lang.CharSequence self, java.util.regex.Pattern pattern)`
`static java.lang.CharSequence` | `find(java.lang.CharSequence self, java.util.regex.Pattern pattern, Closure closure)`
`static java.lang.String` | `find(java.lang.String self, java.util.regex.Pattern pattern)`
`static java.lang.String` | `find(java.lang.String self, java.util.regex.Pattern pattern, Closure closure)` Returns the result of calling a closure with the first occurrence of a compiled regular expression found within a String.
`static java.lang.String` | `find(java.lang.String self, java.lang.String regex)` Finds the first occurrence of a regular expression String within a String.
`static java.lang.String` | `find(java.lang.String self, java.lang.String regex, Closure closure)`
`static java.util.List` | `findAll(java.lang.CharSequence self, java.lang.CharSequence regex)`
`static java.util.List` | `findAll(java.lang.CharSequence self, java.lang.CharSequence regex, Closure closure)`
`static java.util.List` | `findAll(java.lang.CharSequence self, java.util.regex.Pattern pattern)`
`static java.util.List` | `findAll(java.lang.CharSequence self, java.util.regex.Pattern pattern, Closure closure)`
`static java.util.List` | `findAll(java.lang.String self, java.util.regex.Pattern pattern)`
`static java.util.List` | `findAll(java.lang.String self, java.util.regex.Pattern pattern, Closure closure)` Finds all occurrences of a compiled regular expression Pattern within a String.
`static java.util.List` | `findAll(java.lang.String self, java.lang.String regex)`
`static java.util.List` | `findAll(java.lang.String self, java.lang.String regex, Closure closure)`
`static java.lang.CharSequence` | `getAt(java.lang.CharSequence self, java.util.Collection indices)`
`static java.lang.CharSequence` | `getAt(java.lang.CharSequence text, EmptyRange range)` Support the range subscript operator for CharSequence or StringBuffer with EmptyRange
`static java.lang.CharSequence` | `getAt(java.lang.CharSequence text, int index)`
`static java.lang.CharSequence` | `getAt(java.lang.CharSequence text, IntRange range)`
`static java.lang.CharSequence` | `getAt(java.lang.CharSequence text, Range range)`
`static java.util.List` | `getAt(java.util.regex.Matcher self, java.util.Collection indices)` Select a List of values from a Matcher using a Collection to identify the indices to be selected.
`static java.lang.Object` | `getAt(java.util.regex.Matcher matcher, int idx)` Support the subscript operator, e.g.
`static java.lang.String` | `getAt(java.lang.String self, java.util.Collection indices)`
`static java.lang.String` | `getAt(java.lang.String text, EmptyRange range)`
`static java.lang.String` | `getAt(java.lang.String text, int index)`
`static java.lang.String` | `getAt(java.lang.String text, IntRange range)`
`static java.lang.String` | `getAt(java.lang.String text, Range range)`
`static char[]` | `getChars(java.lang.CharSequence self)` Converts the given CharSequence into an array of characters.
`static char[]` | `getChars(java.lang.String self)` Find the number of Strings matched to the given Matcher.
`static int` | `getCount(java.util.regex.Matcher matcher)`
`static boolean` | `hasGroup(java.util.regex.Matcher matcher)` Check whether a Matcher contains a group or not.
`static boolean` | `isAllWhitespace(java.lang.CharSequence self)`
`static boolean` | `isAllWhitespace(java.lang.String self)`
`static boolean` | `isBigDecimal(java.lang.CharSequence self)` Determine if a String can be parsed into a BigDecimal.
`static boolean` | `isBigDecimal(java.lang.String self)`
`static boolean` | `isBigInteger(java.lang.CharSequence self)` Determine if a String can be parsed into a BigInteger.
`static boolean` | `isBigInteger(java.lang.String self)`
`static boolean` | `isCase(java.lang.CharSequence caseValue, java.lang.Object switchValue)`
`static boolean` | `isCase(GString caseValue, java.lang.Object switchValue)`
`static boolean` | `isCase(java.util.regex.Pattern caseValue, java.lang.Object switchValue)`
`static boolean` | `isCase(java.lang.String caseValue, java.lang.Object switchValue)` 'Case' implementation for a String, which uses String#equals(Object) in order to allow Strings to be used in switch statements.
`static boolean` | `isDouble(java.lang.CharSequence self)` Determine if a String can be parsed into a Double.
`static boolean` | `isDouble(java.lang.String self)`
`static boolean` | `isFloat(java.lang.CharSequence self)` Determine if a String can be parsed into a Float.
`static boolean` | `isFloat(java.lang.String self)`
`static boolean` | `isInteger(java.lang.CharSequence self)` Determine if a String can be parsed into an Integer.
`static boolean` | `isInteger(java.lang.String self)`
`static boolean` | `isLong(java.lang.CharSequence self)` Determine if a String can be parsed into a Long.
`static boolean` | `isLong(java.lang.String self)`
`static boolean` | `isNumber(java.lang.CharSequence self)`
`static boolean` | `isNumber(java.lang.String self)`
`static java.util.Iterator` | `iterator(java.util.regex.Matcher matcher)`
`static java.lang.StringBuilder` | `leftShift(java.lang.CharSequence self, java.lang.Object value)` Overloads the left shift operator to provide an easy way to append multiple objects as string representations to a CharSequence.
`static java.lang.StringBuffer` | `leftShift(java.lang.String self, java.lang.Object value)` Overloads the left shift operator to provide an easy way to append multiple objects as string representations to a StringBuffer.
`static java.lang.StringBuffer` | `leftShift(java.lang.StringBuffer self, java.lang.Object value)` Overloads the left shift operator to provide syntactic sugar for appending to a StringBuilder.
`static java.lang.StringBuilder` | `leftShift(java.lang.StringBuilder self, java.lang.Object value)` Tells whether or not a CharSequence matches the given compiled regular expression Pattern.
`static boolean` | `matches(java.lang.CharSequence self, java.util.regex.Pattern pattern)` Tells whether or not self matches the given compiled regular expression Pattern.
`static boolean` | `matches(java.lang.String self, java.util.regex.Pattern pattern)` Remove a part of a CharSequence by replacing the first occurrence of target within self with '' and returns the result.
`static boolean` | `matchesPartially(java.util.regex.Matcher matcher)` Given a matcher that matches a string against a pattern, this method returns true when the string matches the pattern or if a longer string, could match the pattern.
`static java.lang.CharSequence` | `minus(java.lang.CharSequence self, java.lang.Object target)`
`static java.lang.String` | `minus(java.lang.String self, java.lang.Object target)`
`static java.lang.CharSequence` | `multiply(java.lang.CharSequence self, java.lang.Number factor)` Repeat a String a certain number of times.
`static java.lang.String` | `multiply(java.lang.String self, java.lang.Number factor)`
`static java.lang.CharSequence` | `next(java.lang.CharSequence self)` This method is called by the ++ operator for the class String.
`static java.lang.String` | `next(java.lang.String self)`
`static java.lang.CharSequence` | `normalize(java.lang.CharSequence self)` Return a CharSequence with linefeeds and carriage returns normalized to linefeeds.
`static java.lang.String` | `normalize(java.lang.String self)`
`static java.lang.CharSequence` | `padLeft(java.lang.CharSequence self, java.lang.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.
`static java.lang.CharSequence` | `padLeft(java.lang.CharSequence self, java.lang.Number numberOfChars, java.lang.CharSequence padding)`
`static java.lang.String` | `padLeft(java.lang.String self, java.lang.Number numberOfChars)`
`static java.lang.String` | `padLeft(java.lang.String self, java.lang.Number numberOfChars, java.lang.String padding)`
`static java.lang.CharSequence` | `padRight(java.lang.CharSequence self, java.lang.Number numberOfChars)` Pad a CharSequence to a minimum length specified by `numberOfChars`, adding the supplied padding CharSequence as many times as needed to the right.
`static java.lang.CharSequence` | `padRight(java.lang.CharSequence self, java.lang.Number numberOfChars, java.lang.CharSequence padding)`
`static java.lang.String` | `padRight(java.lang.String self, java.lang.Number numberOfChars)`
`static java.lang.String` | `padRight(java.lang.String self, java.lang.Number numberOfChars, java.lang.String padding)`
`static java.lang.CharSequence` | `plus(java.lang.CharSequence left, java.lang.Object value)` Appends a String to the string representation of this number.
`static java.lang.String` | `plus(java.lang.Number value, java.lang.String right)` Appends the String representation of the given operand to this string.
`static java.lang.String` | `plus(java.lang.String left, java.lang.Object value)` Appends a String to this StringBuffer.
`static java.lang.String` | `plus(java.lang.StringBuffer left, java.lang.String value)` This method is called by the -- operator for the class CharSequence.
`static java.lang.CharSequence` | `previous(java.lang.CharSequence self)` This method is called by the -- operator for the class String.
`static java.lang.String` | `previous(java.lang.String self)`
`static void` | `putAt(java.lang.StringBuffer self, EmptyRange range, java.lang.Object value)` Support the range subscript operator for StringBuffer.
`static void` | `putAt(java.lang.StringBuffer self, IntRange range, java.lang.Object value)` Return the lines of a CharSequence as a List of CharSequence.
`static java.util.List` | `readLines(java.lang.CharSequence self)` Return the lines of a String as a List of Strings.
`static java.util.List` | `readLines(java.lang.String self)` Replaces each substring of this CharSequence that matches the given regular expression with the given replacement.
`static java.lang.CharSequence` | `replaceAll(java.lang.CharSequence self, java.lang.CharSequence regex, java.lang.CharSequence replacement)` Replaces all occurrences of a captured group by the result of a closure on that text.
`static java.lang.CharSequence` | `replaceAll(java.lang.CharSequence self, java.lang.CharSequence regex, Closure closure)` Replaces all substrings of a CharSequence that match the given compiled regular expression with the given replacement.
`static java.lang.CharSequence` | `replaceAll(java.lang.CharSequence self, java.util.regex.Pattern pattern, java.lang.CharSequence replacement)` Replaces all occurrences of a captured group by the result of a closure call on that text.
`static java.lang.String` | `replaceAll(java.lang.CharSequence self, java.util.regex.Pattern pattern, Closure closure)`
`static java.lang.String` | `replaceAll(java.lang.String self, java.util.regex.Pattern pattern, Closure closure)`
`static java.lang.String` | `replaceAll(java.lang.String self, java.util.regex.Pattern pattern, java.lang.String replacement)`
`static java.lang.String` | `replaceAll(java.lang.String self, java.lang.String regex, Closure closure)` Replaces the first substring of this CharSequence that matches the given regular expression with the given replacement.
`static java.lang.String` | `replaceFirst(java.lang.CharSequence self, java.lang.CharSequence regex, java.lang.CharSequence replacement)` Replaces the first occurrence of a captured group by the result of a closure call on that text.
`static java.lang.String` | `replaceFirst(java.lang.CharSequence self, java.lang.CharSequence regex, Closure closure)` Replaces the first substring of a CharSequence that matches the given compiled regular expression with the given replacement.
`static java.lang.CharSequence` | `replaceFirst(java.lang.CharSequence self, java.util.regex.Pattern pattern, java.lang.CharSequence replacement)` Replaces the first occurrence of a captured group by the result of a closure call on that text.
`static java.lang.String` | `replaceFirst(java.lang.CharSequence self, java.util.regex.Pattern pattern, Closure closure)`
`static java.lang.String` | `replaceFirst(java.lang.String self, java.util.regex.Pattern pattern, Closure closure)`
`static java.lang.String` | `replaceFirst(java.lang.String self, java.util.regex.Pattern pattern, java.lang.String replacement)`
`static java.lang.String` | `replaceFirst(java.lang.String self, java.lang.String regex, Closure closure)` Creates a new CharSequence which is the reverse (backwards) of this string
`static java.lang.CharSequence` | `reverse(java.lang.CharSequence self)` Creates a new string which is the reverse (backwards) of this string
`static java.lang.String` | `reverse(java.lang.String self)` Set the position of the given Matcher to the given index.
`static void` | `setIndex(java.util.regex.Matcher matcher, int idx)`
`static int` | `size(java.lang.CharSequence text)` Provide the standard Groovy `size()` method for `CharSequence`.
`static long` | `size(java.util.regex.Matcher self)`
`static int` | `size(java.lang.String text)`
`static int` | `size(java.lang.StringBuffer buffer)`
`static java.lang.CharSequence[]` | `split(java.lang.CharSequence self)` Convenience method to split a GString (with whitespace as delimiter).
`static java.lang.String[]` | `split(GString self)` Convenience method to split a string (with whitespace as delimiter) Like tokenize, but returns an Array of Strings instead of a List
`static java.lang.String[]` | `split(java.lang.String self)`
`static java.lang.Object` | `splitEachLine(java.lang.CharSequence self, java.lang.CharSequence regex, Closure closure)`
`static java.lang.Object` | `splitEachLine(java.lang.CharSequence self, java.util.regex.Pattern pattern, Closure closure)`
`static java.lang.Object` | `splitEachLine(java.lang.String self, java.util.regex.Pattern pattern, Closure closure)`
`static java.lang.Object` | `splitEachLine(java.lang.String self, java.lang.String regex, Closure closure)`
`static java.lang.CharSequence` | `stripIndent(java.lang.CharSequence self)`
`static java.lang.CharSequence` | `stripIndent(java.lang.CharSequence self, int numChars)`
`static java.lang.String` | `stripIndent(java.lang.String self)`
`static java.lang.String` | `stripIndent(java.lang.String self, int numChars)`
`static java.lang.CharSequence` | `stripMargin(java.lang.CharSequence self)`
`static java.lang.CharSequence` | `stripMargin(java.lang.CharSequence self, char marginChar)`
`static java.lang.String` | `stripMargin(java.lang.CharSequence self, java.lang.CharSequence marginChar)`
`static java.lang.String` | `stripMargin(java.lang.String self)`
`static java.lang.String` | `stripMargin(java.lang.String self, char marginChar)`
`static java.lang.String` | `stripMargin(java.lang.String self, java.lang.String marginChar)`
`static java.lang.CharSequence` | `take(java.lang.CharSequence self, int num)`
`static java.lang.CharSequence` | `takeWhile(java.lang.CharSequence self, Closure condition)` Parse a CharSequence into a BigDecimal
`static java.math.BigDecimal` | `toBigDecimal(java.lang.CharSequence self)` Parse a String into a BigDecimal
`static java.math.BigDecimal` | `toBigDecimal(java.lang.String self)` Parse a String into a BigInteger
`static java.math.BigInteger` | `toBigInteger(java.lang.CharSequence self)` Converts the given string into a Boolean object.
`static java.math.BigInteger` | `toBigInteger(java.lang.String self)`
`static java.lang.Boolean` | `toBoolean(java.lang.String self)`
`static java.lang.Character` | `toCharacter(java.lang.String self)` Parse a String into a Double
`static java.lang.Double` | `toDouble(java.lang.CharSequence self)` Parse a CharSequence into a Float
`static java.lang.Double` | `toDouble(java.lang.String self)` Parse a String into a Float
`static java.lang.Float` | `toFloat(java.lang.CharSequence self)` Parse a CharSequence into an Integer
`static java.lang.Float` | `toFloat(java.lang.String self)` Parse a String into an Integer
`static java.lang.Integer` | `toInteger(java.lang.CharSequence self)` Tokenize a CharSequence (with a whitespace as the delimiter).
`static java.lang.Integer` | `toInteger(java.lang.String self)`
`static java.util.List` | `toList(java.lang.CharSequence self)`
`static java.util.List` | `toList(java.lang.String self)`
`static java.lang.Long` | `toLong(java.lang.CharSequence self)` Converts the given CharSequence into a Set of unique CharSequence of one character.
`static java.lang.Long` | `toLong(java.lang.String self)`
`static java.util.Set` | `toSet(java.lang.CharSequence self)`
`static java.util.Set` | `toSet(java.lang.String self)` Parse a String into a Short
`static java.lang.Short` | `toShort(java.lang.CharSequence self)`
`static java.lang.Short` | `toShort(java.lang.String self)`
`static java.util.List` | `tokenize(java.lang.CharSequence self)`
`static java.util.List` | `tokenize(java.lang.CharSequence self, java.lang.Character token)`
`static java.util.List` | `tokenize(java.lang.CharSequence self, java.lang.CharSequence token)`
`static java.util.List` | `tokenize(java.lang.String self)`
`static java.util.List` | `tokenize(java.lang.String self, java.lang.Character token)`
`static java.util.List` | `tokenize(java.lang.String self, java.lang.String token)` Converts the given String into a List of strings of one character.
`static java.lang.CharSequence` | `tr(java.lang.CharSequence self, java.lang.CharSequence sourceSet, java.lang.CharSequence replacementSet)`
`static java.lang.String` | `tr(java.lang.String self, java.lang.String sourceSet, java.lang.String replacementSet)` Replaces sequences of whitespaces with tabs using tabStops of size 8.
`static java.lang.CharSequence` | `unexpand(java.lang.CharSequence self)`
`static java.lang.CharSequence` | `unexpand(java.lang.CharSequence self, int tabStop)` Replaces sequences of whitespaces with tabs.
`static java.lang.String` | `unexpand(java.lang.String self)`
`static java.lang.String` | `unexpand(java.lang.String self, int tabStop)`
`static java.lang.CharSequence` | `unexpandLine(java.lang.CharSequence self, int tabStop)` Replaces sequences of whitespaces with tabs within a line.
`static java.lang.String` | `unexpandLine(java.lang.String self, int tabStop)`

Methods inherited from class DefaultGroovyMethodsSupport
cloneSimilarCollection, cloneSimilarMap, closeQuietly, closeWithWarning, createSimilarArray, createSimilarCollection, createSimilarCollection, createSimilarList, createSimilarMap, createSimilarOrDefaultCollection, createSimilarSet, normaliseIndex, sameType, subListBorders, subListBorders

Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Method Detail

### asBoolean

    public static boolean asBoolean(java.lang.CharSequence string)

  Coerce a string (an instance of CharSequence) to a boolean value. A string is coerced to false if it is of length 0, and to true otherwise.
  Parameters:
    `string` - the character sequence
  Returns:
    the boolean value
  Since:
    1.7.0

### asBoolean

    public static boolean asBoolean(java.util.regex.Matcher matcher)

  Coerce a Matcher instance to a boolean value.
  Parameters:
    `matcher` - the matcher
  Returns:
    the boolean value
  Since:
    1.7.0

### asType

    public static java.lang.Object asType(java.lang.CharSequence self, java.lang.Class c)

  Provides a method to perform custom 'dynamic' type conversion to the given class using the `as` operator.

  Parameters:
    `self` - a CharSequence
    `c` - the desired class
  Returns:
    the converted object
  See Also:
    asType(String, Class)
  Since:
    1.8.2

### asType

    @SuppressWarnings("unchecked")
    public static java.lang.Object asType(GString self, java.lang.Class c)

  Converts the GString to a File, or delegates to the default DefaultGroovyMethods.asType
  Parameters:
    `self` - a GString
    `c` - the desired class
  Returns:
    the converted object
  Since:
    1.5.0

### asType

    @SuppressWarnings("unchecked")
    public static java.lang.Object asType(java.lang.String self, java.lang.Class c)

  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:

  - List
  - BigDecimal
  - BigInteger
  - Long
  - Integer
  - Short
  - Byte
  - Character
  - Double
  - Float
  - File
  - Subclasses of Enum (Java 5 and above)
  If any other type is given, the call is delegated to DefaultGroovyMethods.asType.
  Parameters:
    `self` - a String
    `c` - the desired class
  Returns:
    the converted object
  Since:
    1.0

### bitwiseNegate

    public static java.util.regex.Pattern bitwiseNegate(java.lang.CharSequence self)

  Turns a CharSequence into a regular expression Pattern
  Parameters:
    `self` - a String to convert into a regular expression
  Returns:
    the regular expression pattern
  Since:
    1.8.2

### bitwiseNegate

    public static java.util.regex.Pattern bitwiseNegate(java.lang.String self)

  Turns a String into a regular expression Pattern
  Parameters:
    `self` - a String to convert into a regular expression
  Returns:
    the regular expression pattern
  Since:
    1.5.0

### capitalize

    public static java.lang.CharSequence capitalize(java.lang.CharSequence self)

  Convenience method to capitalize the first letter of a CharSequence.
  Parameters:
    `self` - The CharSequence to capitalize
  Returns:
    The capitalized CharSequence
  See Also:
    capitalize(String)
  Since:
    1.8.2

### capitalize

    public static java.lang.String capitalize(java.lang.String self)

  Convenience method to capitalize the first letter of a string (typically the first letter of a word). Example usage:

       assert 'h'.capitalize() == 'H'
       assert 'hello'.capitalize() == 'Hello'
       assert 'hello world'.capitalize() == 'Hello world'
       assert 'Hello World' ==
           'hello world'.split(' ').collect{ it.capitalize() }.join(' ')

  Parameters:
    `self` - The string to capitalize
  Returns:
    The capitalized String
  Since:
    1.7.3

### center

    public static java.lang.CharSequence center(java.lang.CharSequence self, java.lang.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.
  Parameters:
    `self` - a CharSequence object
    `numberOfChars` - the total minimum number of characters of the resulting CharSequence
  Returns:
    the CharSequence centered with padded characters around it
  See Also:
    center(String, Number)
  Since:
    1.8.2

### center

    public static java.lang.CharSequence center(java.lang.CharSequence self, java.lang.Number numberOfChars, java.lang.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.
  Parameters:
    `self` - a CharSequence object
    `numberOfChars` - the total minimum number of characters of the resulting CharSequence
    `padding` - the characters used for padding
  Returns:
    the CharSequence centered with padded characters around it
  See Also:
    center(String, Number, String)
  Since:
    1.8.2

### center

    public static java.lang.String center(java.lang.String self, java.lang.Number numberOfChars)

  Pad a String to a minimum length specified by `numberOfChars` by adding the space character around it as many times as needed so that it remains centered. If the String is already the same size or bigger than the target `numberOfChars`, then the original String is returned. An example:

       ['A', 'BB', 'CCC', 'DDDD'].each{ println '|' + it.center(6) + '|' }

  will produce output like:

       |  A   |
       |  BB  |
       | CCC  |
       | DDDD |

  Parameters:
    `self` - a String object
    `numberOfChars` - the total minimum number of characters of the resulting string
  Returns:
    the String centered with padded characters around it
  See Also:
    center(String, Number, String)
  Since:
    1.0

### center

    public static java.lang.String center(java.lang.String self, java.lang.Number numberOfChars, java.lang.String padding)

  Pad a String to a minimum length specified by `numberOfChars`, appending the supplied padding String around the original as many times as needed keeping it centered. If the String is already the same size or bigger than the target `numberOfChars`, then the original String is returned. An example:

       ['A', 'BB', 'CCC', 'DDDD'].each{ println '|' + it.center(6, '+') + '|' }

  will produce output like:

       |++A+++|
       |++BB++|
       |+CCC++|
       |+DDDD+|

  Parameters:
    `self` - a String object
    `numberOfChars` - the total minimum number of characters of the resulting string
    `padding` - the characters used for padding
  Returns:
    the String centered with padded characters around it
  Since:
    1.0

### contains

    public static boolean contains(java.lang.CharSequence self, java.lang.CharSequence text)

  Provide an implementation of contains() like java.util.Collection#contains(Object) to make CharSequences more polymorphic.
  Parameters:
    `self` - a CharSequence
    `text` - the CharSequence to look for
  Returns:
    true if this CharSequence contains the given text
  See Also:
    contains(String, String)
  Since:
    1.8.2

### contains

    public static boolean contains(java.lang.String self, java.lang.String text)

  Provide an implementation of contains() like java.util.Collection#contains(Object) to make Strings more polymorphic. This method is not required on JDK 1.5 onwards
  Parameters:
    `self` - a String
    `text` - a String to look for
  Returns:
    true if this string contains the given text
  Since:
    1.0

### count

    public static int count(java.lang.CharSequence self, java.lang.CharSequence text)

  Count the number of occurrences of a sub CharSequence.
  Parameters:
    `self` - a CharSequence
    `text` - a sub CharSequence
  Returns:
    the number of occurrences of the given CharSequence inside this CharSequence
  See Also:
    count(String, String)
  Since:
    1.8.2

### count

    public static int count(java.lang.String self, java.lang.String text)

  Count the number of occurrences of a substring.
  Parameters:
    `self` - a String
    `text` - a substring
  Returns:
    the number of occurrences of the given string inside this String
  Since:
    1.0

### denormalize

    public static java.lang.CharSequence denormalize(java.lang.CharSequence self)

  Return a CharSequence with lines (separated by LF, CR/LF, or CR) terminated by the platform specific line separator.
  Parameters:
    `self` - a CharSequence object
  Returns:
    the denormalized CharSequence
  See Also:
    denormalize(String)
  Since:
    1.8.2

### denormalize

    public static java.lang.String denormalize(java.lang.String self)

  Return a String with lines (separated by LF, CR/LF, or CR) terminated by the platform specific line separator.
  Parameters:
    `self` - a String object
  Returns:
    the denormalized string
  Since:
    1.6.0

### drop

    public static java.lang.CharSequence drop(java.lang.CharSequence self, int num)

  Drops the given number of chars from the head of this CharSequence if they are available.

           def text = "Groovy"
           assert text.drop( 0 ) == 'Groovy'
           assert text.drop( 2 ) == 'oovy'
           assert text.drop( 7 ) == ''

  Parameters:
    `self` - the original CharSequence
    `num` - the number of characters to drop from this iterator
  Returns:
    a CharSequence consisting of all characters except the first `num` ones, or else an empty String, if this CharSequence has less than `num` characters.
  Since:
    1.8.1

### dropWhile

    public static java.lang.CharSequence dropWhile(java.lang.CharSequence self, 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.

       def text = "Groovy"
       assert text.dropWhile{ false } == 'Groovy'
       assert text.dropWhile{ true } == ''
       assert text.dropWhile{ it < 'Z' } == 'roovy'
       assert text.dropWhile{ it != 'v' } == 'vy'

  Parameters:
    `self` - the original CharSequence
    `condition` - the closure that while continuously evaluating to true will cause us to drop elements from the front of the original CharSequence
  Returns:
    the shortest suffix of the given CharSequence such that the given closure condition evaluates to true for each element dropped from the front of the CharSequence
  Since:
    2.0.0

### eachLine

    public static java.lang.Object eachLine(java.lang.CharSequence self, Closure closure)

  Iterates through this CharSequence line by line. Each line is passed to the given 1 or 2 arg closure. If a 2 arg closure is found the line count is passed as the second argument.
  throws:
    java.io.IOException if an error occurs
  Parameters:
    `self` - a CharSequence
    `closure` - a closure
  Returns:
    the last value returned by the closure
  See Also:
    eachLine(String, groovy.lang.Closure)
  Since:
    1.8.2

### eachLine

    public static java.lang.Object eachLine(java.lang.CharSequence self, int firstLine, Closure closure)

### eachLine

    public static java.lang.Object eachLine(java.lang.String self, Closure closure)

### eachLine

    public static java.lang.Object eachLine(java.lang.String self, int firstLine, Closure closure)

### eachMatch

    public static java.lang.String eachMatch(java.lang.CharSequence self, java.lang.CharSequence regex, Closure closure)

  Process each regex group matched substring of the given CharSequence. 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.
  Parameters:
    `self` - the source CharSequence
    `regex` - a Regex CharSequence
    `closure` - a closure with one parameter or as much parameters as groups
  Returns:
    the source CharSequence
  See Also:
    eachMatch(String, String, groovy.lang.Closure)
  Since:
    1.8.2

### eachMatch

    public static java.lang.String eachMatch(java.lang.CharSequence self, java.util.regex.Pattern pattern, Closure closure)

### eachMatch

    public static java.lang.String eachMatch(java.lang.String self, java.util.regex.Pattern pattern, Closure closure)

### eachMatch

    public static java.lang.String eachMatch(java.lang.String self, java.lang.String regex, Closure closure)

### expand

    public static java.lang.CharSequence expand(java.lang.CharSequence self)

### expand

    public static java.lang.CharSequence expand(java.lang.CharSequence self, int tabStop)

### expand

    public static java.lang.String expand(java.lang.String self)

### expand

    public static java.lang.String expand(java.lang.String self, int tabStop)

### expandLine

    public static java.lang.CharSequence expandLine(java.lang.CharSequence self, int tabStop)

  Expands all tabs into spaces. Assumes the CharSequence represents a single line of text.
  Parameters:
    `self` - A line to expand
    `tabStop` - The number of spaces a tab represents
  Returns:
    The expanded CharSequence
  See Also:
    expandLine(String, int)
  Since:
    1.8.2

### expandLine

    public static java.lang.String expandLine(java.lang.String self, int tabStop)

### find

    public static java.lang.CharSequence find(java.lang.CharSequence self, java.lang.CharSequence regex)

  Finds the first occurrence of a regular expression CharSequence within a CharSequence.
  Parameters:
    `self` - a CharSequence
    `regex` - the capturing regex
  Returns:
    a CharSequence containing the matched portion, or null if the regex doesn't match
  See Also:
    find(String, java.util.regex.Pattern)
  Since:
    1.8.2

### find

    public static java.lang.CharSequence find(java.lang.CharSequence self, java.lang.CharSequence regex, Closure closure)

### find

    public static java.lang.CharSequence find(java.lang.CharSequence self, java.util.regex.Pattern pattern)

### find

    public static java.lang.CharSequence find(java.lang.CharSequence self, java.util.regex.Pattern pattern, Closure closure)

### find

    public static java.lang.String find(java.lang.String self, java.util.regex.Pattern pattern)

### find

    public static java.lang.String find(java.lang.String self, java.util.regex.Pattern pattern, Closure closure)

  Returns the result of calling a closure with the first occurrence of a compiled regular expression found within a String. If the regex doesn't match, the closure will not be called and find will return null.

  For example, if the pattern doesn't match, the result is null:

           assert null == "New York, NY".find(~/\d{5}/) { match -> return "-$match-"}

  If it does match and we don't have any capture groups in our regex, there is a single parameter on the closure that the match gets passed to:

            assert "-10292-" == "New York, NY 10292-0098".find(~/\d{5}/) { match -> return "-$match-"}

  If we have capture groups in our expression, our closure has one parameter for the match, followed by one for each of the capture groups:

            assert "10292" == "New York, NY 10292-0098".find(~/(\d{5})-?(\d{4})/) { match, zip, plusFour ->
                assert match == "10292-0098"
                assert zip == "10292"
                assert plusFour == "0098"
                return zip
            }

  If we have capture groups in our expression, and our closure has one parameter, the closure will be passed an array with the first element corresponding to the whole match, followed by an element for each of the capture groups:

            assert "10292" == "New York, NY 10292-0098".find(~/(\d{5})-?(\d{4})/) { match, zip, plusFour ->
                assert array[0] == "10292-0098"
                assert array[1] == "10292"
                assert array[2] == "0098"
                return array[1]
            }

  If a capture group is optional, and doesn't match, then the corresponding value for that capture group passed to the closure will be null as illustrated here:

            assert "2339999" == "adsf 233-9999 adsf".find(~/(\d{3})?-?(\d{3})-(\d{4})/) { match, areaCode, exchange, stationNumber ->
                assert "233-9999" == match
                assert null == areaCode
                assert "233" == exchange
                assert "9999" == stationNumber
                return "$exchange$stationNumber"
            }

  Parameters:
    `self` - a String
    `pattern` - the compiled regex Pattern
    `closure` - the closure that will be passed the full match, plus each of the capturing groups
  Returns:
    a String containing the result of the closure, or null if the regex pattern doesn't match
  Since:
    1.6.1

### find

    public static java.lang.String find(java.lang.String self, java.lang.String regex)

  Finds the first occurrence of a regular expression String within a String. If the regex doesn't match, null will be returned.

  For example, if the regex doesn't match the result is null:

           assert null == "New York, NY".find(/\d{5}/)

  If it does match, we get the matching string back:

            assert "10292" == "New York, NY 10292-0098".find(/\d{5}/)

  If we have capture groups in our expression, we still get back the full match

            assert "10292-0098" == "New York, NY 10292-0098".find(/(\d{5})-?(\d{4})/)

  Parameters:
    `self` - a String
    `regex` - the capturing regex
  Returns:
    a String containing the matched portion, or null if the regex doesn't match
  Since:
    1.6.1

### find

    public static java.lang.String find(java.lang.String self, java.lang.String regex, Closure closure)

### findAll

    public static java.util.List findAll(java.lang.CharSequence self, java.lang.CharSequence regex)

### findAll

    public static java.util.List findAll(java.lang.CharSequence self, java.lang.CharSequence regex, Closure closure)

### findAll

    public static java.util.List findAll(java.lang.CharSequence self, java.util.regex.Pattern pattern)

### findAll

    public static java.util.List findAll(java.lang.CharSequence self, java.util.regex.Pattern pattern, Closure closure)

### findAll

    public static java.util.List findAll(java.lang.String self, java.util.regex.Pattern pattern)

### findAll

    public static java.util.List findAll(java.lang.String self, java.util.regex.Pattern pattern, Closure closure)

  Finds all occurrences of a compiled regular expression Pattern within a String. Any matches are passed to the specified closure. The closure is expected to have the full match in the first parameter. If there are any capture groups, they will be placed in subsequent parameters.

  If there are no matches, the closure will not be called, and an empty List will be returned.

  For example, if the pattern doesn't match, it returns an empty list:

       assert [] == "foo".findAll(~/(\w*) Fish/) { match, firstWord -> return firstWord }

  Any regular expression matches are passed to the closure, if there are no capture groups, there will be one parameter for the match:

       assert ["couldn't", "wouldn't"] == "I could not, would not, with a fox.".findAll(~/.ould/) { match -> "${match}n't"}

  If there are capture groups, the first parameter will be the match followed by one parameter for each capture group:

       def orig = "There's a Wocket in my Pocket"
       assert ["W > Wocket", "P > Pocket"] == orig.findAll(~/(.)ocket/) { match, firstLetter -> "$firstLetter > $match" }

  Parameters:
    `self` - a String
    `pattern` - the compiled regex Pattern
    `closure` - will be passed the full match plus each of the capturing groups
  Returns:
    a List containing all full matches of the regex Pattern within the string, an empty list will be returned if there are no matches
  Since:
    1.6.1

### findAll

    public static java.util.List findAll(java.lang.String self, java.lang.String regex)

### findAll

    public static java.util.List findAll(java.lang.String self, java.lang.String regex, Closure closure)

### getAt

    public static java.lang.CharSequence getAt(java.lang.CharSequence self, java.util.Collection indices)

### getAt

    public static java.lang.CharSequence getAt(java.lang.CharSequence text, EmptyRange range)

  Support the range subscript operator for CharSequence or StringBuffer with EmptyRange
  Parameters:
    `text` - a CharSequence
    `range` - an EmptyRange
  Returns:
    the subsequence CharSequence
  Since:
    1.5.0

### getAt

    public static java.lang.CharSequence getAt(java.lang.CharSequence text, int index)

### getAt

    public static java.lang.CharSequence getAt(java.lang.CharSequence text, IntRange range)

### getAt

    public static java.lang.CharSequence getAt(java.lang.CharSequence text, Range range)

### getAt

    public static java.util.List getAt(java.util.regex.Matcher self, java.util.Collection indices)

  Select a List of values from a Matcher using a Collection to identify the indices to be selected.
  Parameters:
    `self` - a Matcher
    `indices` - a Collection of indices
  Returns:
    a String of the values at the given indices
  Since:
    1.6.0

### getAt

    public static java.lang.Object getAt(java.util.regex.Matcher matcher, int idx)

  Support the subscript operator, e.g. matcher[index], for a regex Matcher.

  For an example using no group match,

          def p = /ab[d|f]/
          def m = "abcabdabeabf" =~ p
          assert 2 == m.count
          assert 2 == m.size() // synonym for m.getCount()
          assert ! m.hasGroup()
          assert 0 == m.groupCount()
          def matches = ["abd", "abf"]
          for (i in 0..<m.count) {
            assert m[i] == matches[i]
          }

  For an example using group matches,

          def p = /(?:ab([c|d|e|f]))/
          def m = "abcabdabeabf" =~ p
          assert 4 == m.count
          assert m.hasGroup()
          assert 1 == m.groupCount()
          def matches = [["abc", "c"], ["abd", "d"], ["abe", "e"], ["abf", "f"]]
          for (i in 0..<m.count) {
            assert m[i] == matches[i]
          }

  For another example using group matches,

          def m = "abcabdabeabfabxyzabx" =~ /(?:ab([d|x-z]+))/
          assert 3 == m.count
          assert m.hasGroup()
          assert 1 == m.groupCount()
          def matches = [["abd", "d"], ["abxyz", "xyz"], ["abx", "x"]]
          for (i in 0..<m.count) {
            assert m[i] == matches[i]
          }

  Parameters:
    `matcher` - a Matcher
    `idx` - an index
  Returns:
    object a matched String if no groups matched, list of matched groups otherwise.
  Since:
    1.0

### getAt

    public static java.lang.String getAt(java.lang.String self, java.util.Collection indices)

### getAt

    public static java.lang.String getAt(java.lang.String text, EmptyRange range)

### getAt

    public static java.lang.String getAt(java.lang.String text, int index)

### getAt

    public static java.lang.String getAt(java.lang.String text, IntRange range)

### getAt

    public static java.lang.String getAt(java.lang.String text, Range range)

### getChars

    public static char[] getChars(java.lang.CharSequence self)

  Converts the given CharSequence into an array of characters.
  Parameters:
    `self` - a CharSequence
  Returns:
    an array of characters
  See Also:
    getChars(String)
  Since:
    1.8.2

### getChars

    public static char[] getChars(java.lang.String self)

  Find the number of Strings matched to the given Matcher.
  Parameters:
    `matcher` - a Matcher
  Returns:
    int the number of Strings matched to the given matcher.
  Since:
    1.0

### getCount

    public static int getCount(java.util.regex.Matcher matcher)

### hasGroup

    public static boolean hasGroup(java.util.regex.Matcher matcher)

  Check whether a Matcher contains a group or not.
  Parameters:
    `matcher` - a Matcher
  Returns:
    boolean `true` if matcher contains at least one group.
  Since:
    1.0

### isAllWhitespace

    public static boolean isAllWhitespace(java.lang.CharSequence self)

### isAllWhitespace

    public static boolean isAllWhitespace(java.lang.String self)

### isBigDecimal

    public static boolean isBigDecimal(java.lang.CharSequence self)

  Determine if a String can be parsed into a BigDecimal.
  Parameters:
    `self` - a String
  Returns:
    true if the string can be parsed
  Since:
    1.5.0

### isBigDecimal

    public static boolean isBigDecimal(java.lang.String self)

### isBigInteger

    public static boolean isBigInteger(java.lang.CharSequence self)

  Determine if a String can be parsed into a BigInteger.
  Parameters:
    `self` - a String
  Returns:
    true if the string can be parsed
  Since:
    1.5.0

### isBigInteger

    public static boolean isBigInteger(java.lang.String self)

### isCase

    public static boolean isCase(java.lang.CharSequence caseValue, java.lang.Object switchValue)

### isCase

    public static boolean isCase(GString caseValue, java.lang.Object switchValue)

### isCase

    public static boolean isCase(java.util.regex.Pattern caseValue, java.lang.Object switchValue)

### isCase

    public static boolean isCase(java.lang.String caseValue, java.lang.Object switchValue)

  'Case' implementation for a String, which uses String#equals(Object) in order to allow Strings to be used in switch statements. For example:

      switch( str ) {
         case 'one' :
         // etc...
       }

  Note that this returns `true` for the case where both the 'switch' and 'case' operand is `null`.
  Parameters:
    `caseValue` - the case value
    `switchValue` - the switch value
  Returns:
    true if the switchValue's toString() equals the caseValue
  Since:
    1.0

### isDouble

    public static boolean isDouble(java.lang.CharSequence self)

  Determine if a String can be parsed into a Double.
  Parameters:
    `self` - a String
  Returns:
    true if the string can be parsed
  Since:
    1.5.0

### isDouble

    public static boolean isDouble(java.lang.String self)

### isFloat

    public static boolean isFloat(java.lang.CharSequence self)

  Determine if a String can be parsed into a Float.
  Parameters:
    `self` - a String
  Returns:
    true if the string can be parsed
  Since:
    1.5.0

### isFloat

    public static boolean isFloat(java.lang.String self)

### isInteger

    public static boolean isInteger(java.lang.CharSequence self)

  Determine if a String can be parsed into an Integer.
  Parameters:
    `self` - a String
  Returns:
    true if the string can be parsed
  Since:
    1.5.0

### isInteger

    public static boolean isInteger(java.lang.String self)

### isLong

    public static boolean isLong(java.lang.CharSequence self)

  Determine if a String can be parsed into a Long.
  Parameters:
    `self` - a String
  Returns:
    true if the string can be parsed
  Since:
    1.5.0

### isLong

    public static boolean isLong(java.lang.String self)

### isNumber

    public static boolean isNumber(java.lang.CharSequence self)

### isNumber

    public static boolean isNumber(java.lang.String self)

### iterator

    public static java.util.Iterator iterator(java.util.regex.Matcher matcher)

### leftShift

    public static java.lang.StringBuilder leftShift(java.lang.CharSequence self, java.lang.Object value)

  Overloads the left shift operator to provide an easy way to append multiple objects as string representations to a CharSequence.
  Parameters:
    `self` - a CharSequence
    `value` - an Object
  Returns:
    a StringBuilder built from this CharSequence
  Since:
    1.8.2

### leftShift

    public static java.lang.StringBuffer leftShift(java.lang.String self, java.lang.Object value)

  Overloads the left shift operator to provide an easy way to append multiple objects as string representations to a StringBuffer.
  Parameters:
    `self` - a StringBuffer
    `value` - a value to append
  Returns:
    the StringBuffer on which this operation was invoked
  Since:
    1.0

### leftShift

    public static java.lang.StringBuffer leftShift(java.lang.StringBuffer self, java.lang.Object value)

  Overloads the left shift operator to provide syntactic sugar for appending to a StringBuilder.
  Parameters:
    `self` - a StringBuilder
    `value` - an Object
  Returns:
    the original StringBuilder
  Since:
    1.8.2

### leftShift

    public static java.lang.StringBuilder leftShift(java.lang.StringBuilder self, java.lang.Object value)

  Tells whether or not a CharSequence matches the given compiled regular expression Pattern.
  Parameters:
    `self` - the CharSequence that is to be matched
    `pattern` - the regex Pattern to which the string of interest is to be matched
  Returns:
    true if the CharSequence matches
  See Also:
    java.lang.String#matches(java.lang.String)
  Since:
    1.8.2

### matches

    public static boolean matches(java.lang.CharSequence self, java.util.regex.Pattern pattern)

  Tells whether or not self matches the given compiled regular expression Pattern.
  Parameters:
    `self` - the string that is to be matched
    `pattern` - the regex Pattern to which the string of interest is to be matched
  Returns:
    true if the string matches
  See Also:
    java.lang.String#matches(java.lang.String)
  Since:
    1.6.1

### matches

    public static boolean matches(java.lang.String self, java.util.regex.Pattern pattern)

  Remove a part of a CharSequence by replacing the first occurrence of target within self with '' and returns the result.
  Parameters:
    `self` - a CharSequence
    `target` - an object representing the part to remove
  Returns:
    a CharSequence minus the part to be removed
  See Also:
    minus(String, Object)
  Since:
    1.8.2

### matchesPartially

    public static boolean matchesPartially(java.util.regex.Matcher matcher)

  Given a matcher that matches a string against a pattern, this method returns true when the string matches the pattern or if a longer string, could match the pattern. For example:

           def emailPattern = /\w+@\w+\.\w{2,}/

           def matcher = "john@doe" =~ emailPattern
           assert matcher.matchesPartially()

           matcher = "john@doe.com" =~ emailPattern
           assert matcher.matchesPartially()

           matcher = "john@@" =~ emailPattern
           assert !matcher.matchesPartially()

  Parameters:
    `matcher` - the Matcher
  Returns:
    true if more input to the String could make the matcher match the associated pattern, false otherwise.
  Since:
    2.0.0

### minus

    public static java.lang.CharSequence minus(java.lang.CharSequence self, java.lang.Object target)

### minus

    public static java.lang.String minus(java.lang.String self, java.lang.Object target)

### multiply

    public static java.lang.CharSequence multiply(java.lang.CharSequence self, java.lang.Number factor)

  Repeat a String a certain number of times.
  throws:
    IllegalArgumentException if the number of repetitions is < 0
  Parameters:
    `self` - a String to be repeated
    `factor` - the number of times the String should be repeated
  Returns:
    a String composed of a repetition
  Since:
    1.0

### multiply

    public static java.lang.String multiply(java.lang.String self, java.lang.Number factor)

### next

    public static java.lang.CharSequence next(java.lang.CharSequence self)

  This method is called by the ++ operator for the class String. It increments the last character in the given string. If the character in the string is Character.MAX_VALUE a Character.MIN_VALUE will be appended. The empty string is incremented to a string consisting of the character Character.MIN_VALUE.
  Parameters:
    `self` - a String
  Returns:
    an incremented String
  Since:
    1.0

### next

    public static java.lang.String next(java.lang.String self)

### normalize

    public static java.lang.CharSequence normalize(java.lang.CharSequence self)

  Return a CharSequence with linefeeds and carriage returns normalized to linefeeds.
  Parameters:
    `self` - a CharSequence object
  Returns:
    the normalized CharSequence
  See Also:
    normalize(String)
  Since:
    1.8.2

### normalize

    public static java.lang.String normalize(java.lang.String self)

### padLeft

    public static java.lang.CharSequence padLeft(java.lang.CharSequence self, java.lang.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.
  Parameters:
    `self` - a CharSequence object
    `numberOfChars` - the total minimum number of characters of the resulting CharSequence
  Returns:
    the CharSequence padded to the left
  See Also:
    padLeft(CharSequence, Number, CharSequence)
  Since:
    1.8.2

### padLeft

    public static java.lang.CharSequence padLeft(java.lang.CharSequence self, java.lang.Number numberOfChars, java.lang.CharSequence padding)

### padLeft

    public static java.lang.String padLeft(java.lang.String self, java.lang.Number numberOfChars)

### padLeft

    public static java.lang.String padLeft(java.lang.String self, java.lang.Number numberOfChars, java.lang.String padding)

### padRight

    public static java.lang.CharSequence padRight(java.lang.CharSequence self, java.lang.Number numberOfChars)

  Pad a CharSequence to a minimum length specified by `numberOfChars`, adding the supplied padding CharSequence as many times as needed to the right.
  Parameters:
    `self` - a CharSequence object
    `numberOfChars` - the total minimum number of characters of the resulting CharSequence
    `padding` - the characters used for padding
  Returns:
    the CharSequence padded to the right
  See Also:
    padRight(String, Number, String)
  Since:
    1.8.2

### padRight

    public static java.lang.CharSequence padRight(java.lang.CharSequence self, java.lang.Number numberOfChars, java.lang.CharSequence padding)

### padRight

    public static java.lang.String padRight(java.lang.String self, java.lang.Number numberOfChars)

### padRight

    public static java.lang.String padRight(java.lang.String self, java.lang.Number numberOfChars, java.lang.String padding)

### plus

    public static java.lang.CharSequence plus(java.lang.CharSequence left, java.lang.Object value)

  Appends a String to the string representation of this number.
  Parameters:
    `value` - a Number
    `right` - a String
  Returns:
    a String
  Since:
    1.0

### plus

    public static java.lang.String plus(java.lang.Number value, java.lang.String right)

  Appends the String representation of the given operand to this string.
  Parameters:
    `left` - a String
    `value` - any Object
  Returns:
    the new string with the object appended
  Since:
    1.0

### plus

    public static java.lang.String plus(java.lang.String left, java.lang.Object value)

  Appends a String to this StringBuffer.
  Parameters:
    `left` - a StringBuffer
    `value` - a String
  Returns:
    a String
  Since:
    1.0

### plus

    public static java.lang.String plus(java.lang.StringBuffer left, java.lang.String value)

  This method is called by the -- operator for the class CharSequence.
  Parameters:
    `self` - a CharSequence
  Returns:
    a CharSequence with a decremented digit at the end
  See Also:
    previous(String)
  Since:
    1.8.2

### previous

    public static java.lang.CharSequence previous(java.lang.CharSequence self)

  This method is called by the -- operator for the class String. It decrements the last character in the given string. If the character in the string is Character.MIN_VALUE it will be deleted. The empty string can't be decremented.
  Parameters:
    `self` - a String
  Returns:
    a String with a decremented digit at the end
  Since:
    1.0

### previous

    public static java.lang.String previous(java.lang.String self)

### putAt

    public static void putAt(java.lang.StringBuffer self, EmptyRange range, java.lang.Object value)

  Support the range subscript operator for StringBuffer. Index values are treated as characters within the buffer.
  Parameters:
    `self` - a StringBuffer
    `range` - a Range
    `value` - the object that's toString() will be inserted
  Since:
    1.0

### putAt

    public static void putAt(java.lang.StringBuffer self, IntRange range, java.lang.Object value)

  Return the lines of a CharSequence as a List of CharSequence.
  throws:
    java.io.IOException if an error occurs
  Parameters:
    `self` - a CharSequence object
  Returns:
    a list of lines
  Since:
    1.8.2

### readLines

    public static java.util.List readLines(java.lang.CharSequence self)

  Return the lines of a String as a List of Strings.
  throws:
    java.io.IOException if an error occurs
  Parameters:
    `self` - a String object
  Returns:
    a list of lines
  Since:
    1.5.5

### readLines

    public static java.util.List readLines(java.lang.String self)

  Replaces each substring of this CharSequence that matches the given regular expression with the given replacement.
  throws:
    java.util.regex.PatternSyntaxException if the regular expression's syntax is invalid
  Parameters:
    `self` - a CharSequence
    `regex` - the capturing regex
    `replacement` - the capturing regex
  Returns:
    a CharSequence with replaced content
  See Also:
    java.lang.String#replaceAll(java.lang.String, java.lang.String)
  Since:
    1.8.2

### replaceAll

    public static java.lang.CharSequence replaceAll(java.lang.CharSequence self, java.lang.CharSequence regex, java.lang.CharSequence replacement)

  Replaces all occurrences of a captured group by the result of a closure on that text.
  throws:
    java.util.regex.PatternSyntaxException if the regular expression's syntax is invalid
  Parameters:
    `self` - a CharSequence
    `regex` - the capturing regex
    `closure` - the closure to apply on each captured group
  Returns:
    a CharSequence with replaced content
  See Also:
    replaceAll(String, java.util.regex.Pattern, groovy.lang.Closure)
  Since:
    1.8.2

### replaceAll

    public static java.lang.CharSequence replaceAll(java.lang.CharSequence self, java.lang.CharSequence regex, Closure closure)

  Replaces all substrings of a CharSequence that match the given compiled regular expression with the given replacement.
  Parameters:
    `self` - the CharSequence that is to be matched
    `pattern` - the regex Pattern to which the CharSequence of interest is to be matched
    `replacement` - the CharSequence to be substituted for the first match
  Returns:
    The resulting `CharSequence`
  See Also:
    replaceAll(String, java.util.regex.Pattern, String)
  Since:
    1.8.2

### replaceAll

    public static java.lang.CharSequence replaceAll(java.lang.CharSequence self, java.util.regex.Pattern pattern, java.lang.CharSequence replacement)

  Replaces all occurrences of a captured group by the result of a closure call on that text.
  Parameters:
    `self` - a CharSequence
    `pattern` - the capturing regex Pattern
    `closure` - the closure to apply on each captured group
  Returns:
    a CharSequence with replaced content
  See Also:
    replaceAll(String, java.util.regex.Pattern, groovy.lang.Closure)
  Since:
    1.8.2

### replaceAll

    public static java.lang.String replaceAll(java.lang.CharSequence self, java.util.regex.Pattern pattern, Closure closure)

### replaceAll

    public static java.lang.String replaceAll(java.lang.String self, java.util.regex.Pattern pattern, Closure closure)

### replaceAll

    public static java.lang.String replaceAll(java.lang.String self, java.util.regex.Pattern pattern, java.lang.String replacement)

### replaceAll

    public static java.lang.String replaceAll(java.lang.String self, java.lang.String regex, Closure closure)

  Replaces the first substring of this CharSequence that matches the given regular expression with the given replacement.
  throws:
    java.util.regex.PatternSyntaxException if the regular expression's syntax is invalid
  Parameters:
    `self` - a CharSequence
    `regex` - the capturing regex
    `replacement` - the capturing regex
  Returns:
    a CharSequence with replaced content
  See Also:
    java.lang.String#replaceAll(java.lang.String, java.lang.String)
  Since:
    1.8.2

### replaceFirst

    public static java.lang.String replaceFirst(java.lang.CharSequence self, java.lang.CharSequence regex, java.lang.CharSequence replacement)

  Replaces the first occurrence of a captured group by the result of a closure call on that text.
  throws:
    java.util.regex.PatternSyntaxException if the regular expression's syntax is invalid
  Parameters:
    `self` - a CharSequence
    `regex` - the capturing regex
    `closure` - the closure to apply on the first captured group
  Returns:
    a CharSequence with replaced content
  See Also:
    replaceFirst(String, String, groovy.lang.Closure)
  Since:
    1.8.2

### replaceFirst

    public static java.lang.String replaceFirst(java.lang.CharSequence self, java.lang.CharSequence regex, Closure closure)

  Replaces the first substring of a CharSequence that matches the given compiled regular expression with the given replacement.
  Parameters:
    `self` - the CharSequence that is to be matched
    `pattern` - the regex Pattern to which the CharSequence of interest is to be matched
    `replacement` - the CharSequence to be substituted for the first match
  Returns:
    The resulting `CharSequence`
  See Also:
    replaceFirst(String, java.util.regex.Pattern, String)
  Since:
    1.8.2

### replaceFirst

    public static java.lang.CharSequence replaceFirst(java.lang.CharSequence self, java.util.regex.Pattern pattern, java.lang.CharSequence replacement)

  Replaces the first occurrence of a captured group by the result of a closure call on that text.
  Parameters:
    `self` - a CharSequence
    `pattern` - the capturing regex Pattern
    `closure` - the closure to apply on the first captured group
  Returns:
    a CharSequence with replaced content
  See Also:
    replaceFirst(String, java.util.regex.Pattern, groovy.lang.Closure)
  Since:
    1.8.2

### replaceFirst

    public static java.lang.String replaceFirst(java.lang.CharSequence self, java.util.regex.Pattern pattern, Closure closure)

### replaceFirst

    public static java.lang.String replaceFirst(java.lang.String self, java.util.regex.Pattern pattern, Closure closure)

### replaceFirst

    public static java.lang.String replaceFirst(java.lang.String self, java.util.regex.Pattern pattern, java.lang.String replacement)

### replaceFirst

    public static java.lang.String replaceFirst(java.lang.String self, java.lang.String regex, Closure closure)

  Creates a new CharSequence which is the reverse (backwards) of this string
  Parameters:
    `self` - a CharSequence
  Returns:
    a new CharSequence with all the characters reversed.
  See Also:
    reverse(String)
  Since:
    1.8.2

### reverse

    public static java.lang.CharSequence reverse(java.lang.CharSequence self)

  Creates a new string which is the reverse (backwards) of this string
  Parameters:
    `self` - a String
  Returns:
    a new string with all the characters reversed.
  See Also:
    java.lang.StringBuilder#reverse()
  Since:
    1.0

### reverse

    public static java.lang.String reverse(java.lang.String self)

  Set the position of the given Matcher to the given index.
  Parameters:
    `matcher` - a Matcher
    `idx` - the index number
  Since:
    1.0

### setIndex

    public static void setIndex(java.util.regex.Matcher matcher, int idx)

### size

    public static int size(java.lang.CharSequence text)

  Provide the standard Groovy `size()` method for `CharSequence`.
  Parameters:
    `text` - a CharSequence
  Returns:
    the length of the CharSequence
  Since:
    1.8.2

### size

    public static long size(java.util.regex.Matcher self)

### size

    public static int size(java.lang.String text)

### size

    public static int size(java.lang.StringBuffer buffer)

### split

    public static java.lang.CharSequence[] split(java.lang.CharSequence self)

  Convenience method to split a GString (with whitespace as delimiter).
  Parameters:
    `self` - the GString to split
  Returns:
    String[] result of split
  See Also:
    split(String)
  Since:
    1.6.1

### split

    public static java.lang.String[] split(GString self)

  Convenience method to split a string (with whitespace as delimiter) Like tokenize, but returns an Array of Strings instead of a List
  Parameters:
    `self` - the string to split
  Returns:
    String[] result of split
  Since:
    1.5.0

### split

    public static java.lang.String[] split(java.lang.String self)

### splitEachLine

    public static java.lang.Object splitEachLine(java.lang.CharSequence self, java.lang.CharSequence regex, Closure closure)

### splitEachLine

    public static java.lang.Object splitEachLine(java.lang.CharSequence self, java.util.regex.Pattern pattern, Closure closure)

### splitEachLine

    public static java.lang.Object splitEachLine(java.lang.String self, java.util.regex.Pattern pattern, Closure closure)

### splitEachLine

    public static java.lang.Object splitEachLine(java.lang.String self, java.lang.String regex, Closure closure)

  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.

  Parameters:
    `self` - The CharSequence to strip the leading spaces from
  Returns:
    the stripped CharSequence
  See Also:
    stripIndent(String)
  Since:
    1.8.2

### stripIndent

    public static java.lang.CharSequence stripIndent(java.lang.CharSequence self)

  Strip `numChar` leading characters from every line in a CharSequence.

  Parameters:
    `self` - The CharSequence to strip the characters from
    `numChars` - The number of characters to strip
  Returns:
    the stripped CharSequence
  Since:
    1.8.2

### stripIndent

    public static java.lang.CharSequence stripIndent(java.lang.CharSequence self, int numChars)

### stripIndent

    public static java.lang.String stripIndent(java.lang.String self)

### stripIndent

    public static java.lang.String stripIndent(java.lang.String self, int numChars)

  Strip `numChar` leading characters from every line in a String.

       assert 'DEF\n456' == '''ABCDEF\n123456'''.stripIndent(3)

  Parameters:
    `self` - The String to strip the characters from
    `numChars` - The number of characters to strip
  Returns:
    the stripped String
  Since:
    1.7.3

### stripMargin

    public static java.lang.CharSequence stripMargin(java.lang.CharSequence self)

### stripMargin

    public static java.lang.CharSequence stripMargin(java.lang.CharSequence self, char marginChar)

### stripMargin

    public static java.lang.String stripMargin(java.lang.CharSequence self, java.lang.CharSequence marginChar)

### stripMargin

    public static java.lang.String stripMargin(java.lang.String self)

  Strip leading whitespace/control characters followed by `marginChar` from every line in a String.

       assert 'ABC\n123\n456' == '''ABC
                                   *123
                                   *456'''.stripMargin('*')

  Parameters:
    `self` - The String to strip the margin from
    `marginChar` - Any character that serves as margin delimiter
  Returns:
    the stripped String
  Since:
    1.7.3

### stripMargin

    public static java.lang.String stripMargin(java.lang.String self, char marginChar)

### stripMargin

    public static java.lang.String stripMargin(java.lang.String self, java.lang.String marginChar)

### take

    public static java.lang.CharSequence take(java.lang.CharSequence self, int num)

### takeWhile

    public static java.lang.CharSequence takeWhile(java.lang.CharSequence self, Closure condition)

  Parse a CharSequence into a BigDecimal
  Parameters:
    `self` - a CharSequence
  Returns:
    a BigDecimal
  See Also:
    toBigDecimal(String)
  Since:
    1.8.2

### toBigDecimal

    public static java.math.BigDecimal toBigDecimal(java.lang.CharSequence self)

  Parse a String into a BigDecimal
  Parameters:
    `self` - a String
  Returns:
    a BigDecimal
  Since:
    1.0

### toBigDecimal

    public static java.math.BigDecimal toBigDecimal(java.lang.String self)

  Parse a String into a BigInteger
  Parameters:
    `self` - a String
  Returns:
    a BigInteger
  Since:
    1.0

### toBigInteger

    public static java.math.BigInteger toBigInteger(java.lang.CharSequence self)

  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.
  Parameters:
    `self` - a String
  Returns:
    The Boolean value
  Since:
    1.0

### toBigInteger

    public static java.math.BigInteger toBigInteger(java.lang.String self)

### toBoolean

    public static java.lang.Boolean toBoolean(java.lang.String self)

### toCharacter

    public static java.lang.Character toCharacter(java.lang.String self)

  Parse a String into a Double
  Parameters:
    `self` - a String
  Returns:
    a Double
  Since:
    1.0

### toDouble

    public static java.lang.Double toDouble(java.lang.CharSequence self)

  Parse a CharSequence into a Float
  Parameters:
    `self` - a CharSequence
  Returns:
    a Float
  See Also:
    toFloat(String)
  Since:
    1.8.2

### toDouble

    public static java.lang.Double toDouble(java.lang.String self)

  Parse a String into a Float
  Parameters:
    `self` - a String
  Returns:
    a Float
  Since:
    1.0

### toFloat

    public static java.lang.Float toFloat(java.lang.CharSequence self)

  Parse a CharSequence into an Integer
  Parameters:
    `self` - a CharSequence
  Returns:
    an Integer
  See Also:
    toInteger(String)
  Since:
    1.8.2

### toFloat

    public static java.lang.Float toFloat(java.lang.String self)

  Parse a String into an Integer
  Parameters:
    `self` - a String
  Returns:
    an Integer
  Since:
    1.0

### toInteger

    public static java.lang.Integer toInteger(java.lang.CharSequence self)

  Tokenize a CharSequence (with a whitespace as the delimiter).
  Parameters:
    `self` - a CharSequence
  Returns:
    a List of tokens
  See Also:
    tokenize(String)
  Since:
    1.8.2

### toInteger

    public static java.lang.Integer toInteger(java.lang.String self)

### toList

    public static java.util.List toList(java.lang.CharSequence self)

### toList

    public static java.util.List toList(java.lang.String self)

### toLong

    public static java.lang.Long toLong(java.lang.CharSequence self)

  Converts the given CharSequence into a Set of unique CharSequence of one character.
  Parameters:
    `self` - a CharSequence
  Returns:
    a Set of unique character CharSequence (each a 1-character CharSequence)
  See Also:
    toSet(String)
  Since:
    1.8.2

### toLong

    public static java.lang.Long toLong(java.lang.String self)

### toSet

    public static java.util.Set toSet(java.lang.CharSequence self)

### toSet

    public static java.util.Set toSet(java.lang.String self)

  Parse a String into a Short
  Parameters:
    `self` - a String
  Returns:
    a Short
  Since:
    1.5.7

### toShort

    public static java.lang.Short toShort(java.lang.CharSequence self)

### toShort

    public static java.lang.Short toShort(java.lang.String self)

### tokenize

    public static java.util.List tokenize(java.lang.CharSequence self)

### tokenize

    public static java.util.List tokenize(java.lang.CharSequence self, java.lang.Character token)

### tokenize

    public static java.util.List tokenize(java.lang.CharSequence self, java.lang.CharSequence token)

### tokenize

    * Tokenize a String based on the given string delimiter.
    public static java.util.List tokenize(java.lang.String self)

### tokenize

    public static java.util.List tokenize(java.lang.String self, java.lang.Character token)

### tokenize

    public static List toList(String self) {
    public static java.util.List tokenize(java.lang.String self, java.lang.String token)

  Converts the given String into a List of strings of one character.
  Parameters:
    `self` - a String
  Returns:
    a List of characters (a 1-character String)
  Since:
    1.0

### tr

    public static java.lang.CharSequence tr(java.lang.CharSequence self, java.lang.CharSequence sourceSet, java.lang.CharSequence replacementSet)

### tr

    public static java.lang.String tr(java.lang.String self, java.lang.String sourceSet, java.lang.String replacementSet)

  Replaces sequences of whitespaces with tabs using tabStops of size 8.
  Parameters:
    `self` - A CharSequence to unexpand
  Returns:
    The unexpanded CharSequence
  See Also:
    unexpand(String)
  Since:
    1.8.2

### unexpand

    public static java.lang.CharSequence unexpand(java.lang.CharSequence self)

### unexpand

    public static java.lang.CharSequence unexpand(java.lang.CharSequence self, int tabStop)

  Replaces sequences of whitespaces with tabs.
  Parameters:
    `self` - A String to unexpand
    `tabStop` - The number of spaces a tab represents
  Returns:
    The unexpanded String
  Since:
    1.7.3

### unexpand

    public static java.lang.String unexpand(java.lang.String self)

### unexpand

    public static java.lang.String unexpand(java.lang.String self, int tabStop)

### unexpandLine

    public static java.lang.CharSequence unexpandLine(java.lang.CharSequence self, int tabStop)

  Replaces sequences of whitespaces with tabs within a line.
  Parameters:
    `self` - A line to unexpand
    `tabStop` - The number of spaces a tab represents
  Returns:
    The unexpanded String
  Since:
    1.7.3

### unexpandLine

    public static java.lang.String unexpandLine(java.lang.String self, int tabStop)

Groovy Documentation