Package: org.codehaus.groovy.jsr223

## [Java] Class GroovyScriptEngineFactory

- org.codehaus.groovy.jsr223.GroovyScriptEngineFactory

- All Implemented Interfaces and Traits:
    ScriptEngineFactory

      public class GroovyScriptEngineFactory
      extends Object
      implements ScriptEngineFactory

  A factory class conforming to JSR-223 which is used to instantiate Groovy `ScriptEngines` and also exposes metadata describing Groovy's engine class. Adapted from original by Mike Grogan and A. Sundararajan

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public String` | `getEngineName()` Returns the display name of this script engine implementation.
    `` | `public String` | `getEngineVersion()` Note that the scripting.dev.java.net engine had this backwards.
    `` | `public List<String>` | `getExtensions()` Returns the file extensions recognized by this engine.
    `` | `public String` | `getLanguageName()` This is also different from scripting.dev.java.net which used an initial lowercase.
    `` | `public String` | `getLanguageVersion()` Returns the version of the Groovy language available at runtime.
    `` | `public String` | `getMethodCallSyntax(String obj, String method, String args)` Formats a Groovy method call using the supplied receiver, method name, and arguments.
    `` | `public List<String>` | `getMimeTypes()` Returns the MIME types associated with Groovy scripts.
    `` | `public List<String>` | `getNames()` Returns the short and display names accepted when locating this engine.
    `` | `public String` | `getOutputStatement(String toDisplay)` Produces a Groovy statement that prints the supplied text.
    `` | `public Object` | `getParameter(String key)` Resolves a standard JSR-223 metadata key for this engine.
    `` | `public String` | `getProgram(String statements)` Joins multiple Groovy statements into a single program.
    `` | `public ScriptEngine` | `getScriptEngine()` Creates a new Groovy script engine backed by this factory.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### public String getEngineName()

      Returns the display name of this script engine implementation.

      Returns:
        the engine name reported through the JSR-223 API

    - #### public String getEngineVersion()

      Note that the scripting.dev.java.net engine had this backwards. The engine version refers to this engine implementation. Whereas language version refers to the groovy implementation (which is obtained from the runtime).

    - #### public List<String> getExtensions()

      Returns the file extensions recognized by this engine.

      Returns:
        an immutable list of supported script file extensions

    - #### public String getLanguageName()

      This is also different from scripting.dev.java.net which used an initial lowercase. But these are proper names and should be capitalized.

    - #### public String getLanguageVersion()

      Returns the version of the Groovy language available at runtime.

      Returns:
        the runtime Groovy version

    - #### public String getMethodCallSyntax(String obj, String method, String args)

      Formats a Groovy method call using the supplied receiver, method name, and arguments.

      Parameters:
        `obj` - the expression identifying the receiver object
        `method` - the method name to call
        `args` - the argument expressions to include in the invocation
      Returns:
        a Groovy expression that invokes `method` on `obj`

    - #### public List<String> getMimeTypes()

      Returns the MIME types associated with Groovy scripts.

      Returns:
        an immutable list of supported MIME types

    - #### public List<String> getNames()

      Returns the short and display names accepted when locating this engine.

      Returns:
        an immutable list of supported engine names

    - #### public String getOutputStatement(String toDisplay)

      Produces a Groovy statement that prints the supplied text.

      Parameters:
        `toDisplay` - the text to render
      Returns:
        a `println` statement with embedded quotes and backslashes escaped

    - #### public Object getParameter(String key)

      Resolves a standard JSR-223 metadata key for this engine.

      throws:
        IllegalArgumentException if `key` is not supported by this factory
      Parameters:
        `key` - the metadata key to resolve
      Returns:
        the metadata value associated with `key`

    - #### public String getProgram(String statements)

      Joins multiple Groovy statements into a single program.

      Parameters:
        `statements` - the statements to concatenate in source order
      Returns:
        a newline-delimited Groovy program

    - #### public ScriptEngine getScriptEngine()

      Creates a new Groovy script engine backed by this factory.

      Returns:
        a fresh GroovyScriptEngineImpl instance