groovy.text
Class GStringTemplateEngine.GStringTemplate

java.lang.Object
  extended by groovy.text.GStringTemplateEngine.GStringTemplate
All Implemented Interfaces:
Template
Enclosing class:
GStringTemplateEngine

private static class GStringTemplateEngine.GStringTemplate
extends java.lang.Object
implements Template


Field Summary
(package private)  Closure template
           
 
Constructor Summary
GStringTemplateEngine.GStringTemplate(java.io.Reader reader, java.lang.ClassLoader parentLoader)
          Turn the template into a writable Closure When executed the closure evaluates all the code embedded in the template and then writes a GString containing the fixed and variable items to the writer passed as a parameter

For example:

'<%= "test" %> of expr and <% test = 1 %>${test} script.'

would compile into:

{ out -> out << "${"test"} of expr and "; test = 1 ; out << "${test} script."}.asWritable()

 
Method Summary
private static void appendCharacter(char c, java.lang.StringBuffer templateExpressions, boolean writingString)
           
 Writable make()
           
 Writable make(java.util.Map map)
           
private static void parseExpression(java.io.Reader reader, boolean writingString, java.lang.StringBuffer templateExpressions)
          Parse a <%= ....
private  void parseGSstring(java.io.Reader reader, boolean writingString, java.lang.StringBuffer templateExpressions)
           
private static void parseSection(int pendingC, java.io.Reader reader, boolean writingString, java.lang.StringBuffer templateExpressions)
          Parse a <% ....
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

template

final Closure template
Constructor Detail

GStringTemplateEngine.GStringTemplate

GStringTemplateEngine.GStringTemplate(java.io.Reader reader,
                                      java.lang.ClassLoader parentLoader)
                                throws CompilationFailedException,
                                       java.lang.ClassNotFoundException,
                                       java.io.IOException
Turn the template into a writable Closure When executed the closure evaluates all the code embedded in the template and then writes a GString containing the fixed and variable items to the writer passed as a parameter

For example:

'<%= "test" %> of expr and <% test = 1 %>${test} script.'

would compile into:

{ out -> out << "${"test"} of expr and "; test = 1 ; out << "${test} script."}.asWritable()

Parameters:
reader -
parentLoader -
Throws:
CompilationFailedException
java.lang.ClassNotFoundException
java.io.IOException
Method Detail

appendCharacter

private static void appendCharacter(char c,
                                    java.lang.StringBuffer templateExpressions,
                                    boolean writingString)

parseGSstring

private void parseGSstring(java.io.Reader reader,
                           boolean writingString,
                           java.lang.StringBuffer templateExpressions)
                    throws java.io.IOException
Throws:
java.io.IOException

parseSection

private static void parseSection(int pendingC,
                                 java.io.Reader reader,
                                 boolean writingString,
                                 java.lang.StringBuffer templateExpressions)
                          throws java.io.IOException
Parse a <% .... %> section if we are writing a GString close and append ';' then write the section as a statement

Parameters:
pendingC -
reader -
writingString -
templateExpressions -
Throws:
java.io.IOException

parseExpression

private static void parseExpression(java.io.Reader reader,
                                    boolean writingString,
                                    java.lang.StringBuffer templateExpressions)
                             throws java.io.IOException
Parse a <%= .... %> expression

Parameters:
reader -
writingString -
templateExpressions -
Throws:
java.io.IOException

make

public Writable make()
Specified by:
make in interface Template

make

public Writable make(java.util.Map map)
Specified by:
make in interface Template


Copyright © ${year} The Codehaus. All Rights Reserved.