Code Example 3: A ScriptEngineFactory object provides detailed information about the engine it provides.

Scripting for the Java Platform

Code Example 3: A ScriptEngineFactory object provides detailed information about the engine it provides.

  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);
  }    
 

Code Example 3 produces the following output:

ScriptEngineFactory Info
  Script Engine: Mozilla Rhino (1.6 release 2)
  Engine Alias: js
  Engine Alias: rhino
  Engine Alias: JavaScript
  Engine Alias: javascript
  Engine Alias: ECMAScript
  Engine Alias: ecmascript
  Language: ECMAScript (1.6)

你可能感兴趣的:(factory)