Package gw.internal.gosu.template
Class TemplateGenerator
- java.lang.Object
-
- gw.internal.gosu.template.TemplateGenerator
-
- All Implemented Interfaces:
ITemplateGenerator
public class TemplateGenerator extends Object implements ITemplateGenerator
A template generator employing Gosu. Works much like JSP -- uses <% script %> for scriptlets and <%= expr %> for expressions. Also supports JSP comments like this: <%-- comment here --%> Templates can be any type e.g., XML, HTML, text, whatever.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TemplateGenerator.LockedDownSymbol
-
Field Summary
Fields Modifier and Type Field Description static String
ALTERNATE_EXPRESSION_BEGIN
static int
ALTERNATE_EXPRESSION_BEGIN_LEN
static String
ALTERNATE_EXPRESSION_END
static int
ALTERNATE_EXPRESSION_END_LEN
static String
COMMENT_BEGIN
static int
COMMENT_BEGIN_LEN
static String
COMMENT_END
static int
COMMENT_END_LEN
static char
DECLARATION_SUFFIX
static char
DIRECTIVE_SUFFIX
static char
ESCAPED_ALTERNATE_EXPRESSION_BEGIN_CHAR
static char
ESCAPED_SCRIPTLET_BEGIN_CHAR
static char
ESCAPED_SCRIPTLET_MARKER
static char
EXPRESSION_SUFFIX
static String
GS_TEMPLATE
static String
GS_TEMPLATE_PARSED
static LockingLazyVar<ISymbol>
PRINT_CONTENT_SYMBOL
static LockingLazyVar<ISymbol>
PRINT_RANGE_SYMBOL
static String
SCRIPTLET_BEGIN
static int
SCRIPTLET_BEGIN_LEN
static String
SCRIPTLET_END
static int
SCRIPTLET_END_LEN
static int
SUBSTR_CHUNKSIZE
static String
TEMPLATE_LINE_NUMBER
-
Fields inherited from interface gw.lang.parser.template.ITemplateGenerator
PRINT_COMPRESSED_METHOD, PRINT_METHOD, PRINT_RANGE_METHOD
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
compile(ISymbolTable symTable)
void
compile(Stack<IScriptPartId> scriptPartIdStack, ISymbolTable symTable, Map<String,List<IFunctionSymbol>> dfsDeclByName, ITypeUsesMap typeUsesMap, Stack<BlockExpression> blocks, ContextInferenceManager ctxInferenceMgr)
void
execute(Writer writer, ISymbolTable symbolTable)
void
execute(Writer writer, StringEscaper escaper, ISymbolTable symTable)
static void
generateTemplate(Reader readerTemplate, Writer writerOut, ISymbolTable symTable)
Generates a template of any format having embedded Gosu.static void
generateTemplate(Reader readerTemplate, Writer writerOut, ISymbolTable symTable, boolean strict)
Generates a template of any format having embedded Gosu.String
getFullyQualifiedTypeName()
List<ISymbol>
getParameters()
Program
getProgram()
String
getSource()
IType
getSuperType()
static TemplateGenerator
getTemplate(Reader readerTemplate)
static TemplateGenerator
getTemplate(Reader readerTemplate, String fullyQualifiedName)
List<TemplateParseException>
getTemplateSyntaxProblems()
boolean
isForStringLiteral()
boolean
isValid()
static void
printContent(String strContent, boolean escape)
For internal use only!!static void
printRange(int iStart, int iEnd)
void
setContextInferenceManager(ContextInferenceManager ctxInferenceMgr)
void
setDisableAlternative(boolean disableAlternative)
void
setForStringLiteral(boolean bForStringLiteralTemplate)
void
setUseStudioEditorParser(boolean useStudioEditorParser)
String
toString()
void
verify(IGosuParser parser)
void
verify(IGosuParser parser, Map<String,List<IFunctionSymbol>> dfsDeclByName, ITypeUsesMap typeUsesMap)
-
-
-
Field Detail
-
GS_TEMPLATE
public static final String GS_TEMPLATE
- See Also:
- Constant Field Values
-
GS_TEMPLATE_PARSED
public static final String GS_TEMPLATE_PARSED
- See Also:
- Constant Field Values
-
SCRIPTLET_BEGIN
public static final String SCRIPTLET_BEGIN
- See Also:
- Constant Field Values
-
SCRIPTLET_END
public static final String SCRIPTLET_END
- See Also:
- Constant Field Values
-
EXPRESSION_SUFFIX
public static final char EXPRESSION_SUFFIX
- See Also:
- Constant Field Values
-
DECLARATION_SUFFIX
public static final char DECLARATION_SUFFIX
- See Also:
- Constant Field Values
-
DIRECTIVE_SUFFIX
public static final char DIRECTIVE_SUFFIX
- See Also:
- Constant Field Values
-
COMMENT_BEGIN
public static final String COMMENT_BEGIN
- See Also:
- Constant Field Values
-
COMMENT_END
public static final String COMMENT_END
- See Also:
- Constant Field Values
-
ALTERNATE_EXPRESSION_BEGIN
public static final String ALTERNATE_EXPRESSION_BEGIN
- See Also:
- Constant Field Values
-
ALTERNATE_EXPRESSION_END
public static final String ALTERNATE_EXPRESSION_END
- See Also:
- Constant Field Values
-
ESCAPED_SCRIPTLET_MARKER
public static final char ESCAPED_SCRIPTLET_MARKER
- See Also:
- Constant Field Values
-
ESCAPED_SCRIPTLET_BEGIN_CHAR
public static final char ESCAPED_SCRIPTLET_BEGIN_CHAR
- See Also:
- Constant Field Values
-
ESCAPED_ALTERNATE_EXPRESSION_BEGIN_CHAR
public static final char ESCAPED_ALTERNATE_EXPRESSION_BEGIN_CHAR
- See Also:
- Constant Field Values
-
SCRIPTLET_BEGIN_LEN
public static final int SCRIPTLET_BEGIN_LEN
-
SCRIPTLET_END_LEN
public static final int SCRIPTLET_END_LEN
-
COMMENT_BEGIN_LEN
public static final int COMMENT_BEGIN_LEN
-
COMMENT_END_LEN
public static final int COMMENT_END_LEN
-
ALTERNATE_EXPRESSION_BEGIN_LEN
public static final int ALTERNATE_EXPRESSION_BEGIN_LEN
-
ALTERNATE_EXPRESSION_END_LEN
public static final int ALTERNATE_EXPRESSION_END_LEN
-
PRINT_CONTENT_SYMBOL
public static final LockingLazyVar<ISymbol> PRINT_CONTENT_SYMBOL
-
PRINT_RANGE_SYMBOL
public static final LockingLazyVar<ISymbol> PRINT_RANGE_SYMBOL
-
TEMPLATE_LINE_NUMBER
public static final String TEMPLATE_LINE_NUMBER
- See Also:
- Constant Field Values
-
SUBSTR_CHUNKSIZE
public static final int SUBSTR_CHUNKSIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
generateTemplate
public static void generateTemplate(Reader readerTemplate, Writer writerOut, ISymbolTable symTable) throws TemplateParseException
Generates a template of any format having embedded Gosu.- Parameters:
readerTemplate
- The source of the template.writerOut
- Where the output should go.symTable
- The symbol table to use.- Throws:
TemplateParseException
- on execution exception
-
generateTemplate
public static void generateTemplate(Reader readerTemplate, Writer writerOut, ISymbolTable symTable, boolean strict) throws TemplateParseException
Generates a template of any format having embedded Gosu.- Parameters:
readerTemplate
- The source of the template.writerOut
- Where the output should go.symTable
- The symbol table to use.strict
- whether to allow althernative template- Throws:
TemplateParseException
- on execution exception
-
getTemplate
public static TemplateGenerator getTemplate(Reader readerTemplate)
-
getTemplate
public static TemplateGenerator getTemplate(Reader readerTemplate, String fullyQualifiedName)
-
getProgram
public Program getProgram()
- Specified by:
getProgram
in interfaceITemplateGenerator
-
execute
public void execute(Writer writer, ISymbolTable symbolTable) throws TemplateParseException
- Specified by:
execute
in interfaceITemplateGenerator
- Throws:
TemplateParseException
-
execute
public void execute(Writer writer, StringEscaper escaper, ISymbolTable symTable) throws TemplateParseException
- Specified by:
execute
in interfaceITemplateGenerator
- Throws:
TemplateParseException
-
compile
public void compile(ISymbolTable symTable) throws TemplateParseException
- Specified by:
compile
in interfaceITemplateGenerator
- Throws:
TemplateParseException
-
compile
public void compile(Stack<IScriptPartId> scriptPartIdStack, ISymbolTable symTable, Map<String,List<IFunctionSymbol>> dfsDeclByName, ITypeUsesMap typeUsesMap, Stack<BlockExpression> blocks, ContextInferenceManager ctxInferenceMgr) throws TemplateParseException
- Throws:
TemplateParseException
-
verify
public void verify(IGosuParser parser, Map<String,List<IFunctionSymbol>> dfsDeclByName, ITypeUsesMap typeUsesMap) throws ParseResultsException
- Throws:
ParseResultsException
-
verify
public void verify(IGosuParser parser) throws ParseResultsException
- Specified by:
verify
in interfaceITemplateGenerator
- Throws:
ParseResultsException
-
getTemplateSyntaxProblems
public List<TemplateParseException> getTemplateSyntaxProblems()
- Specified by:
getTemplateSyntaxProblems
in interfaceITemplateGenerator
-
printContent
public static void printContent(String strContent, boolean escape)
For internal use only!!
-
printRange
public static void printRange(int iStart, int iEnd)
-
setDisableAlternative
public void setDisableAlternative(boolean disableAlternative)
-
setContextInferenceManager
public void setContextInferenceManager(ContextInferenceManager ctxInferenceMgr)
-
setForStringLiteral
public void setForStringLiteral(boolean bForStringLiteralTemplate)
-
isForStringLiteral
public boolean isForStringLiteral()
-
isValid
public boolean isValid()
- Specified by:
isValid
in interfaceITemplateGenerator
-
getFullyQualifiedTypeName
public String getFullyQualifiedTypeName()
- Specified by:
getFullyQualifiedTypeName
in interfaceITemplateGenerator
-
getParameters
public List<ISymbol> getParameters()
- Specified by:
getParameters
in interfaceITemplateGenerator
-
getSuperType
public IType getSuperType()
- Specified by:
getSuperType
in interfaceITemplateGenerator
-
setUseStudioEditorParser
public void setUseStudioEditorParser(boolean useStudioEditorParser)
-
getSource
public String getSource()
- Specified by:
getSource
in interfaceITemplateGenerator
-
-