Package: groovy.lang

## [Java] Class GString

- groovy.lang.GString

- All Implemented Interfaces and Traits:
    Buildable, Comparable, CharSequence, Writable, Serializable

      public abstract class GString
      extends GroovyObjectSupport
      implements Buildable, Comparable, CharSequence, Writable, Serializable

  Represents a String which contains embedded values such as "hello there ${user} how are you?" which can be evaluated lazily. Advanced users can iterate over the text and values to perform special processing, such as for performing SQL operations, the values can be substituted for ? and the actual value objects can be bound to a JDBC statement.

  James Strachan: The lovely name of this class was suggested by Jules Gosnell and was such a good idea, I couldn't resist :)

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static GString` | `EMPTY` | A GString containing a single empty String and no values.
    `static Object[]` | `EMPTY_OBJECT_ARRAY` |
    `static String[]` | `EMPTY_STRING_ARRAY` |

  - ### Constructor Summary

    Constructors
    Constructor and description
    `GString(Object values)`
    `GString(Object[] values)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public void` | `build(GroovyObject builder)`
    `` | `protected int` | `calcInitialCapacity()`
    `` | `public char` | `charAt(int index)`
    `` | `public int` | `compareTo(Object that)`
    `` | `public boolean` | `equals(Object that)`
    `` | `public boolean` | `equals(GString that)`
    `` | `public byte[]` | `getBytes()`
    `` | `public byte[]` | `getBytes(String charset)`
    `` | `public String[]` | `getStrings()`
    `` | `public abstract String[]` | `getStrings()`
    `` | `public Object` | `getValue(int idx)`
    `` | `public int` | `getValueCount()`
    `` | `public Object[]` | `getValues()`
    `` | `public int` | `hashCode()`
    `` | `public Object` | `invokeMethod(String name, Object args)` Overloaded to implement duck typing for Strings so that any method that can't be evaluated on this object will be forwarded to the toString() object instead.
    `` | `public int` | `length()`
    `` | `public Pattern` | `negate()` Turns a String into a regular expression pattern
    `` | `public GString` | `plus(GString that)`
    `` | `public GString` | `plus(String that)`
    `` | `public CharSequence` | `subSequence(int start, int end)`
    `` | `public String` | `toString()`
    `` | `public String` | `toString()`
    `` | `public Writer` | `writeTo(Writer out)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class GroovyObjectSupport` | `getMetaClass, setMetaClass`

- - ### Field Detail

    - #### public static final GString EMPTY

      A GString containing a single empty String and no values.

    - #### public static final Object[] EMPTY_OBJECT_ARRAY

    - #### public static final String[] EMPTY_STRING_ARRAY

  - ### Constructor Detail

    - #### public GString(Object values)

    - #### public GString(Object[] values)

  - ### Method Detail

    - #### @Override
      public void build(GroovyObject builder)

    - #### protected int calcInitialCapacity()

    - #### @Override
      public char charAt(int index)

    - #### @Override
      public int compareTo(Object that)

    - #### @Override
      public boolean equals(Object that)

    - #### public boolean equals(GString that)

    - #### public byte[] getBytes()

    - #### public byte[] getBytes(String charset)

    - #### @Override
      public String[] getStrings()

    - #### public abstract String[] getStrings()

    - #### public Object getValue(int idx)

    - #### public int getValueCount()

    - #### public Object[] getValues()

    - #### @Override
      public int hashCode()

    - #### @Override
      public Object invokeMethod(String name, Object args)

      Overloaded to implement duck typing for Strings so that any method that can't be evaluated on this object will be forwarded to the toString() object instead.

    - #### @Override
      public int length()

    - #### public Pattern negate()

      Turns a String into a regular expression pattern

      Returns:
        the regular expression pattern

    - #### public GString plus(GString that)

    - #### public GString plus(String that)

    - #### @Override
      public CharSequence subSequence(int start, int end)

    - #### @Override
      public String toString()

    - #### @Override
      public String toString()

    - #### @Override
      public Writer writeTo(Writer out)