List of usage examples for javax.script ScriptEngineFactory getExtensions
public List<String> getExtensions();
ScriptEngine
. From source file:FileExtensionsDemo.java
public static void main(String[] args) { ScriptEngineManager manager = new ScriptEngineManager(); List<ScriptEngineFactory> factories = manager.getEngineFactories(); for (ScriptEngineFactory factory : factories) { List<String> ext = factory.getExtensions(); for (int i = 0; i < ext.size(); i++) { System.out.printf("Supported file extension: " + (String) ext.get(i) + "\n"); }/* ww w . j a v a2 s . c om*/ } }
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 va2s.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 www.j a v a 2 s . c o m*/ } }
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:org.apache.solr.update.processor.StatelessScriptUpdateProcessorFactory.java
/** * For error messages - returns null if there are any exceptions of any * kind building the string (or of the list is empty for some unknown reason). * @param ext - if true, list of extensions, otherwise a list of engine names *///from w w w . j a v a 2 s. co m private static String getSupportedEngines(ScriptEngineManager mgr, boolean ext) { String result = null; try { List<ScriptEngineFactory> factories = mgr.getEngineFactories(); if (null == factories) return result; Set<String> engines = new LinkedHashSet<>(factories.size()); for (ScriptEngineFactory f : factories) { if (ext) { engines.addAll(f.getExtensions()); } else { engines.addAll(f.getNames()); } } result = StringUtils.join(engines, ", "); } catch (RuntimeException e) { /* :NOOP: */ } return result; }
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);// ww w . ja va 2s. c o m } return engines; }
From source file:com.galeoconsulting.leonardinius.api.impl.ScriptServiceImpl.java
@Override public void defaultRegistration(ScriptEngineFactory engineFactory) { for (String extension : engineFactory.getExtensions()) { registerEngineExtension(extension, engineFactory); }// ww w . j av a 2 s .co m for (String mime : engineFactory.getMimeTypes()) { registerEngineMime(mime, engineFactory); } registerEngineLanguage(engineFactory.getLanguageName(), engineFactory); registerEngineLanguage((String) engineFactory.getParameter(ScriptEngine.NAME), engineFactory); // do not rely on the other methods registeredEngines.put(engineFactory, DUMMY); }
From source file:ca.hedlund.jiss.preprocessor.LangPreprocessor.java
@Override public boolean preprocessCommand(JissModel jissModel, String orig, StringBuffer cmd) { final String c = cmd.toString(); if (c.equals("::langs")) { cmd.setLength(0);// w ww . ja v a2s . c o m printLangs(jissModel, cmd); } else if (c.equals("::lang")) { cmd.setLength(0); printCurrentLang(jissModel, cmd); } else if (c.startsWith("::lang")) { cmd.setLength(0); final String parts[] = c.split("\\p{Space}"); if (parts.length == 2) { final String lang = parts[1]; final ScriptEngineManager manager = new ScriptEngineManager(JissModel.class.getClassLoader()); ScriptEngine newEngine = null; for (ScriptEngineFactory factory : manager.getEngineFactories()) { if (factory.getLanguageName().equals(lang) || factory.getExtensions().contains(lang) || factory.getMimeTypes().contains(lang)) { newEngine = factory.getScriptEngine(); break; } } if (newEngine != null) { jissModel.setScriptEngine(newEngine); printCurrentLang(jissModel, cmd); } } } return false; }
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 ww w . ja va 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; }
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 w ww .j av a 2 s . c om }