Package gw.internal.gosu.template
Class TemplateGenerator
java.lang.Object
gw.internal.gosu.template.TemplateGenerator
- All Implemented Interfaces:
ITemplateGenerator
A template generator employing Gosu.
Works much like JSP -- uses invalid input: '<'% script %> for scriptlets and invalid input: '<'%= expr %> for expressions.
Also supports JSP comments like this: invalid input: '<'%-- comment here --%>
Templates can be any type e.g., XML, HTML, text, whatever.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final intstatic final Stringstatic final intstatic final Stringstatic final intstatic final Stringstatic final intstatic final charstatic final charstatic final charstatic final charstatic final charstatic final charstatic final Stringstatic final Stringstatic final LockingLazyVar<ISymbol> static final LockingLazyVar<ISymbol> static final Stringstatic final intstatic final Stringstatic final intstatic final intstatic final StringFields inherited from interface gw.lang.parser.template.ITemplateGenerator
PRINT_COMPRESSED_METHOD, PRINT_METHOD, PRINT_RANGE_METHOD -
Method Summary
Modifier and TypeMethodDescriptionvoidcompile(ISymbolTable symTable) voidcompile(Stack<IScriptPartId> scriptPartIdStack, ISymbolTable symTable, Map<String, List<IFunctionSymbol>> dfsDeclByName, ITypeUsesMap typeUsesMap, Stack<BlockExpression> blocks, ContextInferenceManager ctxInferenceMgr) voidexecute(Writer writer, ISymbolTable symbolTable) voidexecute(Writer writer, StringEscaper escaper, ISymbolTable symTable) static voidgenerateTemplate(Reader readerTemplate, Writer writerOut, ISymbolTable symTable) Generates a template of any format having embedded Gosu.static voidgenerateTemplate(Reader readerTemplate, Writer writerOut, ISymbolTable symTable, boolean strict) Generates a template of any format having embedded Gosu.static TemplateGeneratorgetTemplate(Reader readerTemplate) static TemplateGeneratorgetTemplate(Reader readerTemplate, String fullyQualifiedName) booleanbooleanisValid()static voidprintContent(String strContent, boolean escape) For internal use only!!static voidprintRange(int iStart, int iEnd) voidsetContextInferenceManager(ContextInferenceManager ctxInferenceMgr) voidsetDisableAlternative(boolean disableAlternative) voidsetForStringLiteral(boolean bForStringLiteralTemplate) voidsetUseStudioEditorParser(boolean useStudioEditorParser) toString()voidverify(IGosuParser parser) voidverify(IGosuParser parser, Map<String, List<IFunctionSymbol>> dfsDeclByName, ITypeUsesMap typeUsesMap)
-
Field Details
-
GS_TEMPLATE
- See Also:
-
GS_TEMPLATE_PARSED
- See Also:
-
SCRIPTLET_BEGIN
- See Also:
-
SCRIPTLET_END
- See Also:
-
EXPRESSION_SUFFIX
public static final char EXPRESSION_SUFFIX- See Also:
-
DECLARATION_SUFFIX
public static final char DECLARATION_SUFFIX- See Also:
-
DIRECTIVE_SUFFIX
public static final char DIRECTIVE_SUFFIX- See Also:
-
COMMENT_BEGIN
- See Also:
-
COMMENT_END
- See Also:
-
ALTERNATE_EXPRESSION_BEGIN
- See Also:
-
ALTERNATE_EXPRESSION_END
- See Also:
-
ESCAPED_SCRIPTLET_MARKER
public static final char ESCAPED_SCRIPTLET_MARKER- See Also:
-
ESCAPED_SCRIPTLET_BEGIN_CHAR
public static final char ESCAPED_SCRIPTLET_BEGIN_CHAR- See Also:
-
ESCAPED_ALTERNATE_EXPRESSION_BEGIN_CHAR
public static final char ESCAPED_ALTERNATE_EXPRESSION_BEGIN_CHAR- See Also:
-
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
-
PRINT_RANGE_SYMBOL
-
TEMPLATE_LINE_NUMBER
- See Also:
-
SUBSTR_CHUNKSIZE
public static final int SUBSTR_CHUNKSIZE- See Also:
-
-
Method Details
-
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
-
getTemplate
-
getProgram
- Specified by:
getProgramin interfaceITemplateGenerator
-
execute
- Specified by:
executein interfaceITemplateGenerator- Throws:
TemplateParseException
-
execute
public void execute(Writer writer, StringEscaper escaper, ISymbolTable symTable) throws TemplateParseException - Specified by:
executein interfaceITemplateGenerator- Throws:
TemplateParseException
-
compile
- Specified by:
compilein 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
- Specified by:
verifyin interfaceITemplateGenerator- Throws:
ParseResultsException
-
getTemplateSyntaxProblems
- Specified by:
getTemplateSyntaxProblemsin interfaceITemplateGenerator
-
printContent
For internal use only!! -
printRange
public static void printRange(int iStart, int iEnd) -
setDisableAlternative
public void setDisableAlternative(boolean disableAlternative) -
setContextInferenceManager
-
setForStringLiteral
public void setForStringLiteral(boolean bForStringLiteralTemplate) -
isForStringLiteral
public boolean isForStringLiteral() -
isValid
public boolean isValid()- Specified by:
isValidin interfaceITemplateGenerator
-
getFullyQualifiedTypeName
- Specified by:
getFullyQualifiedTypeNamein interfaceITemplateGenerator
-
getParameters
- Specified by:
getParametersin interfaceITemplateGenerator
-
getSuperType
- Specified by:
getSuperTypein interfaceITemplateGenerator
-
setUseStudioEditorParser
public void setUseStudioEditorParser(boolean useStudioEditorParser) -
toString
-
getSource
- Specified by:
getSourcein interfaceITemplateGenerator
-