public interface Evaluator
Modifier and Type | Field and Description |
---|---|
static String |
CLASSLOADER_VARIABLE
Variable name for classloader instance.
|
static String |
GLOBAL_VARIABLE
Name of specific variable referring to global properties.
|
static String |
MATH_CONTEXT_VARIABLE
Name of a specific variable holding a mathematical context.
|
Modifier and Type | Method and Description |
---|---|
Object |
getAttribute(Object instance,
String attributeName)
Reads the value for the named attribute from the given instance.
|
Context |
getContext()
Provides the current context object.
|
Object |
getDefaultExpression()
Provides the defined default expression.
|
Locale |
getLocale()
Provides the currently defined locale.
|
String |
getLocaleKey()
A locale key, default value is
getLocale() .getLanguage().toUpperCase()}. |
Writer |
getOut()
Provides a writer to the output.
|
String |
getStack()
Provides a textual representation of the current evaluation stack.
|
Printable |
getTemplate(String type,
String name,
Map<String,Object> params)
Looks up a variable based on the given type and name and provides a printable template initialized with the given parameters.
|
String |
getTopStackElement()
The currently evaluated stack element as string - for debugging.
|
Object |
getVariableValue(String variableName)
Looks up the value stored for the variable having the given name.
|
void |
include(String type,
Object toInclude,
Map<String,Object> params)
Includes something in the output.
|
Object |
invokeMethod(Object instance,
String methodName,
List<Object> args)
Invokes the named method on the given instance.
|
boolean |
isDebugging()
Indicates, whether this evaluation is operating in debugging mode.
|
void |
logDebug(String message)
Logs a debug message.
|
void |
logError(int line,
int col,
String message)
Logs an error message giving a line and column to locate the cause within the template.
|
void |
logError(int line,
int col,
String message,
Throwable t)
Logs an error message giving a line and column to locate the cause within the template.
|
void |
logError(String message)
Logs an error message.
|
void |
logError(String message,
Throwable throwable)
Logs an error message and a trace.
|
void |
logInfo(String message)
Logs an information message.
|
void |
logWarning(String message)
Logs a warning message.
|
TemplateDocument |
parse(Reader source)
Parses the given source and creates an evaluatable template.
|
TemplateDocument |
parse(String source)
Parses the given source text and creates an evaluatable template.
|
Context |
popContext()
Provides and pops the current context from this evaluation.
|
void |
print(Object value)
Print an object instance to the
output . |
void |
print(Printable template)
Instructs to evaluate and print the given template.
|
void |
pushContext(Context context)
Set a new top context.
|
Context |
pushContext(String name)
Will push a new context.
|
Context |
pushContext(String name,
Object target)
Will push a new context and set the target object as #this.
|
Context |
pushContext(String name,
String info)
Will push a new context and an info text on the stack
|
Object |
resolveReference(List<Object> params,
Map<String,Object> namedParams)
Resolves a firstspirit reference by the given parameters corresponding to the definition of CMS_REF.
|
void |
setDefaultExpression(Object value)
Sets the default expression to be used for output when some value evaluates to null or undefined.
|
void |
setErrorOut(PrintWriter out)
Sets the error output writer.
|
void |
setErrorOut(Writer out)
Shortcut for
setErrorOut(new PrintWriter(out)) . |
void |
setLocale(Locale value)
Defines the locale to be used for further evaluation.
|
void |
setLocaleKey(String value)
Defines the locale key to be used for further evaluation.
|
void |
setMaxStackSize(int value)
Defines the maximum stack size for evaluation.
|
void |
setOut(Writer out)
Sets the writer for the output.
|
void |
setVariableValue(String variableName,
Object value)
Stores the given value for the variable with the given name.
|
static final String MATH_CONTEXT_VARIABLE
static final String GLOBAL_VARIABLE
static final String CLASSLOADER_VARIABLE
Object getVariableValue(String variableName)
variableName
- The variable's name.void setVariableValue(String variableName, Object value)
variableName
- The variable's name.value
- The value to be stored.Object resolveReference(List<Object> params, Map<String,Object> namedParams) throws Exception
params
- A list of parameters.namedParams
- A list of named parameters.Exception
void include(String type, Object toInclude, Map<String,Object> params) throws IOException
type
- recognized types are: "file", "url", "jar"
toInclude
- used to determine the source, e.g. treated as file name, File
object, ...params
- recognized parameter keys are: "encoding", "parse", "info"
IOException
- if including the source failed.Object getAttribute(Object instance, String attributeName) throws Exception
instance
- The instance.attributeName
- The name of the attribute.Exception
- if accessing the attribute failed for some reason.Object invokeMethod(Object instance, String methodName, List<Object> args) throws Exception
instance
- The instance.methodName
- The name of the method.args
- Arguments for the method to be invoked.Exception
- if invoking the method failed for some reason.void print(Object value) throws IOException
output
.value
- objectIOException
Context getContext()
void setLocale(Locale value)
value
- The locale.Locale getLocale()
String getLocaleKey()
getLocale()
.getLanguage().toUpperCase()}.setLocaleKey(String)
void setLocaleKey(String value)
value
- The locale key.getLocaleKey()
void logError(String message)
message
- The error message.void logError(String message, Throwable throwable)
message
- The error message.throwable
- A throwable.void logError(int line, int col, String message)
line
- The line.col
- The coumn.message
- The error message.void logError(int line, int col, String message, Throwable t)
line
- The line.col
- The coumn.message
- The error message.t
- A throwable.void logWarning(String message)
message
- The warning message.void logInfo(String message)
message
- The information message.void logDebug(String message)
message
- The debug message.Context pushContext(String name, String info)
name
- the name of the new contextinfo
- the text wich is put on the context stackpushContext(Context)
Context pushContext(String name)
pushContext(Context)
for further informations.name
- the name of the new contextpushContext(Context)
Context pushContext(String name, Object target)
name
- The name of the new context.target
- The target object the context operates on.pushContext(String)
void pushContext(Context context)
Context.setParentContext(Context)
on the providedcontext object. try .. finally
block: evaluator.pushContext(myContext) try { ... } finally { evaluator.popContext(); }
context
- the new top context, null
is not allowedpopContext()
Context popContext()
pushContext(Context)
Writer getOut()
void setOut(Writer out)
out
- A writer.void setErrorOut(Writer out)
setErrorOut(new PrintWriter(out))
.out
- A writer.void setErrorOut(PrintWriter out)
out
- A writer.void print(Printable template) throws IOException
template
- A template.IOException
Printable getTemplate(String type, String name, Map<String,Object> params) throws IOException
type
- The template type.name
- The variable name.params
- The parameters.IOException
String getStack()
String getTopStackElement()
void setDefaultExpression(Object value)
value
- The default expression.Object getDefaultExpression()
void setMaxStackSize(int value)
value
- The maximum stack size.TemplateDocument parse(String source)
source
- The source.TemplateDocument parse(Reader source) throws IOException
source
- The source.IOException
boolean isDebugging()
true
, if debugging.Copyright © 2021 e-Spirit AG. All Rights Reserved. Build 5.2.210210