org.apache.batik.script
Class InterpreterPool
java.lang.Object
|
+--org.apache.batik.script.InterpreterPool
- public class InterpreterPool
- extends java.lang.Object
A class allowing to create/query an Interpreter
corresponding to a particular Document
and scripting language.
By default, it is able to create interpreters for ECMAScript, Python and Tcl
scripting languages if you provide the right jar files in your CLASSPATH (i.e.
Rhino, JPython and Jacl jar files).
Constructor Summary |
InterpreterPool()
Builds an instance of InterpreterPool that
will create Interpreter instances. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
InterpreterPool
public InterpreterPool()
- Builds an instance of
InterpreterPool
that
will create Interpreter
instances. Initializes
the InterpreterPool
to recognize the default
scripting languages.
getInterpreter
public Interpreter getInterpreter(Document document,
java.lang.String language)
- Returns a unique instance of an implementation of
Interpreter
interface that matches the given language and
the given Document
.
It returns null
if the interpreter cannot be build (for
example the language is not recognized by this
InterpreterPool
). If the document is not null
,
the variable "document" in the returned interpreter will give access
to an instance of Document
or SVGDocument
depending on the type of the document. The interpreter will
automatically be released
when the Document
will no longer be referenced elsewhere.
- Parameters:
document
- a DOM Document
instance.language
- a mimeType like string describing the language to use
(i.e. "text/ecmascript" for ECMAScript interpreter, "text/tcl" for Tcl
interpreter...).
putInterpreterFactory
public void putInterpreterFactory(java.lang.String language,
InterpreterFactory factory)
- Registers an
InterpreterFactory
for the given
language. This allows you to add other languages to the default
ones or to replace the InterpreterFactory
usually used
to create an Interpreter
instance for a particular language
by your own to be able to have your own interpreter.
- Parameters:
language
- the language for which the factory is registered.
removeInterpreterFactory
public void removeInterpreterFactory(java.lang.String language)
- Unregisters the
InterpreterFactory
of the given
language. It will then be impossible to create new Interpreter
instances for the given language.
- Parameters:
language
- the language for which the factory should
be unregistered.
Copyright © 2001 Apache Software Foundation. All Rights Reserved.