Class JavaxPacScriptParser

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.lang.String buildFunctionCallCode​(java.lang.String functionName, int args)
      Builds a JavaScript code snippet to call a function that we bind.
      java.lang.String evaluate​(java.lang.String url, java.lang.String host)
      Evaluates the given URL and host against the PAC script.
      PacScriptSource getScriptSource()
      Gets the source of the PAC script used by this parser.
      private delight.rhinosandox.RhinoSandbox setupEngine()
      Initializes the JavaScript engine and adds aliases for the functions defined in ScriptMethods.
      • Methods inherited from class java.lang.Object

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

      • SCRIPT_METHODS_OBJECT

        static final java.lang.String SCRIPT_METHODS_OBJECT
        See Also:
        Constant Field Values
      • SOURCE_NAME

        static final java.lang.String SOURCE_NAME
      • engine

        private final delight.rhinosandox.RhinoSandbox engine
    • Method Detail

      • setupEngine

        private delight.rhinosandox.RhinoSandbox setupEngine()
                                                      throws ProxyEvaluationException
        Initializes the JavaScript engine and adds aliases for the functions defined in ScriptMethods.
        Throws:
        ProxyEvaluationException - on error.
      • buildFunctionCallCode

        private java.lang.String buildFunctionCallCode​(java.lang.String functionName,
                                                       int args)
        Builds a JavaScript code snippet to call a function that we bind.
        Parameters:
        functionName - of the bound function
        args - of the bound function
        Returns:
        the JS code to invoke the method.
      • evaluate

        public java.lang.String evaluate​(java.lang.String url,
                                         java.lang.String host)
                                  throws ProxyEvaluationException
        Evaluates the given URL and host against the PAC script.
        Specified by:
        evaluate in interface PacScriptParser
        Parameters:
        url - the URL to evaluate.
        host - the host name part of the URL.
        Returns:
        the script result.
        Throws:
        ProxyEvaluationException - on execution error.