Package: groovy.lang

## [Java] Class GString

- groovy.lang.GString

-     public class GString
      extends Object

  GDK enhancements for GString.

  displayName:
    GString
  receiverFqcn:
    groovy.lang.GString

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `<T>` | `public T` | `asType(Class<T> c)` Converts the GString to a File, or delegates to the default DefaultGroovyMethods.asType.
    `` | `public String` | `drop(int num)` A GString variant of the equivalent CharSequence method.
    `` | `public String` | `dropRight(int num)` A GString variant of the equivalent CharSequence method CharSequence.dropRight.
    `` | `public String` | `dropWhile(Closure condition)` A GString variant of the equivalent CharSequence method.
    `` | `public String` | `getAt(int index)` Supports the subscript operator for GString.
    `` | `public String` | `getAt(IntRange range)` Supports the range subscript operator for GString with IntRange.
    `` | `public String` | `getAt(Range range)` Supports the range subscript operator for GString.
    `` | `public String` | `take(int num)` A GString variant of the equivalent CharSequence method.
    `` | `public String` | `takeAfter(CharSequence searchString)` A GString variant of the equivalent CharSequence method CharSequence.takeAfter.
    `` | `public String` | `takeBefore(String searchString)` A GString variant of the equivalent CharSequence method CharSequence.takeBefore.
    `` | `public String` | `takeBetween(CharSequence from, CharSequence to)` A GString variant of the equivalent CharSequence method CharSequence.takeBetween.
    `` | `public String` | `takeBetween(CharSequence enclosure)` A GString variant of the equivalent CharSequence method CharSequence.takeBetween.
    `` | `public String` | `takeBetween(CharSequence from, CharSequence to, int occurrence)` A GString variant of the equivalent CharSequence method CharSequence.takeBetween.
    `` | `public String` | `takeBetween(CharSequence enclosure, int occurrence)` A GString variant of the equivalent CharSequence method CharSequence.takeBetween.
    `` | `public String` | `takeRight(int num)` A String variant of the equivalent CharSequence method CharSequence.takeRight.
    `` | `public String` | `takeWhile(Closure condition)` A GString variant of the equivalent GString method.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `addShutdownHook, any, any, asBoolean, asType, clamp, clamp, collect, collect, collect, dump, each, eachMatch, eachMatch, eachWithIndex, every, every, find, find, findAll, findAll, findIndexOf, findIndexOf, findIndexValues, findIndexValues, findLastIndexOf, findLastIndexOf, findResult, findResult, findResult, findResult, getAt, getMetaClass, getMetaPropertyValues, getProperties, grep, grep, hasProperty, identity, inject, inject, inject, inject, inspect, invokeMethod, is, isCase, isNotCase, iterator, metaClass, print, print, printf, printf, println, println, println, putAt, respondsTo, respondsTo, setMetaClass, sleep, sleep, split, sprintf, sprintf, stream, takeIf, tap, toString, use, use, use, with, with, withCloseable, withCloseable, withMethodClosure, withStream, withStream, withTraits`

