當前位置: 首頁>>代碼示例>>Java>>正文


Java ScriptEngineFactory.getEngineName方法代碼示例

本文整理匯總了Java中javax.script.ScriptEngineFactory.getEngineName方法的典型用法代碼示例。如果您正苦於以下問題:Java ScriptEngineFactory.getEngineName方法的具體用法?Java ScriptEngineFactory.getEngineName怎麽用?Java ScriptEngineFactory.getEngineName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.script.ScriptEngineFactory的用法示例。


在下文中一共展示了ScriptEngineFactory.getEngineName方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: listEngines

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
/**
 * Display all script engines.
 */
public static void listEngines() {
  final ScriptEngineManager mgr = new ScriptEngineManager();
  final List<ScriptEngineFactory> factories =
      mgr.getEngineFactories();
  for (final ScriptEngineFactory factory: factories) {
    System.out.println("ScriptEngineFactory Info");

    final String engName = factory.getEngineName();
    final String engVersion = factory.getEngineVersion();
    final String langName = factory.getLanguageName();
    final String langVersion = factory.getLanguageVersion();

    System.out.printf("\tScript Engine: %s (%s)\n", engName, engVersion);

    final List<String> engNames = factory.getNames();
    for (final String name: engNames) {
      System.out.printf("\tEngine Alias: %s\n", name);
    }
    System.out.printf("\tLanguage: %s (%s)\n", langName, langVersion);
  }
}
 
開發者ID:soulmachine,項目名稱:JythonExample,代碼行數:25,代碼來源:JythonExample.java

示例2: availableEngines

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
public Map<String, Map<String, Object>> availableEngines() {
    Map<String, Map<String, Object>> result = new LinkedHashMap<>();

    List<ScriptEngineFactory> factories = ENGINE_MANAGER.getEngineFactories();

    for (ScriptEngineFactory factory : factories) {
        Map<String, Object> f = new LinkedHashMap<>();
        String engName = factory.getEngineName();
        String engVersion = factory.getEngineVersion();
        List<String> engNames = factory.getNames();
        String langName = factory.getLanguageName();
        String langVersion = factory.getLanguageVersion();

        result.put(engName, f);
        f.put("language name", langName);
        f.put("language version", langVersion);
        f.put("aliases", engNames);
        f.put("version", engVersion);
    }
    return result;
}
 
開發者ID:fhoeben,項目名稱:hsac-fitnesse-fixtures,代碼行數:22,代碼來源:ScriptLanguageFixture.java

示例3: createModuleInfo

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
@Nullable
@Override
protected IModuleInfo createModuleInfo(final ScriptEngineFactory moduleInstance) {
    return new IModuleInfo() {

        String name = moduleInstance.getEngineName();
        String searchName = moduleInstance.getEngineName().toLowerCase();

        @Override
        public String getName() {
            return name;
        }

        @Override
        public String getSearchName() {
            return searchName;
        }
    };
}
 
開發者ID:JCThePants,項目名稱:NucleusFramework,代碼行數:20,代碼來源:InternalScriptEngineLoader.java

示例4: javaInfo

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
public static void javaInfo(){
    ScriptEngineManager mgr = new ScriptEngineManager();
    List<ScriptEngineFactory> factories =
            mgr.getEngineFactories();
    for (ScriptEngineFactory factory: factories) {
        System.out.println("ScriptEngineFactory Info");
        String engName = factory.getEngineName();
        String engVersion = factory.getEngineVersion();
        String langName = factory.getLanguageName();
        String langVersion = factory.getLanguageVersion();
        System.out.printf("\tScript Engine: %s (%s)\n",
                engName, engVersion);
        List<String> engNames = factory.getNames();
        for(String name: engNames) {
            System.out.printf("\tEngine Alias: %s\n", name);
        }
        System.out.printf("\tLanguage: %s (%s)\n",
                langName, langVersion);
    }
}
 
開發者ID:Razi91,項目名稱:JavaBlock,代碼行數:21,代碼來源:misc.java

