groovy.lang
Class GString

java.lang.Object
  extended bygroovy.lang.GroovyObjectSupport
      extended bygroovy.lang.GString
All Implemented Interfaces:
java.lang.CharSequence, java.lang.Comparable, GroovyObject, Writable

public abstract class GString
extends GroovyObjectSupport
implements java.lang.Comparable, java.lang.CharSequence, Writable

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: 1.10 $
Author:
James Strachan

Constructor Summary
GString(java.lang.Object values)
           
GString(java.lang.Object[] values)
           
 
Method Summary
 char charAt(int index)
           
 int compareTo(java.lang.Object that)
           
 boolean equals(GString that)
           
 boolean equals(java.lang.Object that)
           
abstract  java.lang.String[] getStrings()
           
 java.lang.Object getValue(int idx)
           
 int getValueCount()
           
 java.lang.Object[] getValues()
           
 int hashCode()
           
 java.lang.Object invokeMethod(java.lang.String name, java.lang.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()
           
 GString plus(GString that)
           
 GString plus(java.lang.String that)
           
 java.lang.CharSequence subSequence(int start, int end)
           
 java.lang.String toString()
           
 void writeTo(java.io.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(java.lang.Object values)

GString

public GString(java.lang.Object[] values)
Method Detail

getStrings

public abstract java.lang.String[] getStrings()

invokeMethod

public java.lang.Object invokeMethod(java.lang.String name,
                                     java.lang.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

getValues

public java.lang.Object[] getValues()

plus

public GString plus(GString that)

plus

public GString plus(java.lang.String that)

getValueCount

public int getValueCount()

getValue

public java.lang.Object getValue(int idx)

toString

public java.lang.String toString()
Specified by:
toString in interface java.lang.CharSequence

writeTo

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

Specified by:
writeTo in interface Writable
Throws:
java.io.IOException

equals

public boolean equals(java.lang.Object that)

equals

public boolean equals(GString that)

hashCode

public int hashCode()

compareTo

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

charAt

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

length

public int length()
Specified by:
length in interface java.lang.CharSequence

subSequence

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


Copyright © 2003-2004 The Codehaus. All Rights Reserved.