Package com.adobe.xfa

Class ScriptHandler

  • Direct Known Subclasses:
    FormCalcScriptHandler, RhinoScriptHandler

    public abstract class ScriptHandler
    extends java.lang.Object
    A base class to handle scripting engines. A script handler is used by an XFA application model to enable scripting support. A script handler provides support for one particular language.
    • Constructor Detail

      • ScriptHandler

        public ScriptHandler()
        Instantiates a script handler.
      • ScriptHandler

        public ScriptHandler​(ScriptDebugger oDebugger)
        Instantiates a script handler using the given debugger.
        Parameters:
        oDebugger - a script debugger.
    • Method Detail

      • createScriptHandler

        public static ScriptHandler createScriptHandler​(java.lang.String contentType,
                                                        AppModel appModel,
                                                        ScriptDebugger debugger)
        Deprecated.
        This won't work in client environments.
        Create a new ScriptHandler that can handle a given contentType.
        Parameters:
        contentType - the contentType of the script.
        appModel - the AppModel that contains the context for the script.
        debugger - the ScriptDebugger for debugging the script, or null if debugging is not required.
        Returns:
        a new ScriptHandler.
        Throws:
        ExFull - if the contentType is not recognized.
      • setDebugger

        public void setDebugger​(ScriptDebugger oDebugger)
        Set the debugger for this script handler. Can also be specified in the constructor.
      • executeOrSyntaxCheck

        public abstract void executeOrSyntaxCheck​(java.lang.String script,
                                                  Arg oReturnValue,
                                                  int eReason,
                                                  boolean bSyntaxCheckOnly)
        Executes or checks the syntax of the given script.
        Parameters:
        script - the script to execute.
        oReturnValue - the return value of the script.
        eReason - the reason for the execution of the script.
        bSyntaxCheckOnly - the flag to only check syntax when set.
        Throws:
        ExFull - whenever errors are reported.
      • execute

        public void execute​(java.lang.String script,
                            java.lang.String locale,
                            Arg returnValue,
                            int eReason)
        Executes the given script.
        Parameters:
        script - the script to execute.
        locale - the operating locale.
        returnValue - the return value of the script.
        eReason - the reason for the execution of the script.
        Throws:
        ExFull - whenever errors are reported.
      • syntaxCheck

        public void syntaxCheck​(java.lang.String script)
        Checks the given script for syntax errors. Errors are reported in the form of a scriptException exception (scriptException derives from ExFull).
        Parameters:
        script - the script to execute.
        Throws:
        ScriptHandler.ScriptException - upon syntax error. ScriptException derives from ExFull.
      • languageName

        public abstract java.lang.String languageName()
        Gets the name of the scripting language supported by this script handler.
        Returns:
        the name of the scripting language.
      • setOption

        public void setOption​(java.lang.String sOptionName,
                              java.lang.String sOptionValue)
        Sets the value of the given option. If the option is unknown, the call is ignored.
        Parameters:
        sOptionName - the name of the option to set.
        sOptionValue - the value to set.
      • getOption

        public java.lang.String getOption​(java.lang.String sOptionName)
        Gets the value of the given option. If the option is unknown, the empty string is returned.
        Parameters:
        sOptionName - the name of the option to get.
        Returns:
        the value of the specified option as a string.
      • wasFatalError

        public boolean wasFatalError()
        Determines the severity of an error is returned from execute().
      • clone

        public abstract ScriptHandler clone()
        Clones this script handler.
        Returns:
        a copy of this script handler.
      • stringToExecuteReason

        public static int stringToExecuteReason​(java.lang.String sReason)
        Converts a string into an executeReason.
        Returns:
        the executeReason representing the string (UNSPECIFIED if not recognized).
      • executeReasonToString

        public static java.lang.String executeReasonToString​(int eReason)
        Converts an executeReason into a string.
        Returns:
        the string representing the executeReason ("other" if not recognized).
      • executeReasonToXFAEnum

        public static int executeReasonToXFAEnum​(int eReason)
        Converts an executeReason into an XFAEnum.
        Returns:
        the XFAEnum corresponding to the executeReason (NULL if not recognized). Note in particular that UNSPECIFIED, CALCULATE, and VALIDATE have no XFAEnum equivalent.
      • getDebugger

        public ScriptDebugger getDebugger()
        Get the debugger for this script handler.
      • debugCommand

        public boolean debugCommand​(int eCmd)
        Set an internal flag in the script handler indicating that, when control is returned to the script handler, it should perform a step-over, step-into or step-out function (calling the stopped callback on the associated debugger).
      • debugBreakPoint

        public boolean debugBreakPoint​(int nScriptID,
                                       int nLine,
                                       int eSetType)
        Set or clear a break-point.
      • debugGetStack

        public boolean debugGetStack​(java.util.List<java.lang.String> oStack)
        Get the current stack frame.
      • debugGetVariables

        public boolean debugGetVariables​(java.util.List<java.lang.String> oVarNames,
                                         java.util.List<Arg> oVarValues)
        Retrieve parallel lists of variable names and their values (lists have the same size). Note that this will only give meaningful results when stopped at a break-point.
      • removeReference

        public void removeReference​(Node oNode)
        Removes any script references to the node and the descendants