org.rythmengine.internal
Class CodeBuilder

java.lang.Object
  extended by org.rythmengine.utils.TextBuilder
      extended by org.rythmengine.internal.CodeBuilder
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
AutoToStringCodeBuilder

public class CodeBuilder
extends TextBuilder


Nested Class Summary
static class CodeBuilder.InlineTag
           
static class CodeBuilder.RenderArgDeclaration
           
 
Nested classes/interfaces inherited from class org.rythmengine.utils.TextBuilder
TextBuilder.StrBuf
 
Field Summary
 String buildBody
           
 Set<String> imports
           
 String includingCName
           
static String INTERRUPT_CODE
           
protected static ILogger logger
           
protected  boolean logTime
           
 boolean removeNextLF
           
 Map<String,CodeBuilder.RenderArgDeclaration> renderArgs
           
 IDialect requiredDialect
           
 ICodeType templateDefLang
           
protected  String tmpl
           
 
Fields inherited from class org.rythmengine.utils.TextBuilder
__buffer, __caller
 
Constructor Summary
CodeBuilder()
           
CodeBuilder(String template, String className, String tagName, org.rythmengine.internal.compiler.TemplateClass templateClass, RythmEngine engine, IDialect requiredDialect)
           
 
Method Summary
 void addBuilder(TextBuilder builder)
           
 void addImport(String imprt, int lineNo)
           
 String addInclude(String include, int lineNo)
           
 String addIncludes(String includes, int lineNo)
           
 String addInlineInclude(String inlineTemplate, int lineNo)
           
 void addRenderArgs(CodeBuilder.RenderArgDeclaration declaration)
           
 void addRenderArgs(int lineNo, String type, String name)
           
 void addRenderArgs(int lineNo, String type, String name, String defVal)
           
 void addRenderArgsIfNotDeclared(int lineNo, String type, String name)
           
 boolean basicTemplate()
           
 TextBuilder build()
          Sub class could implement this method to append the generated source code to the buffer
 String className()
           
 void clear()
          Reset to the state before construction
 CodeBuilder.InlineTag defTag(String tagName, String retType, String signature, String body)
           
 void endTag(CodeBuilder.InlineTag tag)
           
 RythmEngine engine()
           
protected  String extended()
           
 org.rythmengine.internal.compiler.TemplateClass getExtendedTemplateClass()
           
 List<TextBuilder> getMacro(String macro)
           
 String getRenderArgType(String name)
           
 org.rythmengine.internal.compiler.TemplateClass getTemplateClass()
           
 boolean hasMacro(String macro)
           
 String includingClassName()
           
 boolean isLastBuilderLiteral()
           
 boolean isRythmTemplate()
           
 boolean lastIsBlockToken()
           
 void merge(CodeBuilder codeBuilder)
           
 boolean needsPrint(String tagName)
           
 String newVarName()
           
protected  void pBuild()
           
protected  void pClassClose()
           
protected  void pClassOpen()
           
protected  void pExtendInitArgCode()
           
protected  void pImports()
           
protected  void pInitCode()
           
protected  void pInlineTags()
           
 void popMacro()
           
protected  void pPackage()
           
protected  void pRenderArgs()
           
static String preventInfiniteLoop(String code)
           
protected  void pSetup()
           
protected  void pTagImpl()
           
 void pushMacro(String macro)
           
 void removeSpaceTillLastLineBreak(IContext ctx)
          If from the current cursor till last linebreak are all space, then remove all those spaces and the last line break
 void removeSpaceToLastLineBreak(IContext ctx)
          If from the current cursor to last linebreak are all space, then remove all those spaces and the last line break
 void rewind()
          Rewind to the state when construction finished
 void setExtended_deprecated(String extended, org.rythmengine.internal.parser.build_in.InvokeTemplateParser.ParameterDeclarationList args, int lineNo)
           
 void setExtended(Class<? extends TemplateBase> c)
           
 void setExtended(String extended, org.rythmengine.internal.parser.build_in.InvokeTemplateParser.ParameterDeclarationList args, int lineNo)
           
 void setInitCode(String code)
           
 void setLogTime()
           
 
Methods inherited from class org.rythmengine.utils.TextBuilder
__append, __append, __append, __append, __append, __append, __append, __append, __append, __getBuffer, __setBuffer, buffer, caller, clone, getSelfOut, np, p, p, p, p, p, p, p, p, p, p2t, p2tn, p3t, p3tn, p4t, p4tn, pn, pn, pt, ptn, setSelfOut, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected static final ILogger logger

templateDefLang

