com.gargoylesoftware.htmlunit
Class ScriptEngine

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.ScriptEngine
Direct Known Subclasses:
JavaScriptEngine

public abstract class ScriptEngine
extends java.lang.Object

An abstract base class for scripting engines.

Version:
$Revision: 1.3 $
Author:
Mike Bowler, Ben Curren, Marc Guillemot, Daniel Gredler, David K. Taylor, Ahmed Ashour

Method Summary
abstract  java.lang.Object callFunction(HtmlPage htmlPage, java.lang.Object javaScriptFunction, java.lang.Object thisObject, java.lang.Object[] args, DomNode htmlElementScope)
 Call a JavaScript function and return the result.
 java.lang.Object execute(HtmlPage htmlPage, java.lang.String sourceCode, java.lang.String sourceName)
 Execute the specified source code in the context of the given page.
abstract  java.lang.Object execute(HtmlPage htmlPage, java.lang.String sourceCode, java.lang.String sourceName, HtmlElement htmlElement)
 Execute the specified source code in the context of the given page.
static org.apache.commons.logging.Log getScriptEngineLog()
 Return the log object that is being used to log information about the script engine.
 WebClient getWebClient()
 Return the web client that this engine is associated with.
abstract  void initialize(WebWindow webWindow)
 perform initialization for the given webWindow
abstract  boolean isScriptRunning()
 Indicates if Script is running in current thread.
 java.lang.String preProcess(HtmlPage htmlPage, java.lang.String sourceCode, java.lang.String sourceName, HtmlElement htmlElement)
 Pre process the specified source code in the context of the given page using the processor specified in the webclient.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

callFunction

public abstract java.lang.Object callFunction(HtmlPage htmlPage,
                                              java.lang.Object javaScriptFunction,
                                              java.lang.Object thisObject,
                                              java.lang.Object[] args,
                                              DomNode htmlElementScope)
Call a JavaScript function and return the result.

Parameters:
htmlPage - The page
javaScriptFunction - The function to call.
thisObject - The this object for class method calls.
args - The list of arguments to pass to the function.
htmlElementScope - The html element that will act as the context.
Returns:
The result of the function call.

execute

public java.lang.Object execute(HtmlPage htmlPage,
                                java.lang.String sourceCode,
                                java.lang.String sourceName)
Execute the specified source code in the context of the given page.

Parameters:
htmlPage - The page
sourceCode - The code to execute.
sourceName - A name for the chunk of code that is going to be executed. This will be used in error messages.
Returns:
The result of executing the specified code

execute

public abstract java.lang.Object execute(HtmlPage htmlPage,
                                         java.lang.String sourceCode,
                                         java.lang.String sourceName,
                                         HtmlElement htmlElement)
Execute the specified source code in the context of the given page.

Parameters:
htmlPage - The page
sourceCode - The code to execute.
sourceName - A name for the chunk of code that is going to be executed. This will be used in error messages.
htmlElement - The html element that will act as the context.
Returns:
The result of executing the specified code

getScriptEngineLog

public static org.apache.commons.logging.Log getScriptEngineLog()
Return the log object that is being used to log information about the script engine.

Returns:
The log

getWebClient

public final WebClient getWebClient()
Return the web client that this engine is associated with.

Returns:
The web client.

initialize

public abstract void initialize(WebWindow webWindow)
perform initialization for the given webWindow

Parameters:
webWindow - the web window to initialize for

isScriptRunning

public abstract boolean isScriptRunning()
Indicates if Script is running in current thread.
This allows code to know if there own evaluation is has been triggered by some script code.

Returns:
true if script is running.

preProcess

public java.lang.String preProcess(HtmlPage htmlPage,
                                   java.lang.String sourceCode,
                                   java.lang.String sourceName,
                                   HtmlElement htmlElement)
Pre process the specified source code in the context of the given page using the processor specified in the webclient. This method delegates to the pre processor handler specified in the WebClient. If no pre processor handler is defined, the original source code is returned unchanged.

Parameters:
htmlPage - The page
sourceCode - The code to process.
sourceName - A name for the chunk of code. This will be used in error messages.
htmlElement - The html element that will act as the context.
Returns:
The source code after being pre processed
See Also:
ScriptPreProcessor


Copyright © 2003-2016 AppPerfect Corporation. All Rights Reserved.