Groovy 2.2.0

groovy.lang
[Java] Class GString

java.lang.Object
  groovy.lang.GroovyObjectSupport
      groovy.lang.GString
All Implemented Interfaces:
Buildable, Comparable, CharSequence, Writable, Serializable

public abstract class GString
extends GroovyObjectSupport

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 :)

Authors:
James Strachan
Version:
\$Revision\$


Field Summary
static GString EMPTY

A GString containing a single empty String and no values.

 
Constructor Summary
GString(Object values)

GString(Object[] values)

 
Method Summary
void build(GroovyObject builder)

char charAt(int index)

int compareTo(Object that)

boolean equals(Object that)

boolean equals(GString that)

byte[] getBytes()

byte[] getBytes(String charset)

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)

 
Methods inherited from class GroovyObjectSupport
getMetaClass, getProperty, invokeMethod, setMetaClass, setProperty
 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

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

build

public void build(GroovyObject builder)


charAt

public char charAt(int index)


compareTo

public int compareTo(Object that)


equals

public boolean equals(Object that)


equals

public boolean equals(GString that)


getBytes

public byte[] getBytes()


getBytes

public byte[] getBytes(String charset)


getStrings

public String[] getStrings()


getValue

public Object getValue(int idx)


getValueCount

public int getValueCount()


getValues

public Object[] getValues()


hashCode

public int hashCode()


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.


length

public int length()


negate

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


plus

public GString plus(GString that)


plus

public GString plus(String that)


subSequence

public CharSequence subSequence(int start, int end)


toString

public String toString()


writeTo

public Writer writeTo(Writer out)


 

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