示例5: listKnownScriptEngines

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
public void listKnownScriptEngines() {
    ScriptEngineManager mgr = new ScriptEngineManager();
    List<ScriptEngineFactory> factories = 
        mgr.getEngineFactories();
    for (ScriptEngineFactory factory: factories) {
      System.out.println("ScriptEngineFactory Info");
      String engName = factory.getEngineName();
      String engVersion = factory.getEngineVersion();
      String langName = factory.getLanguageName();
      String langVersion = factory.getLanguageVersion();
      System.out.printf("\tScript Engine: %s (%s)\n", 
          engName, engVersion);
      List<String> engNames = factory.getNames();
      for(String name: engNames) {
        System.out.printf("\tEngine Alias: %s\n", name);
      }
      System.out.printf("\tLanguage: %s (%s)\n", 
          langName, langVersion);
    }
}
 
開發者ID:crotwell,項目名稱:sod,代碼行數:21,代碼來源:SodUtil.java

示例6: next

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
@Override
public Row next() {
    if (!it.hasNext())
        return null;
    ScriptEngineFactory factory = it.next();
    return new ValuesHolderRow(
            rowType,
            it.nextIndex(), // use nextIndex so that the IDs are 1-based
            factory.getEngineName(),
            factory.getEngineVersion(),
            factory.getLanguageName(),
            factory.getLanguageVersion(),
            ++rowCounter /*hidden pk*/);
}
 
開發者ID:jaytaylor,項目名稱:sql-layer,代碼行數:15,代碼來源:BasicInfoSchemaTablesServiceImpl.java

示例7: perform

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
public void perform(TaskRequest req, TaskResponse res) {
       final ScriptEngine engine = (ScriptEngine) this.engine.evaluate(req, res);
       final String script = (String) this.script.evaluate(req, res);
       
       final Tuple<ScriptEngine, String> scriptEvaluatorKey = new Tuple<ScriptEngine, String>(engine, script);
       final ScriptEvaluator scriptEvaluator = this.scriptEvaluatorCache.getCachedObject(req, res, scriptEvaluatorKey, ScriptEvaluatorFactory.INSTANCE);
       
       final Bindings bindings = ScriptUtils.generateBindings(req, res);
       
       final ScriptContext scriptContext = new javax.script.SimpleScriptContext();
       scriptContext.setBindings(bindings, ScriptContext.GLOBAL_SCOPE);
       scriptContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE);

       final ScriptEngineFactory scriptEngineFactory = engine.getFactory();
       final String engineName = scriptEngineFactory.getEngineName();
       try {
           scriptEvaluator.eval(scriptContext);
       }
       catch (ScriptException se) {
           throw new RuntimeException("Error while executing the specified script.  " +
                   "\n\t\tENGINE_NAME:  " + engineName +
                   "\n\t\tSCRIPT (follows):\n" + script + "\n", se);
       }
       
       res.setAttribute(ScriptAttributes.ENGINE + "." + engineName, engine);
       super.performSubtasks(req, res);
}
 
開發者ID:drewwills,項目名稱:cernunnos,代碼行數:28,代碼來源:ScriptTask.java

示例8: scriptUsage

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
@Test
public void scriptUsage() throws ScriptException, NoSuchMethodException {
    // 創建腳本引擎管理類
    ScriptEngineManager manager = new ScriptEngineManager();

    // 查詢可用的腳本引擎
    List<ScriptEngineFactory> factoryList = manager.getEngineFactories();
    for (ScriptEngineFactory factory : factoryList) {
        String name = factory.getEngineName();
        String language = factory.getLanguageName();
        System.out.println(name + "-->" + language);
    }

    // 獲取javaScript腳本引擎
    ScriptEngine javaScriptEngine = manager.getEngineByName("JavaScript");
    // 向腳本引擎傳入變量,計算表達式,從腳本引擎查詢變量
    javaScriptEngine.put("k", 100);
    javaScriptEngine.eval("k=k*3+24");
    Object k = javaScriptEngine.get("k");
    System.out.println("k  = " + k);

    // 調用腳本中的函數
    javaScriptEngine.eval("function sayHello(){ println('hello,World!!!!'); }");
    javaScriptEngine.eval("sayHello();");

    // 腳本中使用java(下麵代碼展示如何在腳本中使用java創建窗體)
    String script = "var jf=new javax.swing.JFrame();jf.setTitle('hello,Script');jf.setBounds(200,100,400,300);jf.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);jf.setVisible(true);";
    javaScriptEngine.eval(script);
}
 
