com.gargoylesoftware.htmlunit.javascript
Class SimpleScriptable

java.lang.Object
  extended by org.mozilla.javascript.ScriptableObject
      extended by com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
All Implemented Interfaces:
java.io.Serializable, org.mozilla.javascript.ConstProperties, org.mozilla.javascript.debug.DebuggableObject, org.mozilla.javascript.Scriptable
Direct Known Subclasses:
ActiveXObject, Attribute, DOMImplementation, Event, History, HTMLCollection, HTMLOptionsCollection, Location, Navigator, NodeImpl, Popup, Screen, Style, Stylesheet, TextRectangle, Window, XMLHttpRequest

public class SimpleScriptable
extends org.mozilla.javascript.ScriptableObject

A javascript object for a Location

Version:
$Revision: 1.3 $
Author:
Mike Bowler, David K. Taylor, Marc Guillemot, Chris Erskine, Daniel Gredler
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.mozilla.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
 
Fields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND
 
Constructor Summary
SimpleScriptable()
  
 
Method Summary
 java.lang.Object get(java.lang.String name, org.mozilla.javascript.Scriptable start)
 Get a named property from the object.
static boolean getBooleanArg(int index, java.lang.Object[] args, boolean defaultValue)
 Return the boolean value at the specified location in the argument list.
 java.lang.String getClassName()
 Return the javascript class name
 java.lang.Object getDefaultValue(java.lang.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.
 HtmlElement getHtmlElementOrDie()
 Return the html element that corresponds to this javascript object or throw an exception if one cannot be found.
 HtmlElement getHtmlElementOrNull()
 Return the html element that corresponds to this javascript object or null if an element hasn't been set.
static int getIntArg(int index, java.lang.Object[] args, int defaultValue)
 Return the int value at the specified location in the argument list.
static java.lang.Object getObjectArg(int index, java.lang.Object[] args, java.lang.Object defaultValue)
 Return the value at the specified location in the argument list.
static java.lang.String getStringArg(int index, java.lang.Object[] args, java.lang.String defaultValue)
 Return the string value at the specified location in the argument list.
 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
 void setHtmlElement(HtmlElement htmlElement)
 Set the html element that corresponds to this javascript object
 
Methods inherited from class org.mozilla.javascript.ScriptableObject
associateValue, avoidObjectDetection, callMethod, callMethod, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, 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
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleScriptable

public SimpleScriptable()
Method Detail

get

public java.lang.Object get(java.lang.String name,
                            org.mozilla.javascript.Scriptable start)
Get a named property from the object. Normally HtmlUnit objects don't need to overwrite this method as properties are defined on the prototypes from the xml configuration. In some cases where "content" of object has priority compared to the properties consider using utility getWithPreemption(String). For fallback case just implement ScriptableWithFallbackGetter.

Specified by:
get in interface org.mozilla.javascript.Scriptable
Overrides:
get in class org.mozilla.javascript.ScriptableObject

getBooleanArg

public static boolean getBooleanArg(int index,
                                    java.lang.Object[] args,
                                    boolean defaultValue)
Return the boolean value at the specified location in the argument list. If the index is larger than the argument array then return the default value.

Parameters:
index - The index into the argument list.
args - The argument list.
defaultValue - The default value to be used.
Returns:
The specified boolean or the default value.

getClassName

public java.lang.String getClassName()
Return the javascript class name

Specified by:
getClassName in interface org.mozilla.javascript.Scriptable
Specified by:
getClassName in class org.mozilla.javascript.ScriptableObject
Returns:
The javascript class name

getDefaultValue

public java.lang.Object getDefaultValue(java.lang.Class hint)
Return the javascript default value of this object. This is the javascript equivalent of a toString() in java.

Specified by:
getDefaultValue in interface org.mozilla.javascript.Scriptable
Overrides:
getDefaultValue in class org.mozilla.javascript.ScriptableObject
Parameters:
hint - A hint as to the format of the default value. Ignored in this case.
Returns:
The default value.

getDomNodeOrDie

public final DomNode getDomNodeOrDie()
                              throws java.lang.IllegalStateException
Return the DOM node that corresponds to this javascript object or throw an exception if one cannot be found.

Returns:
The DOM node
Throws:
java.lang.IllegalStateException - If the DOM node could not be found.

getDomNodeOrNull

public final DomNode getDomNodeOrNull()
Return the DOM node that corresponds to this javascript object or null if a node hasn't been set.

Returns:
The DOM node or null

getHtmlElementOrDie

public final HtmlElement getHtmlElementOrDie()
                                      throws java.lang.IllegalStateException
Return the html element that corresponds to this javascript object or throw an exception if one cannot be found.

Returns:
The html element
Throws:
java.lang.IllegalStateException - If the html element could not be found.

getHtmlElementOrNull

public final HtmlElement getHtmlElementOrNull()
Return the html element that corresponds to this javascript object or null if an element hasn't been set.

Returns:
The html element or null

getIntArg

public static int getIntArg(int index,
                            java.lang.Object[] args,
                            int defaultValue)
Return the int value at the specified location in the argument list. If the index is larger than the argument array then return the default value.

Parameters:
index - The index into the argument list.
args - The argument list.
defaultValue - The default value to be used.
Returns:
The specified int or the default value.

getObjectArg

public static java.lang.Object getObjectArg(int index,
                                            java.lang.Object[] args,
                                            java.lang.Object defaultValue)
Return the value at the specified location in the argument list. If the index is larger than the argument array then return the default value.

Parameters:
index - The index into the argument list.
args - The argument list.
defaultValue - The default value to return if the arg wasn't specified.
Returns:
The specified object or null

getStringArg

public static java.lang.String getStringArg(int index,
                                            java.lang.Object[] args,
                                            java.lang.String defaultValue)
Return the string value at the specified location in the argument list. If the index is larger than the argument array then return the default value.

Parameters:
index - The index into the argument list.
args - The argument list.
defaultValue - The default value to return if the arg wasn't specified.
Returns:
The specified string or null

makeScriptableFor

public SimpleScriptable makeScriptableFor(DomNode domNode)
Builds a new the javascript object that corresponds to the specified object.

Parameters:
domNode - the dom node for which a JS object should be created
Returns:
The javascript object

setDomNode

public void setDomNode(DomNode domNode)
Set the DOM node that corresponds to this javascript object

Parameters:
domNode - The DOM node

setHtmlElement

public void setHtmlElement(HtmlElement htmlElement)
Set the html element that corresponds to this javascript object

Parameters:
htmlElement - The html element


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