javax.script
Interface ScriptEngineFactory


public interface ScriptEngineFactory

See Javadoc of Java Scripting API


Method Summary
 String getEngineName()
          Retrieves the full name of the ScriptEngine.
 String getEngineVersion()
          Retrieves the version of the Script Engine.
 List getExtensions()
          Retrieves an immutable list of Strings which are file extensions typically used for files containing scripts written in the language supported by the ScriptEngine.
 String getLanguageName()
          Retrieves the name of the language supported by the ScriptEngine.
 String getLanguageVersion()
          Retrieves the version of the language supported by the ScriptEngine.
 String getMethodCallSyntax(String objectName, String method, String[] args)
          Returns a String which can be used to invoke a method of a Java object using the syntax of the supported scripting language.
 List getMimeTypes()
          Retrieves an immutable list of Strings containing MIME types describing the content which can be processed using the Script Engine.
 List getNames()
          Retrieves an immutable list of short descriptive names such as {"javascript", "rhino"} describing the language supported by the Script Engine.
 String getOutputStatement(String toDisplay)
          Returns a String that can be used as a statement to display the specified String using the syntax of the supported scripting language.
 Object getParameter(String key)
          Retrieves an associated value for the specified key.
 String getProgram(String[] statements)
          Returns A valid scripting language executable progam with given statements.
 ScriptEngine getScriptEngine()
          Retrieves an instance of the associated ScriptEngine.
 

Method Detail

getScriptEngine

ScriptEngine getScriptEngine()
Retrieves an instance of the associated ScriptEngine.

Returns:
an instance of the associated ScriptEngine

getEngineName

String getEngineName()
Retrieves the full name of the ScriptEngine.

Returns:
the name of the Script Engine

getEngineVersion

String getEngineVersion()
Retrieves the version of the Script Engine.

Returns:
the version of the Script Engine

getLanguageName

String getLanguageName()
Retrieves the name of the language supported by the ScriptEngine.

Returns:
the name of the supported language

getLanguageVersion

String getLanguageVersion()
Retrieves the version of the language supported by the ScriptEngine.

Returns:
the version of the supported language

getExtensions

List getExtensions()
Retrieves an immutable list of Strings which are file extensions typically used for files containing scripts written in the language supported by the ScriptEngine.

Returns:
immutable list of supported file extensions

getMimeTypes

List getMimeTypes()
Retrieves an immutable list of Strings containing MIME types describing the content which can be processed using the Script Engine.

Returns:
immutable list of MIME types

getNames

List getNames()
Retrieves an immutable list of short descriptive names such as {"javascript", "rhino"} describing the language supported by the Script Engine.

Returns:
immutable list of short descriptive names describing the language supported by the ScriptEngine

getParameter

Object getParameter(String key)
Retrieves an associated value for the specified key. Returns null if the ScriptEngine does not have an associated value for the key.

Returns:
associated value for the specified key

getMethodCallSyntax

String getMethodCallSyntax(String objectName,
                           String method,
                           String[] args)
Returns a String which can be used to invoke a method of a Java object using the syntax of the supported scripting language. For instance, an implementaton for a Javascript engine might be;
  public String getMethodCallSyntax(String objectName,
                                    String method, String[] args) {
       String ret = objectName;
       ret += "." + method + "(";
       for (int i = 0; i < args.length; i++) {
           ret += args[i];
           if (i == args.length - 1) {
               ret += ")";
           } else {
               ret += ",";
           }
       }
       return ret;
  }
 

Parameters:
objectName - The name representing the object whose method is to be invoked.
method - The name of the method to invoke.
args - names of the arguments in the method call.
Returns:
The String used to invoke the method in the syntax of the scripting language.

getOutputStatement

String getOutputStatement(String toDisplay)
Returns a String that can be used as a statement to display the specified String using the syntax of the supported scripting language. For instance, the implementaton for a Perl engine might be;
 
 public String getOutputStatement(String toDisplay) {
       return "print(" + toDisplay + ")";
  }
  

Parameters:
toDisplay - the string to be displayed
Returns:
The string used to display the String in the syntax of the scripting language.

getProgram

String getProgram(String[] statements)
Returns A valid scripting language executable progam with given statements. For instance an implementation for a PHP engine might be:
 
  public String getProgram(String... statements) {
       $retval = "<?\n";
       int len = statements.length;
       for (int i = 0; i < len; i++) {
           $retval += statements[i] + ";\n";
       }
       $retval += "?>";
  }
 

Parameters:
statements - the statements to be executed, e.g. as returned by the getMethodCallSyntax(java.lang.String, java.lang.String, java.lang.String[]) or getOutputStatement(java.lang.String) methods
Returns:
The Program


Copyright © 1999-2012 The Apache Software Foundation. All Rights Reserved.