Class JPythonInterpreter

java.lang.Object
org.apache.batik.script.jpython.JPythonInterpreter
All Implemented Interfaces:
Localizable, Interpreter

public class JPythonInterpreter extends Object implements Interpreter
A simple implementation of Interpreter interface to use JPython python parser.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    bindObject(String name, Object object)
    This method should register a particular Java Object in the environment of the interpreter.
    void
    This method can dispose resources used by the interpreter when it is no longer used.
    evaluate(Reader scriptreader)
    This method should evaluate a piece of script.
    evaluate(Reader scriptreader, String description)
    This method should evaluate a piece of script associated to a given description.
    evaluate(String script)
    This method should evaluate a piece of script using a String instead of a Reader.
    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.
    Returns the content types of the scripting languages this interpreter handles.
    void
    setLocale(Locale locale)
    Provides a way to the user to specify a locale which override the default one.
    void
    This method should change the output Writer that will be used when output function of the scripting langage is used.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JPythonInterpreter

      public JPythonInterpreter()
  • Method Details

    • getMimeTypes

      public String[] getMimeTypes()
      Returns the content types of the scripting languages this interpreter handles.
      Specified by:
      getMimeTypes in interface Interpreter
    • evaluate

      public Object evaluate(Reader scriptreader) throws IOException
      Description copied from interface: Interpreter
      This method should evaluate a piece of script.
      Specified by:
      evaluate in interface Interpreter
      Parameters:
      scriptreader - a java.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

      public Object evaluate(Reader scriptreader, String description) throws IOException
      Description copied from interface: Interpreter
      This method should evaluate a piece of script associated to a given description.
      Specified by:
      evaluate in interface Interpreter
      Parameters:
      scriptreader - a java.io.Reader on the piece of script
      description - 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

      public Object evaluate(String script)
      Description copied from interface: Interpreter
      This method should evaluate a piece of script using a String instead of a Reader. This usually allows do easily do some caching.
      Specified by:
      evaluate in interface Interpreter
      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 interface Interpreter
    • bindObject

      public void bindObject(String name, Object object)
      Description copied from interface: Interpreter
      This method should register a particular Java Object in the environment of the interpreter.
      Specified by:
      bindObject in interface Interpreter
      Parameters:
      name - the name of the script object to create
      object - the Java object
    • setOut

      public void setOut(Writer out)
      Description copied from interface: Interpreter
      This method should change the output Writer that will be used when output function of the scripting langage is used.
      Specified by:
      setOut in interface Interpreter
      Parameters:
      out - the new out Writer.
    • getLocale

      public Locale 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 interface Localizable
    • setLocale

      public void setLocale(Locale locale)
      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 interface Localizable
      Parameters:
      locale - The locale to set.
    • formatMessage

      public String formatMessage(String key, Object[] args)
      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 interface Localizable
      Parameters:
      key - The key used to retreive the message from the resource bundle.
      args - The objects that compose the message.