org.nuiton.wikitty
Class ScriptEvaluator

java.lang.Object
  extended by org.nuiton.wikitty.ScriptEvaluator

public class ScriptEvaluator
extends Object

Version:
$Revision: 784 $ Last update: $Date: 2011-04-12 10:26:26 +0200 (mar., 12 avril 2011) $ by : $Author: jcouteau $
Author:
poussin

Field Summary
protected static ScriptEngineManager scriptEnginManager
           
 
Constructor Summary
ScriptEvaluator()
           
 
Method Summary
static Object eval(ClassLoader classLoader, String name, String script, String mimetype, Map<String,Object> bindings)
          Evalue le script et retourne le retour de l'evaluation
static Map<String,Object> exec(ClassLoader classLoader, String name, String script, String mimetype, Map<String,Object> bindings)
          Evalue le script et recupere a la fin de l'evaluation les valeurs des variables presentes dans la map bindings.
static ScriptEngine getScriptEngin(ClassLoader classLoader, String name, String mimetype)
           
static ScriptEngineManager getScriptEnginManager(ClassLoader classLoader)
          Return all time new ScriptEnginManager if classLoader is not null else return default ScriptEnginManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scriptEnginManager

protected static ScriptEngineManager scriptEnginManager
Constructor Detail

ScriptEvaluator

public ScriptEvaluator()
Method Detail

getScriptEnginManager

public static ScriptEngineManager getScriptEnginManager(ClassLoader classLoader)
Return all time new ScriptEnginManager if classLoader is not null else return default ScriptEnginManager

Parameters:
classLoader - ClassLoader used to looking for ScriptEngin, can be null
Returns:
ScriptEnginManager

getScriptEngin

public static ScriptEngine getScriptEngin(ClassLoader classLoader,
                                          String name,
                                          String mimetype)
Parameters:
classLoader -
name - only used in exception message (this help to determine what script failed)
mimetype - script engine looking for this specific mimetype
Returns:
ScriptEngine or exception if not available for this mimetype

eval

public static Object eval(ClassLoader classLoader,
                          String name,
                          String script,
                          String mimetype,
                          Map<String,Object> bindings)
Evalue le script et retourne le retour de l'evaluation

Parameters:
classLoader - optionnal classLoader used to find ScriptEngine
name -
script -
mimetype -
bindings -
Returns:

exec

public static Map<String,Object> exec(ClassLoader classLoader,
                                      String name,
                                      String script,
                                      String mimetype,
                                      Map<String,Object> bindings)
Evalue le script et recupere a la fin de l'evaluation les valeurs des variables presentes dans la map bindings. Le resultat a exactement les memes cles que binding.

Parameters:
classLoader - optionnal classLoader used to find ScriptEngine
name -
script -
mimetype -
bindings -
Returns:


Copyright © 2009-2011 CodeLutin. All Rights Reserved.