ScriptEngineManager(ClassLoader loader)
-
-
Method Detail
-
setBindings
public void setBindings(Bindings bindings)
setBindings stores the specified Bindings
in the globalScope field. ScriptEngineManager sets this
Bindings as global bindings for ScriptEngine
objects created by it.
- Parameters:
bindings - The specified Bindings
- Throws:
IllegalArgumentException - if bindings is null.
-
getEngineByName
public ScriptEngine getEngineByName(String shortName)
Looks up and creates a ScriptEngine for a given name.
The algorithm first searches for a ScriptEngineFactory that has been
registered as a handler for the specified name using the registerEngineName
method.
If one is not found, it searches the set of ScriptEngineFactory instances
stored by the constructor for one with the specified name. If a ScriptEngineFactory
is found by either method, it is used to create instance of ScriptEngine .
- Parameters:
shortName - The short name of the ScriptEngine implementation.
returned by the getNames method of its ScriptEngineFactory .
- Returns:
- A
ScriptEngine created by the factory located in the search. Returns null
if no such factory was found. The ScriptEngineManager sets its own globalScope
Bindings as the GLOBAL_SCOPE Bindings of the newly
created ScriptEngine .
- Throws:
NullPointerException - if shortName is null.
-
getEngineByExtension
public ScriptEngine getEngineByExtension(String extension)
Look up and create a ScriptEngine for a given extension. The algorithm
used by getEngineByName is used except that the search starts
by looking for a ScriptEngineFactory registered to handle the
given extension using registerEngineExtension .
- Parameters:
extension - The given extension
- Returns:
- The engine to handle scripts with this extension. Returns
null
if not found.
- Throws:
NullPointerException - if extension is null.
-
getEngineByMimeType
public ScriptEngine getEngineByMimeType(String mimeType)
Look up and create a ScriptEngine for a given mime type. The algorithm
used by getEngineByName is used except that the search starts
by looking for a ScriptEngineFactory registered to handle the
given mime type using registerEngineMimeType .
- Parameters:
mimeType - The given mime type
- Returns:
- The engine to handle scripts with this mime type. Returns
null
if not found.
- Throws:
NullPointerException - if mimeType is null.
-
registerEngineName
public void registerEngineName(String name,
ScriptEngineFactory factory)
Registers a ScriptEngineFactory to handle a language
name. Overrides any such association found using the Discovery mechanism.
- Parameters:
name - The name to be associated with the ScriptEngineFactory .
factory - The class to associate with the given name.
- Throws:
NullPointerException - if any of the parameters is null.
-
registerEngineMimeType
public void registerEngineMimeType(String type,
ScriptEngineFactory factory)
Registers a ScriptEngineFactory to handle a mime type.
Overrides any such association found using the Discovery mechanism.
- Parameters:
type - The mime type to be associated with the
ScriptEngineFactory .
factory - The class to associate with the given mime type.
- Throws:
NullPointerException - if any of the parameters is null.
-
registerEngineExtension
public void registerEngineExtension(String extension,
ScriptEngineFactory factory)
Registers a ScriptEngineFactory to handle an extension.
Overrides any such association found using the Discovery mechanism.
- Parameters:
extension - The extension type to be associated with the
ScriptEngineFactory .
factory - The class to associate with the given extension.
- Throws:
NullPointerException - if any of the parameters is null.
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2015, Oracle and/or its affiliates. All rights reserved.
|