org.rythmengine.internal
Class TemplateParser

java.lang.Object
  extended by org.rythmengine.internal.TemplateParser
All Implemented Interfaces:
IContext

public class TemplateParser
extends Object
implements IContext


Nested Class Summary
static class TemplateParser.ComplexExpressionException
           
static class TemplateParser.ExitInstruction
           
static class TemplateParser.NoFreeLoopException
           
static class TemplateParser.ScriptingDisabledException
           
static class TemplateParser.TypeDeclarationException
           
 
Nested classes/interfaces inherited from interface org.rythmengine.internal.IContext
IContext.Break, IContext.Continue
 
Constructor Summary
TemplateParser(CodeBuilder cb)
           
 
Method Summary
 String closeBlock()
          Notify context to close current block and return the block close carets
 boolean compactMode()
           
 IBlockHandler currentBlock()
          Return current block handler
 int currentLine()
          Return current line number
 int cursor()
           
 void enterDirectiveComment()
           
 CodeBuilder getCodeBuilder()
          Return the root source code builder
 IDialect getDialect()
           
 RythmEngine getEngine()
           
 String getRemain()
          Return the remaining template string that has not parsed yet
 org.rythmengine.internal.compiler.TemplateClass getTemplateClass()
           
 String getTemplateSource(int start, int end)
          Return any segment of template source
 boolean hasRemain()
          Do have have remain template content to be parsed
 boolean insideBody()
           
 boolean insideBody2()
           
 boolean insideDirectiveComment()
           
 void leaveDirectiveComment()
           
 void openBlock(IBlockHandler bh)
          Notify context to enter a block
 char peek()
           
 IContext.Break peekBreak()
           
 ICodeType peekCodeType()
           
 Boolean peekCompact()
           
 IContext.Continue peekContinue()
           
 Boolean peekInsideBody()
           
 Boolean peekInsideBody2()
           
 Locale peekLocale()
           
 char pop()
           
 IContext.Break popBreak()
           
 ICodeType popCodeType()
           
 Boolean popCompact()
           
 IContext.Continue popContinue()
           
 Boolean popInsideBody()
           
 Boolean popInsideBody2()
           
 Locale popLocale()
           
 void pushBreak(IContext.Break b)
           
 void pushCodeType(ICodeType type)
           
 void pushCompact(Boolean compact)
           
 void pushContinue(IContext.Continue b)
           
 void pushInsideBody(Boolean b)
           
 void pushInsideBody2(Boolean b)
           
 void pushLocale(Locale locale)
           
 void setDialect(IDialect dialect)
           
 void shutdown()
           
 void step(int i)
          Move the current cursor i steps ahead
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateParser

public TemplateParser(CodeBuilder cb)
Method Detail

getTemplateClass

public org.rythmengine.internal.compiler.TemplateClass getTemplateClass()
Specified by:
getTemplateClass in interface IContext

getCodeBuilder

public CodeBuilder getCodeBuilder()
Description copied from interface: IContext
Return the root source code builder

Specified by:
getCodeBuilder in interface IContext
Returns:
the code builder

getDialect

public IDialect getDialect()
Specified by:
getDialect in interface IContext

setDialect

public void setDialect(IDialect dialect)
Specified by:
setDialect in interface IContext

getRemain

public String getRemain()
Description copied from interface: IContext
Return the remaining template string that has not parsed yet

Specified by:
getRemain in interface IContext
Returns:
remaining text to be parsed

cursor

public int cursor()
Specified by:
cursor in interface IContext

hasRemain

public boolean hasRemain()
Description copied from interface: IContext
Do have have remain template content to be parsed

Specified by:
hasRemain in interface IContext
Returns:
true if there are remaining text to be parsed

peek

public char peek()
Specified by:
peek in interface IContext
Returns:
the first remain character without moving cursor

pop

public char pop()
Specified by:
pop in interface IContext
Returns:
the first remain character and move the cursor one step

step

public void step(int i)
Description copied from interface: IContext
Move the current cursor i steps ahead

Specified by:
step in interface IContext

getTemplateSource

public String getTemplateSource(int start,
                                int end)
Description copied from interface: IContext
Return any segment of template source

Specified by:
getTemplateSource in interface IContext
Returns:
template source

openBlock

public void openBlock(IBlockHandler bh)
Description copied from interface: IContext
Notify context to enter a block

Specified by:
openBlock in interface IContext
Parameters:
bh - the block handler

currentBlock

public IBlockHandler currentBlock()
Description copied from interface: IContext
Return current block handler

Specified by:
currentBlock in interface IContext
Returns:
current block handler

closeBlock

public String closeBlock()
                  throws ParseException
Description copied from interface: IContext
Notify context to close current block and return the block close carets

Specified by:
closeBlock in interface IContext
Throws:
ParseException

currentLine

public int currentLine()
Description copied from interface: IContext
Return current line number

Specified by:
currentLine in interface IContext
Returns:
current parsing line

getEngine

public RythmEngine getEngine()
Specified by:
getEngine in interface IContext

compactMode

public boolean compactMode()
Specified by:
compactMode in interface IContext

pushCompact

public void pushCompact(Boolean compact)
Specified by:
pushCompact in interface IContext

peekCompact

public Boolean peekCompact()
Specified by:
peekCompact in interface IContext

popCompact

public Boolean popCompact()
Specified by:
popCompact in interface IContext

pushBreak

public void pushBreak(IContext.Break b)
Specified by:
pushBreak in interface IContext

peekBreak

public IContext.Break peekBreak()
Specified by:
peekBreak in interface IContext

popBreak

public IContext.Break popBreak()
Specified by:
popBreak in interface IContext

pushContinue

public void pushContinue(IContext.Continue b)
Specified by:
pushContinue in interface IContext

peekContinue

public IContext.Continue peekContinue()
Specified by:
peekContinue in interface IContext

popContinue

public IContext.Continue popContinue()
Specified by:
popContinue in interface IContext

insideBody

public boolean insideBody()
Specified by:
insideBody in interface IContext

pushInsideBody

public void pushInsideBody(Boolean b)
Specified by:
pushInsideBody in interface IContext

peekInsideBody

public Boolean peekInsideBody()
Specified by:
peekInsideBody in interface IContext

popInsideBody

public Boolean popInsideBody()
Specified by:
popInsideBody in interface IContext

insideBody2

public boolean insideBody2()
Specified by:
insideBody2 in interface IContext

pushInsideBody2

public void pushInsideBody2(Boolean b)
Specified by:
pushInsideBody2 in interface IContext

peekInsideBody2

public Boolean peekInsideBody2()
Specified by:
peekInsideBody2 in interface IContext

popInsideBody2

public Boolean popInsideBody2()
Specified by:
popInsideBody2 in interface IContext

insideDirectiveComment

public boolean insideDirectiveComment()
Specified by:
insideDirectiveComment in interface IContext

enterDirectiveComment

public void enterDirectiveComment()
Specified by:
enterDirectiveComment in interface IContext

leaveDirectiveComment

public void leaveDirectiveComment()
Specified by:
leaveDirectiveComment in interface IContext

peekCodeType

public ICodeType peekCodeType()
Specified by:
peekCodeType in interface IContext

pushCodeType

public void pushCodeType(ICodeType type)
Specified by:
pushCodeType in interface IContext

popCodeType

public ICodeType popCodeType()
Specified by:
popCodeType in interface IContext

peekLocale

public Locale peekLocale()
Specified by:
peekLocale in interface IContext

pushLocale

public void pushLocale(Locale locale)
Specified by:
pushLocale in interface IContext

popLocale

public Locale popLocale()
Specified by:
popLocale in interface IContext

shutdown

public void shutdown()


Copyright © 2013. All Rights Reserved.