Interface Interpreter

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean containsVariable​(java.lang.String name)
      Tests whether the variable is defined in this interpreter.
      void destroy()
      Called when the interpreter is about to be destroyed.
      java.lang.Class<?> getClass​(java.lang.String clsnm)
      Returns the class defined in this interpreter, or null if not found.
      Function getFunction​(java.lang.String name, java.lang.Class[] argTypes)
      Returns the method of the specified name defined in this interpreter, or null if not defined.
      java.lang.String getLanguage()
      Returns the scripting language this interpreter is associated with.
      java.lang.Object getNativeInterpreter()
      Returns the native interpreter, or null if not available.
      Page getOwner()
      Returns the owner of this interpreter.
      java.lang.Object getVariable​(java.lang.String name)
      Returns the value of a variable defined in this interpreter.
      void init​(Page owner, java.lang.String zslang)
      Initializes the interpreter.
      void interpret​(java.lang.String script, Scope scope)
      Evaluates the script against the specified scope.
      void setVariable​(java.lang.String name, java.lang.Object value)
      Sets the value of a variable to this interpreter, as if they are defined in the interpreter.
      void unsetVariable​(java.lang.String name)
      Removes the value of a variable defined in this interpreter.
    • Method Detail

      • init

        void init​(Page owner,
                  java.lang.String zslang)
        Initializes the interpreter. It is called once when the new instance of interpreter is constructed.
        Parameters:
        zslang - the language this interpreter is associated with
      • destroy

        void destroy()
        Called when the interpreter is about to be destroyed. After called, this interpreter cannot be used again.
      • getOwner

        Page getOwner()
        Returns the owner of this interpreter.
      • getLanguage

        java.lang.String getLanguage()
        Returns the scripting language this interpreter is associated with.
      • getNativeInterpreter

        java.lang.Object getNativeInterpreter()
        Returns the native interpreter, or null if not available. The native interpreter depends on the implementation of an interpreter.
        Since:
        3.0.2
      • getClass

        java.lang.Class<?> getClass​(java.lang.String clsnm)
        Returns the class defined in this interpreter, or null if not found.
      • getFunction

        Function getFunction​(java.lang.String name,
                             java.lang.Class[] argTypes)
        Returns the method of the specified name defined in this interpreter, or null if not defined.
        Parameters:
        argTypes - the list of argument (a.k.a., parameter) types. If null, Class[0] is assumed.
        Since:
        3.0.0
      • containsVariable

        boolean containsVariable​(java.lang.String name)
        Tests whether the variable is defined in this interpreter. Note: it doesn't search the attributes (Scope).
        Since:
        2.4.0
      • getVariable

        java.lang.Object getVariable​(java.lang.String name)
        Returns the value of a variable defined in this interpreter. Note: it doesn't search the scope (Scope).
      • setVariable

        void setVariable​(java.lang.String name,
                         java.lang.Object value)
        Sets the value of a variable to this interpreter, as if they are defined in the interpreter.

        Note: it is not part of any namespace and it has higher priority if its name conflicts with any variable defined in the namespaces.

      • unsetVariable

        void unsetVariable​(java.lang.String name)
        Removes the value of a variable defined in this interpreter.