当前位置: 首页>>代码示例>>Java>>正文


Java ScriptEngineFactory.getLanguageName方法代码示例

本文整理汇总了Java中javax.script.ScriptEngineFactory.getLanguageName方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptEngineFactory.getLanguageName方法的具体用法?Java ScriptEngineFactory.getLanguageName怎么用?Java ScriptEngineFactory.getLanguageName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.script.ScriptEngineFactory的用法示例。


在下文中一共展示了ScriptEngineFactory.getLanguageName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: actionPerformed

import javax.script.ScriptEngineFactory; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
    ScriptEngineFactory[] scriptEngineFactories = getScriptManager().getEngineFactories();
    final Item[] items = new Item[scriptEngineFactories.length];
    for (int i = 0; i < scriptEngineFactories.length; i++) {
        ScriptEngineFactory scriptEngineFactory = scriptEngineFactories[i];
        items[i] = new Item(scriptEngineFactory.getLanguageName(), scriptEngineFactory);
    }
    Item selectedItem = null;
    if (items.length != 0) {
        selectedItem = promptForEngine(items);
    } else {
        getScriptConsoleTopComponent().showErrorMessage("No scripting language available.");
    }
    if (selectedItem != null) {
        getScriptConsoleTopComponent().newScript(selectedItem.scriptEngineFactory);
    }
}
 
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:18,代码来源:NewAction.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: getListCellRendererComponent

import javax.script.ScriptEngineFactory; //导入方法依赖的package包/类
/**
 * @{inheritDoc
 */
@Override
public Component getListCellRendererComponent(JList list,
        Object value,
        int index,
        boolean isSelected,
        boolean cellHasFocus) {
    String text = null;
    if (value != null && value instanceof ScriptEngineFactory) {
        ScriptEngineFactory f = (ScriptEngineFactory) value;
        text = f.getLanguageName();
    }
    label.setText(text != null ? text : "");
    return label;
}
 
开发者ID:intuit,项目名称:Tank,代码行数:18,代码来源:LanguageRenderer.java

示例7: 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

示例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: prepareScriptCommand

import javax.script.ScriptEngineFactory; //导入方法依赖的package包/类
private Packet prepareScriptCommand(Iq packet, Bindings binds) {
	Packet result = packet.commandResult(Command.DataType.form);

	Command.addFieldValue(result, DESCRIPT, "Short description");
	Command.addFieldValue(result, COMMAND_ID, "new-command");
	Command.addFieldValue(result, GROUP, "group");

	ScriptEngineManager scriptEngineManager = (ScriptEngineManager) binds.get(SCRI_MANA);
	List<ScriptEngineFactory> scriptFactories = scriptEngineManager.getEngineFactories();

	if (scriptFactories != null) {
		String[] langs = new String[scriptFactories.size()];
		int idx = 0;
		String def = null;

		for (ScriptEngineFactory scriptEngineFactory : scriptFactories) {
			langs[idx++] = scriptEngineFactory.getLanguageName();

			if (scriptEngineFactory.getLanguageName().equals("groovy")) {
				def = "groovy";
			}
		}

		if (def == null) {
			def = langs[0];
		}

		Command.addFieldValue(result, LANGUAGE, def, LANGUAGE, langs, langs);
	}

	Command.addFieldMultiValue(result, SCRIPT_TEXT, Collections.nCopies(1, ""));
	Command.addCheckBoxField(result, SAVE_TO_DISK, true);

	return result;
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:36,代码来源:AddScriptCommand.java

示例10: sameLanguage

import javax.script.ScriptEngineFactory; //导入方法依赖的package包/类
private static boolean sameLanguage(final ScriptEngineFactory factory, final String engine) {
    final String languageName = factory.getLanguageName();
    return TextUtils.containsIgnoreCase(languageName, engine);
}
 
开发者ID:vbauer,项目名称:jconditions,代码行数:5,代码来源:ScriptUtils.java

示例11: toString

import javax.script.ScriptEngineFactory; //导入方法依赖的package包/类
@Override
public String toString() {
    ScriptEngineFactory sf = getFactory();
    return "PyScriptEngine(" + sf.getLanguageName() + ", " + sf.getLanguageVersion() + ")";
}
 
开发者ID:kredel,项目名称:java-algebra-system,代码行数:6,代码来源:PyScriptEngine.java

示例12: CXJsScriptFactory

import javax.script.ScriptEngineFactory; //导入方法依赖的package包/类
/**
 * @param aFactory
 */
public CXJsScriptFactory(ScriptEngineFactory aFactory) {
	this(aFactory, aFactory.getLanguageName());
}
 
开发者ID:isandlaTech,项目名称:cohorte-utilities,代码行数:7,代码来源:CXJsScriptFactory.java


注:本文中的javax.script.ScriptEngineFactory.getLanguageName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。