com.google.sitebricks.compiler
Class MvelEvaluatorCompiler

java.lang.Object
  extended by com.google.sitebricks.compiler.MvelEvaluatorCompiler
All Implemented Interfaces:
EvaluatorCompiler

@NotThreadSafe
public class MvelEvaluatorCompiler
extends Object
implements EvaluatorCompiler

Author:
Dhanji R. Prasanna (dhanji@gmail com) TODO make this thread-safe when pages can be compiled on demand

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.google.sitebricks.compiler.EvaluatorCompiler
EvaluatorCompiler.CompileErrorDetail
 
Constructor Summary
MvelEvaluatorCompiler(Class<?> backingType)
           
MvelEvaluatorCompiler(Map<String,Type> backingTypes)
           
 
Method Summary
 Evaluator compile(String expression)
           
 boolean isWritable(String property)
           
 Type resolveEgressType(String expression)
           
 List<Token> tokenizeAndCompile(String template)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MvelEvaluatorCompiler

public MvelEvaluatorCompiler(Class<?> backingType)

MvelEvaluatorCompiler

public MvelEvaluatorCompiler(Map<String,Type> backingTypes)
Method Detail

resolveEgressType

public Type resolveEgressType(String expression)
                       throws ExpressionCompileException
Specified by:
resolveEgressType in interface EvaluatorCompiler
Parameters:
expression - An expression to compile against this compiler (and context class)
Returns:
Returns the egress type of the entire expression chain
Throws:
ExpressionCompileException - If there is a problem compiling the expression.

isWritable

public boolean isWritable(String property)
                   throws ExpressionCompileException
Specified by:
isWritable in interface EvaluatorCompiler
Parameters:
property - A property of this class to test.
Returns:
True if the property has a setter or reasonable alternative that can be written to by the evaluator produced by this compiler.
Throws:
ExpressionCompileException

compile

public Evaluator compile(String expression)
                  throws ExpressionCompileException
Specified by:
compile in interface EvaluatorCompiler
Parameters:
expression - An expression to compile against this compiler (and context class)
Returns:
Returns An evaluator that can execute the expression against the context class and a real instance of data.
Throws:
ExpressionCompileException - If there is a problem compiling the expression.

tokenizeAndCompile

public List<Token> tokenizeAndCompile(String template)
                               throws ExpressionCompileException
Specified by:
tokenizeAndCompile in interface EvaluatorCompiler
Parameters:
template - A String template with embedded EL expressions to convert into a list of evaluable tokens. These tokens evaluate against given data or simply render plain text as appropriate. Performs a compile of each expression against the context class of this EvaluatorCompiler.
Returns:
Returns the egress type of the entire expression chain
Throws:
ExpressionCompileException - If there is a problem compiling the expression.


Copyright © 2014. All rights reserved.