|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.ujac.util.template.BaseTemplateInterpreter
public abstract class BaseTemplateInterpreter
Name: TemplateInterpreter
Description: Description of the class.
Field Summary | |
---|---|
protected ExpressionInterpreter |
exi
The expression interpeter to use. |
protected ExpressionFilter |
expressionFilter
The expression filter. |
protected Map |
tokenTypes
The template token registry (_if_, _foreach_, _loop_, ...) |
Constructor Summary | |
---|---|
|
BaseTemplateInterpreter()
Constructs a TemplateInterpreter instance with specific attributes. |
|
BaseTemplateInterpreter(ExpressionInterpreter exi)
Constructs a TemplateInterpreter instance with specific attributes. |
protected |
BaseTemplateInterpreter(ExpressionInterpreter exi,
Map tokenTypes)
Constructs a TemplateInterpreter instance with specific attributes. |
Method Summary | |
---|---|
TemplateToken |
createToken(String tokenName)
Gets the token type that matches the given text. |
boolean |
evalBooleanExpr(Operand operand,
TemplateContext ctx)
Evaluates an expression as a boolean value. |
boolean |
evalBooleanExpr(String expression,
TemplateContext ctx)
Evaluates an expression as a boolean value. |
Date |
evalDateExpr(Operand operand,
TemplateContext ctx)
Evaluates an expression as a Date value. |
Date |
evalDateExpr(String expression,
TemplateContext ctx)
Evaluates an expression as a Date value. |
double |
evalDoubleExpr(Operand operand,
TemplateContext ctx)
Evaluates an expression as a double value. |
double |
evalDoubleExpr(String expression,
TemplateContext ctx)
Evaluates an expression as a double value. |
float |
evalFloatExpr(Operand operand,
TemplateContext ctx)
Evaluates an expression as a float value. |
float |
evalFloatExpr(String expression,
TemplateContext ctx)
Evaluates an expression as a float value. |
int |
evalIntExpr(Operand operand,
TemplateContext ctx)
Evaluates an expression as an int value. |
int |
evalIntExpr(String expression,
TemplateContext ctx)
Evaluates an expression as an int value. |
long |
evalLongExpr(Operand operand,
TemplateContext ctx)
Evaluates an expression as a long value. |
long |
evalLongExpr(String expression,
TemplateContext ctx)
Evaluates an expression as a long value. |
Object |
evalObjectExpr(Operand operand,
TemplateContext ctx)
Evaluates an expression as an Object. |
Object |
evalObjectExpr(String expression,
TemplateContext ctx)
Evaluates an expression as an Object. |
String |
evalStringExpr(Operand operand,
TemplateContext ctx)
Evaluates an expression as a String value. |
String |
evalStringExpr(String expression,
TemplateContext ctx)
Evaluates an expression as a String value. |
Time |
evalTimeExpr(Operand operand,
TemplateContext ctx)
Evaluates an expression as a Time value. |
Time |
evalTimeExpr(String expression,
TemplateContext ctx)
Evaluates an expression as a Time value. |
Timestamp |
evalTimestampExpr(Operand operand,
TemplateContext ctx)
Evaluates an expression as a Timestamp value. |
Timestamp |
evalTimestampExpr(String expression,
TemplateContext ctx)
Evaluates an expression as a Timestamp value. |
String |
execute(String template,
TemplateContext ctx)
Executes the given template. |
void |
execute(String template,
Writer writer,
TemplateContext ctx)
Executes the given template. |
void |
execute(TemplateRoot template,
Writer writer,
TemplateContext ctx)
Executes the given template. |
ExpressionFilter |
getExpressionFilter()
Getter method for the the property expressionFilter. |
Class |
getTokenType(String tokenName)
Gets the statement type that matches the given name. |
TemplateRoot |
parse(char[] source,
int offset,
int length)
Parses the given template source code. |
TemplateRoot |
parse(String source)
Parses the given template source code. |
abstract int |
parse(TemplateTokenContainer tokenContainer)
Parses the given template token. |
ExpressionTuple |
parseExpr(char[] source,
int offset,
int lastPos)
Parses an expression from the given source code range. |
ExpressionTuple |
parseExpr(String source)
Parses an expression from the given source code range. |
protected void |
registerTokenTypes()
Registers the token types. |
void |
setExpressionFilter(ExpressionFilter expressionFilter)
Setter method for the the property expressionFilter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ExpressionInterpreter exi
protected Map tokenTypes
protected ExpressionFilter expressionFilter
Constructor Detail |
---|
public BaseTemplateInterpreter()
public BaseTemplateInterpreter(ExpressionInterpreter exi)
exi
- The expression interpreter to use.protected BaseTemplateInterpreter(ExpressionInterpreter exi, Map tokenTypes)
exi
- The expression interpreter to use.tokenTypes
- The template token registry (_if_, _foreach_, _loop_, ...)Method Detail |
---|
protected void registerTokenTypes()
public TemplateRoot parse(String source) throws TemplateException, IOException
parse
in interface TemplateInterpreter
source
- The source to parse.
TemplateException
- If the expression could not be
successfuly resolved
IOException
- In case a I/O problem occured while writing the
expression result.public TemplateRoot parse(char[] source, int offset, int length) throws TemplateException, IOException
source
- The source to parse.offset
- The start position within the source.length
- The length of the area to parse.
TemplateException
- If the expression could not be
successfuly resolved
IOException
- In case a I/O problem occured while writing the
expression result.public abstract int parse(TemplateTokenContainer tokenContainer) throws TemplateException, IOException
tokenContainer
- The token container to fill.
TemplateException
- If the expression could not be
successfuly resolved
IOException
- In case a I/O problem occured while writing the
expression result.public String execute(String template, TemplateContext ctx) throws TemplateException
execute
in interface TemplateInterpreter
template
- The source code of the template to execute.ctx
- The template context to use.
TemplateException
- If the an expression could not be
successfuly resolvedpublic void execute(String template, Writer writer, TemplateContext ctx) throws TemplateException, IOException
execute
in interface TemplateInterpreter
template
- The source code of the template to execute.writer
- The writer to output the result to.ctx
- The template context to use.
TemplateException
- If the an expression could not be
successfuly resolved
IOException
- If something went wrong while writing the
result to the given writer.public void execute(TemplateRoot template, Writer writer, TemplateContext ctx) throws TemplateException, IOException
execute
in interface TemplateInterpreter
template
- The root element of the template parse result.writer
- The writer to output the result to.ctx
- The template context to use.
TemplateException
- If the an expression could not be
successfuly resolved
IOException
- If something went wrong while writing the
result to the given writer.public final ExpressionTuple parseExpr(String source) throws ExpressionException
source
- The source code, to be parsed.
ExpressionException
- If the expression could not be successfuly resolvedpublic final ExpressionTuple parseExpr(char[] source, int offset, int lastPos) throws ExpressionException
source
- The source code, to be parsed.offset
- The offset from which to parse the expression string.lastPos
- The last position to which to parse the expression string.
ExpressionException
- If the expression could not be successfuly resolvedpublic final boolean evalBooleanExpr(Operand operand, TemplateContext ctx) throws ExpressionException
operand
- The operand to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic final boolean evalBooleanExpr(String expression, TemplateContext ctx) throws ExpressionException
evalBooleanExpr
in interface TemplateInterpreter
expression
- The expression to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic int evalIntExpr(Operand operand, TemplateContext ctx) throws ExpressionException
operand
- The operand to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic int evalIntExpr(String expression, TemplateContext ctx) throws ExpressionException
evalIntExpr
in interface TemplateInterpreter
expression
- The expression to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic long evalLongExpr(Operand operand, TemplateContext ctx) throws ExpressionException
operand
- The operand to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic long evalLongExpr(String expression, TemplateContext ctx) throws ExpressionException
evalLongExpr
in interface TemplateInterpreter
expression
- The expression to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic float evalFloatExpr(Operand operand, TemplateContext ctx) throws ExpressionException
operand
- The operand to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic float evalFloatExpr(String expression, TemplateContext ctx) throws ExpressionException
evalFloatExpr
in interface TemplateInterpreter
expression
- The expression to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic double evalDoubleExpr(Operand operand, TemplateContext ctx) throws ExpressionException
operand
- The operand to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic double evalDoubleExpr(String expression, TemplateContext ctx) throws ExpressionException
evalDoubleExpr
in interface TemplateInterpreter
expression
- The expression to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic Date evalDateExpr(Operand operand, TemplateContext ctx) throws ExpressionException
operand
- The operand to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic Date evalDateExpr(String expression, TemplateContext ctx) throws ExpressionException
evalDateExpr
in interface TemplateInterpreter
expression
- The expression to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic Time evalTimeExpr(Operand operand, TemplateContext ctx) throws ExpressionException
operand
- The operand to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic Time evalTimeExpr(String expression, TemplateContext ctx) throws ExpressionException
evalTimeExpr
in interface TemplateInterpreter
expression
- The expression to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic Timestamp evalTimestampExpr(Operand operand, TemplateContext ctx) throws ExpressionException
operand
- The operand to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic Timestamp evalTimestampExpr(String expression, TemplateContext ctx) throws ExpressionException
evalTimestampExpr
in interface TemplateInterpreter
expression
- The expression to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic String evalStringExpr(Operand operand, TemplateContext ctx) throws ExpressionException
operand
- The operand to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic String evalStringExpr(String expression, TemplateContext ctx) throws ExpressionException
evalStringExpr
in interface TemplateInterpreter
expression
- The expression to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic final Object evalObjectExpr(Operand operand, TemplateContext ctx) throws ExpressionException
operand
- The operand to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic final Object evalObjectExpr(String expression, TemplateContext ctx) throws ExpressionException
evalObjectExpr
in interface TemplateInterpreter
expression
- The expression to evaluate.ctx
- The template context.
ExpressionException
- If the expression could not be successfuly resolvedpublic final TemplateToken createToken(String tokenName) throws StatementException
tokenName
- The token name.
StatementException
- In case the instantiation failed.public final Class getTokenType(String tokenName)
tokenName
- The token name.
public ExpressionFilter getExpressionFilter()
getExpressionFilter
in interface TemplateInterpreter
public void setExpressionFilter(ExpressionFilter expressionFilter)
setExpressionFilter
in interface TemplateInterpreter
expressionFilter
- The value to set for the property expressionFilter.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |