public class SimpleScriptable
extends org.mozilla.javascript.ScriptableObject
Constructor and Description |
---|
SimpleScriptable() |
Modifier and Type | Method and Description |
---|---|
Object |
get(String name,
org.mozilla.javascript.Scriptable start)
Get a named property from the object.
|
static boolean |
getBooleanArg(int index,
Object[] args,
boolean defaultValue)
Return the boolean value at the specified location in the argument list.
|
String |
getClassName()
Return the javascript class name
|
Object |
getDefaultValue(Class hint)
Return the javascript default value of this object.
|
DomNode |
getDomNodeOrDie()
Return the DOM node that corresponds to this javascript object or throw
an exception if one cannot be found.
|
DomNode |
getDomNodeOrNull()
Return the DOM node that corresponds to this javascript object
or null if a node hasn't been set.
|
static int |
getIntArg(int index,
Object[] args,
int defaultValue)
Return the int value at the specified location in the argument list.
|
protected org.apache.commons.logging.Log |
getLog()
Return the log that is being used for all scripting objects
|
static Object |
getObjectArg(int index,
Object[] args,
Object defaultValue)
Return the value at the specified location in the argument list.
|
protected org.mozilla.javascript.Scriptable |
getPrototype(Class javaScriptClass)
Get the prototype object for the given host class
|
protected SimpleScriptable |
getScriptableFor(Object object)
Return the javascript object that corresponds to the specified object.
|
protected org.mozilla.javascript.Scriptable |
getStartingScope()
Gets the scriptable used at starting scope for the execution of current script.
|
static String |
getStringArg(int index,
Object[] args,
String defaultValue)
Return the string value at the specified location in the argument list.
|
protected org.apache.commons.collections.Transformer |
getTransformerScriptableFor()
Gets a transformer getting the scriptable element for an HtmlElement
|
protected Window |
getWindow()
Gets the window that is the top scope for this object.
|
protected static Window |
getWindow(org.mozilla.javascript.Scriptable s)
Gets the window that is the top scope for the specified object.
|
protected Object |
getWithPreemption(String name)
Called by
get(String, Scriptable) to allow retrieval of the property before the prototype
chain is searched. |
SimpleScriptable |
makeScriptableFor(DomNode domNode)
Builds a new the javascript object that corresponds to the specified object.
|
void |
setDomNode(DomNode domNode)
Set the DOM node that corresponds to this javascript object
|
protected void |
setDomNode(DomNode domNode,
boolean assignScriptObject)
Set the DOM node that corresponds to this javascript object
|
void |
setHtmlElement(HtmlElement htmlElement)
Set the html element that corresponds to this javascript object
|
associateValue, callMethod, callMethod, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, equivalentValues, get, getAllIds, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, has, has, hasInstance, hasProperty, hasProperty, isConst, isSealed, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype
public Object get(String name, org.mozilla.javascript.Scriptable start)
getWithPreemption(String)
.
For fallback case just implement ScriptableWithFallbackGetter
.
get
in interface org.mozilla.javascript.Scriptable
get
in class org.mozilla.javascript.ScriptableObject
protected Object getWithPreemption(String name)
Called by get(String, Scriptable)
to allow retrieval of the property before the prototype
chain is searched.
IMPORTANT: This method is invoked *very* often by Rhino. If you override this method, the implementation needs to be as fast as possible!
name
- the property nameScriptable.NOT_FOUND
if not foundpublic String getClassName()
getClassName
in interface org.mozilla.javascript.Scriptable
getClassName
in class org.mozilla.javascript.ScriptableObject
public final DomNode getDomNodeOrDie() throws IllegalStateException
IllegalStateException
- If the DOM node could not be found.public final DomNode getDomNodeOrNull()
public void setDomNode(DomNode domNode)
domNode
- The DOM nodeprotected void setDomNode(DomNode domNode, boolean assignScriptObject)
domNode
- The DOM nodeassignScriptObject
- If true, call setScriptObject
on domNodepublic void setHtmlElement(HtmlElement htmlElement)
htmlElement
- The html elementprotected final org.apache.commons.logging.Log getLog()
protected SimpleScriptable getScriptableFor(Object object)
public SimpleScriptable makeScriptableFor(DomNode domNode)
domNode
- the dom node for which a JS object should be createdprotected org.mozilla.javascript.Scriptable getPrototype(Class javaScriptClass)
javaScriptClass
- the host classprotected org.apache.commons.collections.Transformer getTransformerScriptableFor()
public static Object getObjectArg(int index, Object[] args, Object defaultValue)
index
- The index into the argument list.args
- The argument list.defaultValue
- The default value to return if the arg wasn't specified.public static String getStringArg(int index, Object[] args, String defaultValue)
index
- The index into the argument list.args
- The argument list.defaultValue
- The default value to return if the arg wasn't specified.public static boolean getBooleanArg(int index, Object[] args, boolean defaultValue)
index
- The index into the argument list.args
- The argument list.defaultValue
- The default value to be used.public static int getIntArg(int index, Object[] args, int defaultValue)
index
- The index into the argument list.args
- The argument list.defaultValue
- The default value to be used.public Object getDefaultValue(Class hint)
getDefaultValue
in interface org.mozilla.javascript.Scriptable
getDefaultValue
in class org.mozilla.javascript.ScriptableObject
hint
- A hint as to the format of the default value. Ignored in this case.protected Window getWindow() throws RuntimeException
RuntimeException
- If the window cannot be found, which should never occur.protected static Window getWindow(org.mozilla.javascript.Scriptable s) throws RuntimeException
s
- The JavaScript object whose associated window is to be returned.RuntimeException
- If the window cannot be found, which should never occur.protected org.mozilla.javascript.Scriptable getStartingScope()
JavaScriptEngine.callFunction(com.gargoylesoftware.htmlunit.html.HtmlPage, java.lang.Object, java.lang.Object, java.lang.Object[], com.gargoylesoftware.htmlunit.html.DomNode)
or JavaScriptEngine.execute(com.gargoylesoftware.htmlunit.html.HtmlPage, java.lang.String, java.lang.String, int)
.Copyright © 2002-2012 Gargoyle Software Inc.. All Rights Reserved.