Java Code Examples for javax.script.ScriptEngineFactory#getLanguageName()

The following examples show how to use javax.script.ScriptEngineFactory#getLanguageName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpagoBIScriptManager.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
public void printInfo() {
	ScriptEngineManager mgr = new ScriptEngineManager();
	List<ScriptEngineFactory> factories = mgr.getEngineFactories();

	for (ScriptEngineFactory factory : factories) {
		logger.debug("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);
	}
}
 
Example 2
Source File: ScriptLanguageFixture.java    From hsac-fitnesse-fixtures with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: NewAction.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
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);
    }
}
 
Example 4
Source File: PmdDataSourceEditor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
private String mapLanguageToSyntaxHighlighting( final ScriptEngineFactory script ) {
  if ( script == null ) {
    return SyntaxConstants.SYNTAX_STYLE_NONE;
  }

  final String language = script.getLanguageName();
  if ( "ECMAScript".equalsIgnoreCase( language )
     || "js".equalsIgnoreCase( language )
     || "rhino".equalsIgnoreCase( language )
     || "javascript".equalsIgnoreCase( language ) ) {
    return SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT;
  }
  if ( "groovy".equalsIgnoreCase( language ) ) {
    return SyntaxConstants.SYNTAX_STYLE_GROOVY;
  }
  return SyntaxConstants.SYNTAX_STYLE_NONE;
}
 
Example 5
Source File: BasicInfoSchemaTablesServiceImpl.java    From sql-layer with GNU Affero General Public License v3.0 5 votes vote down vote up
@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*/);
}
 
Example 6
Source File: DataFactoryEditorSupport.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static String mapLanguageToSyntaxHighlighting( final ScriptEngineFactory script ) {
  if ( script == null ) {
    return SYNTAX_STYLE_NONE;
  }

  final String language = script.getLanguageName();
  if ( "ECMAScript".equalsIgnoreCase( language ) || "js".equalsIgnoreCase( language )
      || "rhino".equalsIgnoreCase( language ) || "javascript".equalsIgnoreCase( language ) ) {
    return SYNTAX_STYLE_JAVASCRIPT;
  }
  if ( "groovy".equalsIgnoreCase( language ) ) {
    return SYNTAX_STYLE_GROOVY;
  }
  return SYNTAX_STYLE_NONE;
}
 
Example 7
Source File: QueryEditorPanel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private String getSelectedGlobalScriptLanguage() {
  Object selectedItem = globalLanguageField.getSelectedItem();
  if ( selectedItem instanceof ScriptEngineFactory == false ) {
    return null;
  }
  ScriptEngineFactory engineFactory = (ScriptEngineFactory) selectedItem;
  return engineFactory.getLanguageName();
}
 
Example 8
Source File: QueryEditorPanel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private String getSelectedQueryScriptLanguage() {
  Object selectedItem = queryLanguageField.getSelectedItem();
  if ( selectedItem instanceof ScriptEngineFactory == false ) {
    return null;
  }
  ScriptEngineFactory engineFactory = (ScriptEngineFactory) selectedItem;
  return engineFactory.getLanguageName();
}
 
Example 9
Source File: Olap4JDataSourceEditor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private String getGlobalScriptingLanguage() {
  final ScriptEngineFactory selectedValue = (ScriptEngineFactory) globalLanguageField.getSelectedItem();
  if ( selectedValue == null ) {
    return null;
  }
  return selectedValue.getLanguageName();
}
 
Example 10
Source File: PmdDataSourceEditor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private String getGlobalScriptingLanguage() {
  final ScriptEngineFactory selectedValue = (ScriptEngineFactory) globalLanguageField.getSelectedItem();
  if ( selectedValue == null ) {
    return null;
  }
  return selectedValue.getLanguageName();
}
 
Example 11
Source File: JdbcDataSourceDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private String getGlobalScriptingLanguage() {
  final ScriptEngineFactory selectedValue = (ScriptEngineFactory) globalLanguageField.getSelectedItem();
  if ( selectedValue == null ) {
    return null;
  }
  return selectedValue.getLanguageName();
}
 
Example 12
Source File: MondrianDataSourceEditor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private String getGlobalScriptingLanguage() {
  final ScriptEngineFactory selectedValue = (ScriptEngineFactory) globalLanguageField.getSelectedItem();
  if ( selectedValue == null ) {
    return null;
  }
  return selectedValue.getLanguageName();
}