Package org.apache.batik.script.jpython
Class JPythonInterpreter
java.lang.Object
org.apache.batik.script.jpython.JPythonInterpreter
- All Implemented Interfaces:
Localizable
,Interpreter
A simple implementation of
Interpreter
interface to use
JPython python parser.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
bindObject
(String name, Object object) This method should register a particular JavaObject
in the environment of the interpreter.void
dispose()
This method can dispose resources used by the interpreter when it is no longer used.This method should evaluate a piece of script.This method should evaluate a piece of script associated to a given description.This method should evaluate a piece of script using aString
instead of aReader
.formatMessage
(String key, Object[] args) Creates and returns a localized message, given the key of the message in the resource bundle and the message parameters.Returns the current locale or null if the locale currently used is the default one.String[]
Returns the content types of the scripting languages this interpreter handles.void
Provides a way to the user to specify a locale which override the default one.void
This method should change the outputWriter
that will be used when output function of the scripting langage is used.
-
Constructor Details
-
JPythonInterpreter
public JPythonInterpreter()
-
-
Method Details
-
getMimeTypes
Returns the content types of the scripting languages this interpreter handles.- Specified by:
getMimeTypes
in interfaceInterpreter
-
evaluate
Description copied from interface:Interpreter
This method should evaluate a piece of script.- Specified by:
evaluate
in interfaceInterpreter
- Parameters:
scriptreader
- ajava.io.Reader
on the piece of script- Returns:
- if no exception is thrown during the call, should return the value of the last expression evaluated in the script
- Throws:
IOException
-
evaluate
Description copied from interface:Interpreter
This method should evaluate a piece of script associated to a given description.- Specified by:
evaluate
in interfaceInterpreter
- Parameters:
scriptreader
- ajava.io.Reader
on the piece of scriptdescription
- description which can be later used (e.g., for error messages).- Returns:
- if no exception is thrown during the call, should return the value of the last expression evaluated in the script
- Throws:
IOException
-
evaluate
Description copied from interface:Interpreter
This method should evaluate a piece of script using aString
instead of aReader
. This usually allows do easily do some caching.- Specified by:
evaluate
in interfaceInterpreter
- Parameters:
script
- the piece of script- Returns:
- if no exception is thrown during the call, should return the value of the last expression evaluated in the script
-
dispose
public void dispose()Description copied from interface:Interpreter
This method can dispose resources used by the interpreter when it is no longer used. Be careful, you SHOULD NOT use this interpreter instance after calling this method.- Specified by:
dispose
in interfaceInterpreter
-
bindObject
Description copied from interface:Interpreter
This method should register a particular JavaObject
in the environment of the interpreter.- Specified by:
bindObject
in interfaceInterpreter
- Parameters:
name
- the name of the script object to createobject
- the Java object
-
setOut
Description copied from interface:Interpreter
This method should change the outputWriter
that will be used when output function of the scripting langage is used.- Specified by:
setOut
in interfaceInterpreter
- Parameters:
out
- the new outWriter
.
-
getLocale
Description copied from interface:Localizable
Returns the current locale or null if the locale currently used is the default one.- Specified by:
getLocale
in interfaceLocalizable
-
setLocale
Description copied from interface:Localizable
Provides a way to the user to specify a locale which override the default one. If null is passed to this method, the used locale becomes the global one.- Specified by:
setLocale
in interfaceLocalizable
- Parameters:
locale
- The locale to set.
-
formatMessage
Description copied from interface:Localizable
Creates and returns a localized message, given the key of the message in the resource bundle and the message parameters. The messages in the resource bundle must have the syntax described in the java.text.MessageFormat class documentation.- Specified by:
formatMessage
in interfaceLocalizable
- Parameters:
key
- The key used to retreive the message from the resource bundle.args
- The objects that compose the message.
-