List of usage examples for javax.script ScriptEngineFactory getLanguageName
public String getLanguageName();
ScriptEngine
. From source file:ListEngineFactoryDemo.java
public static void main(String[] args) { // create ScriptEngineManager ScriptEngineManager manager = new ScriptEngineManager(); List<ScriptEngineFactory> factoryList = manager.getEngineFactories(); for (ScriptEngineFactory factory : factoryList) { System.out.println(factory.getEngineName()); System.out.println(factory.getLanguageName()); }/*from w w w .j a va2 s . co m*/ }
From source file:Main.java
public static void main(String args[]) { ScriptEngineManager manager = new ScriptEngineManager(); List<ScriptEngineFactory> factories = manager.getEngineFactories(); for (ScriptEngineFactory factory : factories) { System.out.println(factory.getEngineName()); System.out.println(factory.getEngineVersion()); System.out.println(factory.getLanguageName()); System.out.println(factory.getLanguageVersion()); System.out.println(factory.getExtensions()); System.out.println(factory.getMimeTypes()); System.out.println(factory.getNames()); }// w ww.j a va 2 s . c o m }
From source file:Main.java
public static void main(String[] args) { ScriptEngineManager manager = new ScriptEngineManager(); // Get the list of all available engines List<ScriptEngineFactory> list = manager.getEngineFactories(); // Print the details of each engine for (ScriptEngineFactory f : list) { System.out.println("Engine Name:" + f.getEngineName()); System.out.println("Engine Version:" + f.getEngineVersion()); System.out.println("Language Name:" + f.getLanguageName()); System.out.println("Language Version:" + f.getLanguageVersion()); System.out.println("Engine Short Names:" + f.getNames()); System.out.println("Mime Types:" + f.getMimeTypes()); System.out.println("==="); }/* w w w . j a v a2 s . co m*/ }
From source file:EnumerateScriptEngines.java
public static void main(String[] args) { ScriptEngineManager manager = new ScriptEngineManager(); List<ScriptEngineFactory> factories = manager.getEngineFactories(); for (ScriptEngineFactory factory : factories) { System.out.println("Engine name (full): " + factory.getEngineName()); System.out.println("Engine version: " + factory.getEngineVersion()); System.out.println("Supported extensions:"); List<String> extensions = factory.getExtensions(); for (String extension : extensions) System.out.println(" " + extension); System.out.println("Language name: " + factory.getLanguageName()); System.out.println("Language version: " + factory.getLanguageVersion()); System.out.println("Supported MIME types:"); List<String> mimetypes = factory.getMimeTypes(); for (String mimetype : mimetypes) System.out.println(" " + mimetype); System.out.println("Supported short names:"); List<String> shortnames = factory.getNames(); for (String shortname : shortnames) System.out.println(" " + shortname); System.out.println();/*from w w w .java 2s .c o m*/ } }
From source file:com.galeoconsulting.leonardinius.api.LanguageUtils.java
public static String getLanguageName(ScriptEngineFactory factory) { String languageName = factory.getLanguageName(); if ("ECMAScript".equals(languageName) && factory.getNames().contains("JavaScript")) { languageName = "JavaScript"; }//from w ww .j a v a 2s. co m return StringUtils.capitalize(languageName); }
From source file:org.mycontroller.standalone.scripts.McScriptEngineUtils.java
public static List<HashMap<String, Object>> getScriptEnginesDetail() { List<HashMap<String, Object>> engines = new ArrayList<HashMap<String, Object>>(); ScriptEngineManager mgr = McScriptEngineUtils.getScriptEngineManager(); List<ScriptEngineFactory> factories = mgr.getEngineFactories(); for (ScriptEngineFactory factory : factories) { HashMap<String, Object> engine = new HashMap<String, Object>(); engine.put("engineName", factory.getEngineName()); engine.put("engineVersion", factory.getEngineVersion()); engine.put("languageName", factory.getLanguageName()); engine.put("languageVersion", factory.getLanguageVersion()); engine.put("extensions", factory.getExtensions()); engine.put("alias", factory.getNames()); engines.add(engine);//from w ww . j a v a 2 s . c om } return engines; }
From source file:com.xafero.vee.cmd.MainApp.java
private static void printLanguages() { ScriptEngineManager mgr = new ScriptEngineManager(); for (ScriptEngineFactory factory : mgr.getEngineFactories()) System.out.println(MoreObjects.toStringHelper("").add("name", factory.getEngineName()) .add("version", factory.getEngineVersion()) .add("extensions", "[ " + Strings.join(" | ", factory.getExtensions()) + " ]") .add("mimeTypes", "[ " + Strings.join(" | ", factory.getMimeTypes()) + " ]") .add("aliases", "[ " + Strings.join(" | ", factory.getNames()) + " ]") .add("language", factory.getLanguageName() + " " + factory.getLanguageVersion()) .omitNullValues().toString().replace(", ", String.format(", %n "))); }
From source file:tools.httpserver.custom.ScriptList.java
/** * @return a vector containing Scriptengines names and associated languages *//*from ww w .j a va2s . com*/ public static Vector<String[]> getScriptEngines() { Vector<String[]> vector = new Vector<String[]>(); ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); for (ScriptEngineFactory factories : scriptEngineManager.getEngineFactories()) { boolean inserted = false; for (int i = 0; i < vector.size(); i++) { String[] s = vector.elementAt(i); if (s[0].compareToIgnoreCase(factories.getEngineName()) > 0) { vector.insertElementAt(new String[] { factories.getEngineName(), factories.getLanguageName() }, i); inserted = true; break; } } if (!inserted) vector.add(new String[] { factories.getEngineName(), factories.getLanguageName() }); } if (javax.tools.ToolProvider.getSystemJavaCompiler() != null) { vector.add(new String[] { "java", "java" }); } return vector; }
From source file:org.gatherdata.alert.detect.bsf.internal.BsfEventDetector.java
public BsfEventDetector() { this.scriptEngineManager = new ScriptEngineManager(); List<ScriptEngineFactory> engineFactories = scriptEngineManager.getEngineFactories(); log.info("Available ScriptEngineFactories..."); for (ScriptEngineFactory factory : engineFactories) { log.info("\t" + factory.getEngineName() + " - " + factory.getLanguageName() + " " + "ext:" + factory.getExtensions() + " " + "names:" + factory.getNames()); }//from www . j a v a2 s . c om }
From source file:tools.httpserver.custom.ScriptList.java
/** * Create a new empty SpoonScript file using provided parameters * @param params_values parameters to use for file creation (table containing "param=value" strings) * @param type Set if script concerns REQMOD or RESPMOD * @param user User who generates the request * @return Action to do after: edit the new file if all is ok, return error otherwise *//*from www.j a v a 2s . c o m*/ public static String create(String[] params_values, Icap.TYPE type, User user) { String name = null; String language = null; for (String s : params_values) { String[] values = s.split("="); if (values.length != 2) continue; if (values[0].equals("script.name")) name = values[1].replace("+", " ").trim(); if (values[0].equals("script.language")) language = TextTools.hexToUTF8(values[1]).trim(); } if (name == null || language == null) { error = "Invalid script name or language"; return ""; } SpoonScript[] scripts = type == Icap.TYPE.REQMOD ? icap.services.GreasySpoon.reqSpoonScripts : icap.services.GreasySpoon.respSpoonScripts; for (SpoonScript script : scripts) { if (script.getScriptName().equalsIgnoreCase(name)) { error = "A script with this name already exists."; return ""; } } ScriptEngineFactory factory = null; ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); for (ScriptEngineFactory factories : scriptEngineManager.getEngineFactories()) { if (factories.getEngineName().equalsIgnoreCase(language)) { factory = factories; break; } } String factorylanguage; String extension; if (factory == null) { if (language.equals("java")) { factorylanguage = "java"; extension = "java"; } else { error = "Provided language cannot be founded."; return ""; } } else { factorylanguage = factory.getLanguageName(); extension = factory.getExtensions().get(0); } String scriptdirectory = icap.services.GreasySpoon.scriptsDirectory; String commentstring = icap.services.GreasySpoon.languageComments.getProperty(factorylanguage, "//").trim(); String tag; if (type == Icap.TYPE.REQMOD) { tag = icap.services.GreasySpoon.greasySpoonReqTag; } else { tag = icap.services.GreasySpoon.greasySpoonRespTag; } String filecomment = SpoonScript.getScriptSkeleton(type, extension, commentstring); String filename = scriptdirectory + File.separator + name.replace(" ", "_").replace("%20", "_") + tag + extension; SpoonScript.save(filename, filecomment.replace("%name%", name), user.getRights()); icap.services.GreasySpoon.forceReload(); return "edit=" + filename; }