com.meterware.httpunit.scripting
Class ScriptableDelegate

java.lang.Object
  extended bycom.meterware.httpunit.scripting.ScriptableDelegate
All Implemented Interfaces:
ScriptingEventHandler, ScriptingHandler
Direct Known Subclasses:
com.meterware.httpunit.HTMLElementScriptable, HTMLPage.Scriptable, WebResponse.Scriptable

public abstract class ScriptableDelegate
extends java.lang.Object
implements ScriptingHandler

An interface for objects which will be accessible via scripting.

Author:
Russell Gold

Field Summary
static ScriptingEngine NULL_SCRIPT_ENGINE
          a dummy ScriptingEngine implementation
 
Constructor Summary
ScriptableDelegate()
           
 
Method Summary
 void clearCaches()
           
 boolean doEvent(java.lang.String eventScript)
          Deprecated. since 1.7 - use doEventScript instead
 boolean doEventScript(java.lang.String eventScript)
          Executes the specified scripted event.
 java.lang.Object evaluateExpression(java.lang.String urlString)
          Evaluates the specified javascript expression, returning its value.
 java.lang.Object get(int index)
          Returns the value of the index property.
 java.lang.Object get(java.lang.String propertyName)
          Returns the value of the named property.
protected  ScriptableDelegate[] getDelegates(HTMLElement[] elements)
           
 ScriptingEngine getScriptEngine()
           
 ScriptingEngine getScriptEngine(ScriptableDelegate child)
           
 boolean handleEvent(java.lang.String eventName)
          Executes the event Handler script for the specified event (such as onchange, onmousedown, onclick, onmouseup) if it is defined.
 java.lang.String runScript(java.lang.String language, java.lang.String script)
          Executes the specified script, returning any intended replacement text.
 void set(java.lang.String propertyName, java.lang.Object value)
          Sets the value of the named property.
 void setScriptEngine(ScriptingEngine scriptEngine)
          Specifies the scripting engine to be used.
 boolean supportsScriptLanguage(java.lang.String language)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_SCRIPT_ENGINE

public static final ScriptingEngine NULL_SCRIPT_ENGINE
a dummy ScriptingEngine implementation

Constructor Detail

ScriptableDelegate

public ScriptableDelegate()
Method Detail

supportsScriptLanguage

public boolean supportsScriptLanguage(java.lang.String language)
Specified by:
supportsScriptLanguage in interface ScriptingHandler

doEvent

public boolean doEvent(java.lang.String eventScript)
Deprecated. since 1.7 - use doEventScript instead

handle the event that has the given script attached by compiling the eventScript as a function and executing it

Specified by:
doEvent in interface ScriptingEventHandler
Parameters:
eventScript - - the script to use
Returns:
true if the script is empty or the result of the script

doEventScript

public boolean doEventScript(java.lang.String eventScript)
Executes the specified scripted event.

Specified by:
doEventScript in interface ScriptingEventHandler
Parameters:
eventScript - - the eventScript to execute
Returns:
true if the event has been handled.

handleEvent

public boolean handleEvent(java.lang.String eventName)
Executes the event Handler script for the specified event (such as onchange, onmousedown, onclick, onmouseup) if it is defined.

Specified by:
handleEvent in interface ScriptingEventHandler
Parameters:
eventName - the name of the event for which a handler should be run.
Returns:
whether the event with the given name was handled

runScript

public java.lang.String runScript(java.lang.String language,
                                  java.lang.String script)
Executes the specified script, returning any intended replacement text.

Specified by:
runScript in interface ScriptingHandler
Returns:
the replacement text, which may be empty.

evaluateExpression

public java.lang.Object evaluateExpression(java.lang.String urlString)
Evaluates the specified javascript expression, returning its value.

Specified by:
evaluateExpression in interface ScriptingHandler

clearCaches

public void clearCaches()
Specified by:
clearCaches in interface ScriptingHandler

get

public java.lang.Object get(java.lang.String propertyName)
Returns the value of the named property. Will return null if the property does not exist.


get

public java.lang.Object get(int index)
Returns the value of the index property. Will return null if the property does not exist.


set

public void set(java.lang.String propertyName,
                java.lang.Object value)
Sets the value of the named property. Will throw a runtime exception if the property does not exist or cannot accept the specified value.


setScriptEngine

public void setScriptEngine(ScriptingEngine scriptEngine)
Specifies the scripting engine to be used.


getScriptEngine

public ScriptingEngine getScriptEngine()

getScriptEngine

public ScriptingEngine getScriptEngine(ScriptableDelegate child)

getDelegates

protected ScriptableDelegate[] getDelegates(HTMLElement[] elements)

Copyright © 2000-2008 Russell Gold. See license agreement for rights granted.