public ICodeType templateDefLang

tmpl

protected String tmpl

includingCName

public String includingCName

imports

public Set<String> imports

renderArgs

public Map<String,CodeBuilder.RenderArgDeclaration> renderArgs

requiredDialect

public transient IDialect requiredDialect

logTime

protected boolean logTime

removeNextLF

public boolean removeNextLF

buildBody

public String buildBody

INTERRUPT_CODE

public static final String INTERRUPT_CODE
See Also:
Constant Field Values
Constructor Detail

CodeBuilder

public CodeBuilder(String template,
                   String className,
                   String tagName,
                   org.rythmengine.internal.compiler.TemplateClass templateClass,
                   RythmEngine engine,
                   IDialect requiredDialect)

CodeBuilder

public CodeBuilder()
Method Detail

engine

public RythmEngine engine()

isRythmTemplate

public boolean isRythmTemplate()

setInitCode

public void setInitCode(String code)

extended

protected String extended()

getExtendedTemplateClass

public org.rythmengine.internal.compiler.TemplateClass getExtendedTemplateClass()

isLastBuilderLiteral

public boolean isLastBuilderLiteral()

getTemplateClass

public org.rythmengine.internal.compiler.TemplateClass getTemplateClass()

basicTemplate

public boolean basicTemplate()

clear

public void clear()
Reset to the state before construction


rewind

public void rewind()
Rewind to the state when construction finished


merge

public void merge(CodeBuilder codeBuilder)

className

public String className()

includingClassName

public String includingClassName()

addImport

public void addImport(String imprt,
                      int lineNo)

needsPrint

public boolean needsPrint(String tagName)

defTag

public CodeBuilder.InlineTag defTag(String tagName,
                                    String retType,
                                    String signature,
                                    String body)

endTag

public void endTag(CodeBuilder.InlineTag tag)

addIncludes

public String addIncludes(String includes,
                          int lineNo)

addInclude

public String addInclude(String include,
                         int lineNo)

addInlineInclude

public String addInlineInclude(String inlineTemplate,
                               int lineNo)

setExtended

public void setExtended(Class<? extends TemplateBase> c)

setExtended

public void setExtended(String extended,
                        org.rythmengine.internal.parser.build_in.InvokeTemplateParser.ParameterDeclarationList args,
                        int lineNo)

setExtended_deprecated

public void setExtended_deprecated(String extended,
                                   org.rythmengine.internal.parser.build_in.InvokeTemplateParser.ParameterDeclarationList args,
                                   int lineNo)

setLogTime

public void setLogTime()

getRenderArgType

public String getRenderArgType(String name)

addRenderArgs

public void addRenderArgs(CodeBuilder.RenderArgDeclaration declaration)

addRenderArgs

public void addRenderArgs(int lineNo,
                          String type,
                          String name,
                          String defVal)

addRenderArgs

public void addRenderArgs(int lineNo,
                          String type,
                          String name)

addRenderArgsIfNotDeclared

public void addRenderArgsIfNotDeclared(int lineNo,
                                       String type,
                                       String name)

pushMacro

public void pushMacro(String macro)

popMacro

public void popMacro()

hasMacro

public boolean hasMacro(String macro)

getMacro

public List<TextBuilder> getMacro(String macro)

lastIsBlockToken

public boolean lastIsBlockToken()

addBuilder

public void addBuilder(TextBuilder builder)

removeSpaceToLastLineBreak

public void removeSpaceToLastLineBreak(IContext ctx)
If from the current cursor to last linebreak are all space, then remove all those spaces and the last line break


removeSpaceTillLastLineBreak

public void removeSpaceTillLastLineBreak(IContext ctx)
If from the current cursor till last linebreak are all space, then remove all those spaces and the last line break


build

public TextBuilder build()
Description copied from class: TextBuilder
Sub class could implement this method to append the generated source code to the buffer

Overrides:
build in class TextBuilder
Returns:
this builder

pPackage

protected void pPackage()

pImports

protected void pImports()

pClassOpen

protected void pClassOpen()

pClassClose

protected void pClassClose()

pRenderArgs

protected void pRenderArgs()

pExtendInitArgCode

protected void pExtendInitArgCode()

pSetup

protected void pSetup()

pInitCode

protected void pInitCode()

pTagImpl

protected void pTagImpl()

pInlineTags

protected void pInlineTags()

pBuild

protected void pBuild()

newVarName

public String newVarName()

preventInfiniteLoop

public static String preventInfiniteLoop(String code)


Copyright © 2013. All Rights Reserved.