/** * Evaluates an EL expression, and coerces the result to the specified type. * @param expression The EL expression to be evaluated. * @param expectedType Specifies the type that the resultant evaluation * will be coerced to. * @return The result of the expression evaluation. */ public Object getValue(String expression, Class<?> expectedType) { ValueExpression exp = factory.createValueExpression( elManager.getELContext(), bracket(expression), expectedType); return exp.getValue(elManager.getELContext()); }
/** * Register an evaluation listener. * * @param listener The evaluation listener to be added. */ public void addEvaluationListener(EvaluationListener listener) { getELContext().addEvaluationListener(listener); } }
/** * Define a bean in the local bean repository * @param name The name of the bean * @param bean The bean instance to be defined. If null, the definition * of the bean is removed. */ public Object defineBean(String name, Object bean) { Object ret = getELContext().getBeans().get(name); getELContext().getBeans().put(name, bean); return ret; }
/** * Add an user defined ELResolver to the list of ELResolvers. * Can be called multiple times. The new ELResolver is * placed ahead of the default ELResolvers. The list of the ELResolvers * added this way are ordered chronologically. * * @param elr The ELResolver to be added to the list of ELResolvers in * ELContext. * @see StandardELContext#addELResolver */ public void addELResolver(ELResolver elr) { getELContext().addELResolver(elr); }
/** * Sets an expression with a new value. * The target expression is evaluated, up to the last property resolution, * and the resultant (base, property) pair is set to the provided value. * * @param expression The target expression * @param value The new value to set. * @throws PropertyNotFoundException if one of the property * resolutions failed because a specified variable or property * does not exist or is not readable. * @throws PropertyNotWritableException if the final variable or * property resolution failed because the specified * variable or property is not writable. * @throws ELException if an exception was thrown while attempting to * set the property or variable. The thrown exception * must be included as the cause property of this exception, if * available. */ public void setValue(String expression, Object value) { ValueExpression exp = factory.createValueExpression( elManager.getELContext(), bracket(expression), Object.class); exp.setValue(elManager.getELContext(), value); }
/** * Import a static field or method. The class of the static member must be * loadable from the classloader, at class resolution time. * @param staticMemberName The full class name of the class to be imported * @throws ELException if the name is not a full class name. */ public void importStatic(String staticMemberName) throws ELException { getELContext().getImportHandler().importStatic(staticMemberName); }
/** * Register a BeanNameResolver. * Construct a BeanNameELResolver with the BeanNameResolver and add it * to the list of ELResolvers. * Once registered, the BeanNameResolver cannot be removed. * @param bnr The BeanNameResolver to be registered. */ public void addBeanNameResolver(BeanNameResolver bnr) { getELContext().addELResolver(new BeanNameELResolver(bnr)); }
/** * Assign an EL expression to an EL variable. The expression is parsed, * but not evaluated, and the parsed expression is mapped to the EL * variable in the local variable map. * Any previously assigned expression to the same variable will be replaced. * If the expression is <code>null</code>, the variable will be removed. * @param var The name of the variable. * @param expression The EL expression to be assigned to the variable. */ public void setVariable(String var, String expression) { ValueExpression exp = factory.createValueExpression( elManager.getELContext(), bracket(expression), Object.class); elManager.setVariable(var, exp); }
/** * Maps a static method to an EL function. * @param prefix The namespace of the functions, can be "". * @param function The name of the function. * @param meth The static method to be invoked when the function is used. */ public void mapFunction(String prefix, String function, Method meth) { getELContext().getFunctionMapper().mapFunction(prefix, function, meth); }
/** * Import a class. The imported class must be loadable from the classloader * at the expression evaluation time. * @param className The full class name of the class to be imported * @throws ELException if the name is not a full class name. */ public void importClass(String className) throws ELException { getELContext().getImportHandler().importClass(className); }
/** * Import a package. At the expression evaluation time, the imported package * name will be used to construct the full class name, which will then be * used to load the class. Inherently, this is less efficient than * importing a class. * @param packageName The package name to be imported */ public void importPackage(String packageName) { getELContext().getImportHandler().importPackage(packageName); }
/** * Assign a ValueExpression to an EL variable, replacing * any previous assignment to the same variable. * The assignment for the variable is removed if * the expression is <code>null</code>. * * @param variable The variable name * @param expression The ValueExpression to be assigned * to the variable. */ public void setVariable(String variable, ValueExpression expression) { getELContext().getVariableMapper().setVariable(variable, expression); }
/** * Define a bean in the local bean repository * @param name The name of the bean * @param bean The bean instance to be defined. If null, the definition * of the bean is removed. */ public Object defineBean(String name, Object bean) { Object ret = getELContext().getBeans().get(name); getELContext().getBeans().put(name, bean); return ret; }
/** * Register an evaluation listener. * * @param listener The evaluation listener to be added. */ public void addEvaluationListener(EvaluationListener listener) { getELContext().addEvaluationListener(listener); } }
/** * Define a bean in the local bean repository * @param name The name of the bean * @param bean The bean instance to be defined. If null, the definition * of the bean is removed. */ public Object defineBean(String name, Object bean) { Object ret = getELContext().getBeans().get(name); getELContext().getBeans().put(name, bean); return ret; }
/** * Define a bean in the local bean repository * @param name The name of the bean * @param bean The bean instance to be defined. If null, the definition * of the bean is removed. */ public Object defineBean(String name, Object bean) { Object ret = getELContext().getBeans().get(name); getELContext().getBeans().put(name, bean); return ret; }
/** * Register a BeanNameResolver. * Construct a BeanNameELResolver with the BeanNameResolver and add it * to the list of ELResolvers. * Once registered, the BeanNameResolver cannot be removed. * @param bnr The BeanNameResolver to be registered. */ public void addBeanNameResolver(BeanNameResolver bnr) { getELContext().addELResolver(new BeanNameELResolver(bnr)); }
/** * Import a class. The imported class must be loadable from the classloader * at the expression evaluation time. * @param className The full class name of the class to be imported * @throws ELException if the name is not a full class name. */ public void importClass(String className) throws ELException { getELContext().getImportHandler().importClass(className); }
/** * Import a package. At the expression evaluation time, the imported package * name will be used to construct the full class name, which will then be * used to load the class. Inherently, this is less efficient than * importing a class. * @param packageName The package name to be imported */ public void importPackage(String packageName) { getELContext().getImportHandler().importPackage(packageName); }
/** * Maps a static method to an EL function. * @param prefix The namespace of the functions, can be "". * @param function The name of the function. * @param meth The static method to be invoked when the function is used. */ public void mapFunction(String prefix, String function, Method meth) { getELContext().getFunctionMapper().mapFunction(prefix, function, meth); }