Class 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).

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String BIND_NAME_DOCUMENT
      Name of the "document" object when referenced by scripts
      protected static java.util.Map defaultFactories
      The default InterpreterFactory map.
      protected java.util.Map factories
      The InterpreterFactory map.
    • Constructor Summary

      Constructors 
      Constructor Description
      InterpreterPool()
      Constructs a new InterpreterPool.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Interpreter createInterpreter​(org.w3c.dom.Document document, java.lang.String language)
      Creates a new interpreter for the specified document and according to the specified language.
      Interpreter createInterpreter​(org.w3c.dom.Document document, java.lang.String language, ImportInfo imports)
      Creates a new interpreter for the specified document and according to the specified language.
      void putInterpreterFactory​(java.lang.String language, InterpreterFactory factory)
      Adds for the specified language, the specified Interpreter factory.
      void removeInterpreterFactory​(java.lang.String language)
      Removes the InterpreterFactory associated to the specified language.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • BIND_NAME_DOCUMENT

        public static final java.lang.String BIND_NAME_DOCUMENT
        Name of the "document" object when referenced by scripts
        See Also:
        Constant Field Values
      • defaultFactories

        protected static java.util.Map defaultFactories
        The default InterpreterFactory map.
      • factories

        protected java.util.Map factories
        The InterpreterFactory map.
    • Constructor Detail

      • InterpreterPool

        public InterpreterPool()
        Constructs a new InterpreterPool.
    • Method Detail

      • createInterpreter

        public Interpreter createInterpreter​(org.w3c.dom.Document document,
                                             java.lang.String language)
        Creates a new interpreter for the specified document and according to the specified language. This method can return null if no interpreter has been found for the specified language.
        Parameters:
        document - the document that needs the interpreter
        language - the scripting language
      • createInterpreter

        public Interpreter createInterpreter​(org.w3c.dom.Document document,
                                             java.lang.String language,
                                             ImportInfo imports)
        Creates a new interpreter for the specified document and according to the specified language. This method can return null if no interpreter has been found for the specified language.
        Parameters:
        document - the document that needs the interpreter
        language - the scripting language
        imports - The set of classes/packages to import (if the interpreter supports that).
      • putInterpreterFactory

        public void putInterpreterFactory​(java.lang.String language,
                                          InterpreterFactory factory)
        Adds for the specified language, the specified Interpreter factory.
        Parameters:
        language - the language for which the factory is registered
        factory - the InterpreterFactory to register
      • removeInterpreterFactory

        public void removeInterpreterFactory​(java.lang.String language)
        Removes the InterpreterFactory associated to the specified language.
        Parameters:
        language - the language for which the factory should be removed.