org.hibernate.validator.constraints.impl.scriptassert
Class ScriptEvaluator
java.lang.Object
org.hibernate.validator.constraints.impl.scriptassert.ScriptEvaluator
public class ScriptEvaluator
- extends Object
A wrapper around JSR 223 ScriptEngines. This class is thread-safe.
- Author:
- Gunnar Morling
|
Method Summary |
boolean |
evaluate(String script,
Object obj,
String objectAlias)
Makes the given object available in then engine-scoped script context and executes the given script. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ScriptEvaluator
public ScriptEvaluator(ScriptEngine engine)
- Creates a new script executor.
- Parameters:
engine - The engine to be wrapped.
evaluate
public boolean evaluate(String script,
Object obj,
String objectAlias)
- Makes the given object available in then engine-scoped script context and executes the given script.
The execution of the script happens either synchronized or unsynchronized, depending on the engine's
threading abilities.
- Parameters:
script - The script to be executed.obj - The object to be put into the context.objectAlias - The name under which the given object shall be put into the context.
- Returns:
- The script's result.
- Throws:
javax.validation.ConstraintDeclarationException - In case of any errors during script execution or if the script
returned null or another type than Boolean.
Copyright © 2011 Oracle Corporation. All Rights Reserved.