groovy.lang
Class GString

java.lang.Object
  extended by groovy.lang.GroovyObjectSupport
      extended by groovy.lang.GString
All Implemented Interfaces:
Buildable, GroovyObject, Writable, Serializable, CharSequence, Comparable
Direct Known Subclasses:
GStringImpl

public abstract class GString
extends GroovyObjectSupport
implements Comparable, CharSequence, Writable, Buildable, 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. The lovely name of this class was suggested by Jules Gosnell and was such a good idea, I couldn't resist :)

Version:
$Revision: 13355 $
Author:
James Strachan
See Also:
Serialized Form

Constructor Summary
GString(Object values)
           
GString(Object[] values)
           
 
Method Summary
 void build(GroovyObject builder)
           
 char charAt(int index)
           
 int compareTo(Object that)
           
 boolean equals(GString that)
           
 boolean equals(Object that)
           
abstract  String[] getStrings()
           
 Object getValue(int idx)
           
 int getValueCount()
           
 Object[] getValues()
           
 int hashCode()
           
 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.
 int length()
           
 Pattern negate()
          Turns a String into a regular expression pattern
 GString plus(GString that)
           
 GString plus(String that)
           
 CharSequence subSequence(int start, int end)
           
 String toString()
           
 Writer writeTo(Writer out)
          writes this object to the given stream
 
Methods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, getProperty, setMetaClass, setProperty
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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
Overrides:
invokeMethod in class GroovyObjectSupport
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()

plus

public GString plus(GString that)

plus

public GString plus(String that)

getValueCount

public int getValueCount()

getValue

public Object getValue(int idx)

toString

public String toString()
Specified by:
toString in interface CharSequence
Overrides:
toString in class Object

writeTo

public Writer writeTo(Writer out)
               throws IOException
Description copied from interface: Writable
writes this object to the given stream

Specified by:
writeTo in interface Writable
Throws:
IOException

build

public void build(GroovyObject builder)
Specified by:
build in interface Buildable

equals

public boolean equals(Object that)
Overrides:
equals in class Object

equals

public boolean equals(GString that)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

compareTo

public int compareTo(Object that)
Specified by:
compareTo in interface Comparable

charAt

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

length

public int length()
Specified by:
length in interface CharSequence

subSequence

public CharSequence subSequence(int start,
                                int end)
Specified by:
subSequence in interface CharSequence

negate

public Pattern negate()
Turns a String into a regular expression pattern

Returns:
the regular expression pattern

Copyright © 2003-2008 The Codehaus. All rights reserved.