Package org.apache.batik.script.jpython
Class JPythonInterpreter
- java.lang.Object
-
- org.apache.batik.script.jpython.JPythonInterpreter
-
- All Implemented Interfaces:
Localizable,Interpreter
public class JPythonInterpreter extends java.lang.Object implements Interpreter
A simple implementation ofInterpreterinterface to use JPython python parser.- Version:
- $Id: JPythonInterpreter.java 1733416 2016-03-03 07:07:13Z gadams $
-
-
Field Summary
Fields Modifier and Type Field Description private org.python.util.PythonInterpreterinterpreter
-
Constructor Summary
Constructors Constructor Description JPythonInterpreter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbindObject(java.lang.String name, java.lang.Object object)This method should register a particular JavaObjectin the environment of the interpreter.voiddispose()This method can dispose resources used by the interpreter when it is no longer used.java.lang.Objectevaluate(java.io.Reader scriptreader)This method should evaluate a piece of script.java.lang.Objectevaluate(java.io.Reader scriptreader, java.lang.String description)This method should evaluate a piece of script associated to a given description.java.lang.Objectevaluate(java.lang.String script)This method should evaluate a piece of script using aStringinstead of aReader.java.lang.StringformatMessage(java.lang.String key, java.lang.Object[] args)Creates and returns a localized message, given the key of the message in the resource bundle and the message parameters.java.util.LocalegetLocale()Returns the current locale or null if the locale currently used is the default one.java.lang.String[]getMimeTypes()Returns the content types of the scripting languages this interpreter handles.voidsetLocale(java.util.Locale locale)Provides a way to the user to specify a locale which override the default one.voidsetOut(java.io.Writer out)This method should change the outputWriterthat will be used when output function of the scripting langage is used.
-
-
-
Method Detail
-
getMimeTypes
public java.lang.String[] getMimeTypes()
Returns the content types of the scripting languages this interpreter handles.- Specified by:
getMimeTypesin interfaceInterpreter
-
evaluate
public java.lang.Object evaluate(java.io.Reader scriptreader) throws java.io.IOExceptionDescription copied from interface:InterpreterThis method should evaluate a piece of script.- Specified by:
evaluatein interfaceInterpreter- Parameters:
scriptreader- ajava.io.Readeron 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:
java.io.IOException
-
evaluate
public java.lang.Object evaluate(java.io.Reader scriptreader, java.lang.String description) throws java.io.IOExceptionDescription copied from interface:InterpreterThis method should evaluate a piece of script associated to a given description.- Specified by:
evaluatein interfaceInterpreter- Parameters:
scriptreader- ajava.io.Readeron 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:
java.io.IOException
-
evaluate
public java.lang.Object evaluate(java.lang.String script)
Description copied from interface:InterpreterThis method should evaluate a piece of script using aStringinstead of aReader. This usually allows do easily do some caching.- Specified by:
evaluatein 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:InterpreterThis 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:
disposein interfaceInterpreter
-
bindObject
public void bindObject(java.lang.String name, java.lang.Object object)Description copied from interface:InterpreterThis method should register a particular JavaObjectin the environment of the interpreter.- Specified by:
bindObjectin interfaceInterpreter- Parameters:
name- the name of the script object to createobject- the Java object
-
setOut
public void setOut(java.io.Writer out)
Description copied from interface:InterpreterThis method should change the outputWriterthat will be used when output function of the scripting langage is used.- Specified by:
setOutin interfaceInterpreter- Parameters:
out- the new outWriter.
-
getLocale
public java.util.Locale getLocale()
Description copied from interface:LocalizableReturns the current locale or null if the locale currently used is the default one.- Specified by:
getLocalein interfaceLocalizable
-
setLocale
public void setLocale(java.util.Locale locale)
Description copied from interface:LocalizableProvides 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:
setLocalein interfaceLocalizable- Parameters:
locale- The locale to set.
-
formatMessage
public java.lang.String formatMessage(java.lang.String key, java.lang.Object[] args)Description copied from interface:LocalizableCreates 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:
formatMessagein interfaceLocalizable- Parameters:
key- The key used to retreive the message from the resource bundle.args- The objects that compose the message.
-
-