org.apache.oozie.util
Class ELEvaluator

java.lang.Object
  extended by org.apache.oozie.util.ELEvaluator

public class ELEvaluator
extends Object

JSP Expression Language Evaluator.

It provides a more convenient way of using the JSP EL Evaluator.


Nested Class Summary
static class ELEvaluator.Context
          Provides functions and variables for the EL evaluator.
 
Constructor Summary
ELEvaluator()
          Creates an ELEvaluator with no functions and no variables defined.
ELEvaluator(ELEvaluator.Context context)
          Creates an ELEvaluator with the functions and variables defined in the given ELEvaluator.Context.
 
Method Summary
 boolean checkForExistence(String expr, String sequence)
          Check if the input expression contains sequence statically.
<T> T
evaluate(String expr, Class<T> clazz)
          Evaluate an EL expression.
 ELEvaluator.Context getContext()
          Return the context with the functions and variables of the EL evaluator.
static ELEvaluator getCurrent()
          If within the scope of a EL evaluation call, it gives access to the ELEvaluator instance performing the EL evaluation.
 Object getVariable(String name)
          Convenience method that returns a variable from the EL evaluator context.
 void setVariable(String name, Object value)
          Convenience method that sets a variable in the EL evaluator context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ELEvaluator

public ELEvaluator()
Creates an ELEvaluator with no functions and no variables defined.


ELEvaluator

public ELEvaluator(ELEvaluator.Context context)
Creates an ELEvaluator with the functions and variables defined in the given ELEvaluator.Context.

Parameters:
context - the ELSupport with functions and variables to be available for EL evalution.
Method Detail

getCurrent

public static ELEvaluator getCurrent()
If within the scope of a EL evaluation call, it gives access to the ELEvaluator instance performing the EL evaluation.

This is useful for EL function methods to get access to the variables of the Evaluator. Because of this, ELEvaluator variables can be used to pass context to EL function methods (which must be static methods).

Returns:
the ELEvaluator in scope, or null if none.

getContext

public ELEvaluator.Context getContext()
Return the context with the functions and variables of the EL evaluator.

Returns:
the context.

setVariable

public void setVariable(String name,
                        Object value)
Convenience method that sets a variable in the EL evaluator context.

Parameters:
name - variable name.
value - variable value.

getVariable

public Object getVariable(String name)
Convenience method that returns a variable from the EL evaluator context.

Parameters:
name - variable name.
Returns:
the variable value, null if not defined.

evaluate

public <T> T evaluate(String expr,
                      Class<T> clazz)
           throws Exception
Evaluate an EL expression.

Parameters:
expr - EL expression to evaluate.
clazz - return type of the EL expression.
Returns:
the object the EL expression evaluated to.
Throws:
Exception - thrown if an EL function failed due to a transient error or EL expression could not be evaluated.

checkForExistence

public boolean checkForExistence(String expr,
                                 String sequence)
                          throws Exception
Check if the input expression contains sequence statically. for example identify if "," is present outside of a function invocation in the given expression. Ex "${func('abc')},${func('def'}",

Parameters:
expr - - Expression string
sequence - - char sequence to check in the input expression
Returns:
true if present
Throws:
Exception - Exception thrown if an EL function failed due to a transient error or EL expression could not be parsed


Copyright © 2013 Apache Software Foundation. All Rights Reserved.