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 classTemplateGenerator.LockedDownSymbol
-
Field Summary
Fields Modifier and Type Field Description static StringALTERNATE_EXPRESSION_BEGINstatic intALTERNATE_EXPRESSION_BEGIN_LENstatic StringALTERNATE_EXPRESSION_ENDstatic intALTERNATE_EXPRESSION_END_LENstatic StringCOMMENT_BEGINstatic intCOMMENT_BEGIN_LENstatic StringCOMMENT_ENDstatic intCOMMENT_END_LENstatic charDECLARATION_SUFFIXstatic charDIRECTIVE_SUFFIXstatic charESCAPED_ALTERNATE_EXPRESSION_BEGIN_CHARstatic charESCAPED_SCRIPTLET_BEGIN_CHARstatic charESCAPED_SCRIPTLET_MARKERstatic charEXPRESSION_SUFFIXstatic StringGS_TEMPLATEstatic StringGS_TEMPLATE_PARSEDstatic LockingLazyVar<ISymbol>PRINT_CONTENT_SYMBOLstatic LockingLazyVar<ISymbol>PRINT_RANGE_SYMBOLstatic StringSCRIPTLET_BEGINstatic intSCRIPTLET_BEGIN_LENstatic StringSCRIPTLET_ENDstatic intSCRIPTLET_END_LENstatic intSUBSTR_CHUNKSIZEstatic StringTEMPLATE_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 voidcompile(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.StringgetFullyQualifiedTypeName()List<ISymbol>getParameters()ProgramgetProgram()StringgetSource()ITypegetSuperType()static TemplateGeneratorgetTemplate(Reader readerTemplate)static TemplateGeneratorgetTemplate(Reader readerTemplate, String fullyQualifiedName)List<TemplateParseException>getTemplateSyntaxProblems()booleanisForStringLiteral()booleanisValid()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)StringtoString()voidverify(IGosuParser parser)voidverify(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:
getProgramin interfaceITemplateGenerator
-
execute
public void execute(Writer writer, ISymbolTable symbolTable) throws TemplateParseException
- 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
public void compile(ISymbolTable symTable) throws TemplateParseException
- 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
public void verify(IGosuParser parser) throws ParseResultsException
- Specified by:
verifyin interfaceITemplateGenerator- Throws:
ParseResultsException
-
getTemplateSyntaxProblems
public List<TemplateParseException> getTemplateSyntaxProblems()
- Specified by:
getTemplateSyntaxProblemsin 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:
isValidin interfaceITemplateGenerator
-
getFullyQualifiedTypeName
public String getFullyQualifiedTypeName()
- Specified by:
getFullyQualifiedTypeNamein interfaceITemplateGenerator
-
getParameters
public List<ISymbol> getParameters()
- Specified by:
getParametersin interfaceITemplateGenerator
-
getSuperType
public IType getSuperType()
- Specified by:
getSuperTypein interfaceITemplateGenerator
-
setUseStudioEditorParser
public void setUseStudioEditorParser(boolean useStudioEditorParser)
-
getSource
public String getSource()
- Specified by:
getSourcein interfaceITemplateGenerator
-
-