Package groovy.lang

Class GString

    • Field Detail

      • EMPTY_STRING_ARRAY

        public static final String[] EMPTY_STRING_ARRAY
      • EMPTY_OBJECT_ARRAY

        public static final Object[] EMPTY_OBJECT_ARRAY
      • EMPTY

        public static final GString EMPTY
        A GString containing a single empty String and no values.
    • Constructor Detail

      • GString

        public GString​(Object values)
      • GString

        public GString​(Object[] values)
    • Method Detail

      • getStrings

        public abstract String[] getStrings()
      • invokeMethod

        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.
        Specified by:
        invokeMethod in interface GroovyObject
        Parameters:
        name - the name of the method to call
        args - the arguments to use for the method call
        Returns:
        the result of invoking the method
      • getValues

        public Object[] getValues()
      • getValueCount

        public int getValueCount()
      • getValue

        public Object getValue​(int idx)
      • calcInitialCapacity

        protected int calcInitialCapacity()
      • writeTo

        public Writer writeTo​(Writer out)
                       throws IOException
        Description copied from interface: Writable
        Writes this object to the given writer.

        This is used to defer content creation until the point when it is streamed to the output destination. Oftentimes, content will be defined but not necessarily created (as is may be the case with a Closure definition.) In that case, the output is then 'deferred' to the point when it is serialized to the writer. This class may be used whenever an object should be responsible for creating its own textual representation, but creating the entire output as a single String would be inefficient (such as outputting a multi-gigabyte XML document.)

        Specified by:
        writeTo in interface Writable
        Parameters:
        out - the Writer to which this Writable should output its data.
        Returns:
        the Writer that was passed
        Throws:
        IOException - if an error occurred while outputting data to the writer
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • equals

        public boolean equals​(GString that)
      • charAt

        public char charAt​(int index)
        Specified by:
        charAt in interface CharSequence
      • negate

        public Pattern negate()
        Turns a String into a regular expression pattern
        Returns:
        the regular expression pattern
      • getBytes

        public byte[] getBytes()