- - ### Method Detail

    - #### <T> public T asType(Class<T> c)

      Converts the GString to a File, or delegates to the default DefaultGroovyMethods.asType.

      Parameters:
        `c` - the desired class
      Returns:
        the converted object
      Since:
        1.5.0

    - #### public String drop(int num)

      A GString variant of the equivalent CharSequence method.

      Parameters:
        `num` - the number of characters to drop from this GString
      Returns:
        a String consisting of all characters except the first `num` ones, or else an empty String, if the toString() of this GString has less than `num` characters.
      Since:
        2.3.7
      See Also:
        drop(String,int)

    - #### public String dropRight(int num)

      A GString variant of the equivalent CharSequence method CharSequence.dropRight.

      Parameters:
        `num` - number of characters
      Returns:
        String after removing the right `num` chars and empty of the `num` is greater than the length of the CharSequence
      Since:
        3.0.0

    - #### public String dropWhile(Closure condition)

      A GString variant of the equivalent CharSequence method.

      Parameters:
        `condition` - the closure that while continuously evaluating to true will cause us to drop elements from the front of the original GString
      Returns:
        the shortest suffix of the given GString such that the given closure condition evaluates to true for each element dropped from the front of the CharSequence
      Since:
        2.3.7
      See Also:
        dropWhile(CharSequence,Closure)

    - #### public String getAt(int index)

      Supports the subscript operator for GString.

      Parameters:
        `index` - the index of the Character to get
      Returns:
        the Character at the given index
      Since:
        2.3.7

    - #### public String getAt(IntRange range)

      Supports the range subscript operator for GString with IntRange.

      Parameters:
        `range` - an IntRange
      Returns:
        the String of characters corresponding to the provided range
      Since:
        2.3.7

    - #### public String getAt(Range range)

      Supports the range subscript operator for GString.

      Parameters:
        `range` - a Range
      Returns:
        the String of characters corresponding to the provided range
      Since:
        2.3.7

    - #### public String take(int num)

      A GString variant of the equivalent CharSequence method.

      Parameters:
        `num` - the number of chars to take from this GString
      Returns:
        a String consisting of the first `num` chars, or else the whole GString if it has less than `num` elements.
      Since:
        2.3.7

    - #### public String takeAfter(CharSequence searchString)

      A GString variant of the equivalent CharSequence method CharSequence.takeAfter.

      Parameters:
        `searchString` - CharSequence that is searched in this CharSequence
      Returns:
        String that is after the given searchString and empty string if it does not exist
      Since:
        3.0.0

    - #### public String takeBefore(String searchString)

      A GString variant of the equivalent CharSequence method CharSequence.takeBefore.

      Parameters:
        `searchString` - CharSequence that is searched in this CharSequence
      Returns:
        String that is before the given searchString
      Since:
        3.0.0

    - #### public String takeBetween(CharSequence from, CharSequence to)

      A GString variant of the equivalent CharSequence method CharSequence.takeBetween.

      Parameters:
        `from` - beginning of search
        `to` - end of search
      Returns:
        String that is in between the given two CharSequences and empty if the unavailable inputs are given
      Since:
        3.0.0

    - #### public String takeBetween(CharSequence enclosure)

      A GString variant of the equivalent CharSequence method CharSequence.takeBetween.

      Parameters:
        `enclosure` - Enclosure CharSequence
      Returns:
        String between the 2 subsequent `enclosure` strings
      Since:
        3.0.0

    - #### public String takeBetween(CharSequence from, CharSequence to, int occurrence)

      A GString variant of the equivalent CharSequence method CharSequence.takeBetween.

      Parameters:
        `from` - beginning of search
        `to` - end of search
        `occurrence` - nth occurrence that is to be returned. 0 represents first one
      Returns:
        the String that is in between the given nth (specified by occurrence) pair of `from` and `to` CharSequences and empty if the unavailable inputs are given.
      Since:
        3.0.0

    - #### public String takeBetween(CharSequence enclosure, int occurrence)

      A GString variant of the equivalent CharSequence method CharSequence.takeBetween.

      Parameters:
        `enclosure` - Enclosure CharSequence
        `occurrence` - nth occurrence being returned
      Returns:
        String between the nth occurrence of pair of `enclosure` strings
      Since:
        3.0.0

    - #### public String takeRight(int num)

      A String variant of the equivalent CharSequence method CharSequence.takeRight.

      Parameters:
        `num` - the number of chars to take from this GString from the right
      Returns:
        a String consisting of the last `num` chars, or else the whole GString if it has less than `num` elements.
      Since:
        3.0.0

    - #### public String takeWhile(Closure condition)

      A GString variant of the equivalent GString method.

      Parameters:
        `condition` - the closure that must evaluate to true to continue taking elements
      Returns:
        a prefix of elements in the GString where each element passed to the given closure evaluates to true
      Since:
        2.3.7