開發者ID:sunlin901203,項目名稱:example-java,代碼行數:30,代碼來源:ScriptTest.java

示例9: getScriptEngine

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
public ScriptEngine getScriptEngine(String engineInfo){
    ScriptEngineFactory factory=engines.get(engineInfo);
    if(factory==null){
        javax.script.ScriptEngineManager manager=new javax.script.ScriptEngineManager();
        List<ScriptEngineFactory> fs=manager.getEngineFactories();
        int bestScore=0;
        for(ScriptEngineFactory f : fs){
            int s=matchEngine(engineInfo,f);
            if(s==10) {
                factory=f;
                break;
            }
            else if(s>bestScore){
                bestScore=s;
                factory=f;
            }
        }
        engines.put(engineInfo,factory);
    }
    if(factory==null) return null;
    
    ScriptEngine engine = factory.getScriptEngine();
    
    if(engine != null) {
        try {
            String engineName = factory.getEngineName();
            if(engineName != null && engineName.toLowerCase().contains("nashorn")) {
                // https://bugs.openjdk.java.net/browse/JDK-8025132
                engine.eval("load('nashorn:mozilla_compat.js');");
            }
        }
        catch(Exception e) {}
    }
    return engine;
}
 
開發者ID:wandora-team,項目名稱:wandora,代碼行數:36,代碼來源:ScriptManager.java

示例10: getScriptEngines

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
public static String[] getScriptEngines(){
    ScriptEngineManager mgr = javablock.gui.Interpreter.getScriptManager();
     List<ScriptEngineFactory> factories =
             mgr.getEngineFactories();
     String engs[]=new String[factories.size()];
     int i=0;
     for (ScriptEngineFactory factory: factories) {
         engs[i] = factory.getEngineName();
         i++;
     }
     return engs;
}
 
開發者ID:Razi91,項目名稱:JavaBlock,代碼行數:13,代碼來源:misc.java

示例11: getScriptEngineNames

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
public static List<String> getScriptEngineNames() {
  List<String> scriptEngineNames = new ArrayList<String>();
  List<ScriptEngineFactory> engineFactories = getScriptEngineManager().getEngineFactories();
  if ( engineFactories != null ) {
    for ( ScriptEngineFactory factory : engineFactories ) {
      final String engineName = factory.getEngineName();
      if ( engineName.contains( "gremlin" ) || engineName.contains( "Gremlin" ) ) {
        scriptEngineNames.add( factory.getEngineName() );
      }
    }
  }
  return scriptEngineNames;
}
 
開發者ID:mattyb149,項目名稱:pdi-graph-computing,代碼行數:14,代碼來源:GremlinScriptUtils.java

示例12: getEngineInfo

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
@Override
public String getEngineInfo() {
    ScriptEngineFactory factory = scriptEngine.getScriptEngine().getFactory();
    return factory.getEngineName() + " version " + factory.getEngineVersion();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:6,代碼來源:NbPacScriptEvaluator.java

示例13: sameName

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
private static boolean sameName(final ScriptEngineFactory factory, final String engine) {
    final String engineName = factory.getEngineName();
    return TextUtils.containsIgnoreCase(engineName, engine);
}
 
開發者ID:vbauer,項目名稱:jconditions,代碼行數:5,代碼來源:ScriptUtils.java


注:本文中的javax.script.ScriptEngineFactory.getEngineName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。