com.gargoylesoftware.htmlunit.javascript
Class ScriptableWrapper

java.lang.Object
  extended by net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
      extended by com.gargoylesoftware.htmlunit.javascript.ScriptableWrapper
All Implemented Interfaces:
Serializable, Map, net.sourceforge.htmlunit.corejs.javascript.ConstProperties, net.sourceforge.htmlunit.corejs.javascript.debug.DebuggableObject, net.sourceforge.htmlunit.corejs.javascript.Scriptable

public class ScriptableWrapper
extends net.sourceforge.htmlunit.corejs.javascript.ScriptableObject

Simple wrapper to make "normal" object scriptable according to specific configuration and allowing use of index properties. TODO: Configuration of the properties and functions should occur from the XML configuration according to the browser to simulate.

Version:
$Revision: 5864 $
Author:
Marc Guillemot
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
 
Fields inherited from interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
NOT_FOUND
 
Constructor Summary
ScriptableWrapper(net.sourceforge.htmlunit.corejs.javascript.Scriptable scope, Object javaObject, Class<?> staticType)
          Constructs a wrapper for the java object.
 
Method Summary
 Object get(int index, net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
          
 Object get(String name, net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
          
 String getClassName()
          
 Object getDefaultValue(Class<?> hint)
          
 Object getWrappedObject()
          Gets the java object made availabe to JavaScript through this wrapper.
 boolean has(String name, net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
          
protected  Object invoke(Method method)
          Invokes the method on the wrapped object.
protected  Object invoke(Method method, Object[] args)
          Invokes the method on the wrapped object.
 String jsToString()
          To use as "toString" function in JavaScript.
 
Methods inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, clear, containsKey, containsValue, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, entrySet, equivalentValues, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypeOf, has, hasInstance, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, keySet, preventExtensions, put, put, put, putAll, putConst, putConstProperty, putProperty, putProperty, redefineProperty, remove, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype, size, values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

ScriptableWrapper

public ScriptableWrapper(net.sourceforge.htmlunit.corejs.javascript.Scriptable scope,
                         Object javaObject,
                         Class<?> staticType)
Constructs a wrapper for the java object.

Parameters:
scope - the scope of the executing script
javaObject - the javaObject to wrap
staticType - the static type of the object
Method Detail

get

public Object get(String name,
                  net.sourceforge.htmlunit.corejs.javascript.Scriptable start)

Specified by:
get in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
Overrides:
get in class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
See Also:
ScriptableObject.get(java.lang.String,net.sourceforge.htmlunit.corejs.javascript.Scriptable)

has

public boolean has(String name,
                   net.sourceforge.htmlunit.corejs.javascript.Scriptable start)

Specified by:
has in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
Overrides:
has in class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
See Also:
ScriptableObject.has(java.lang.String, net.sourceforge.htmlunit.corejs.javascript.Scriptable)

invoke

protected Object invoke(Method method)
Invokes the method on the wrapped object.

Parameters:
method - the method to invoke
Returns:
the invocation result

invoke

protected Object invoke(Method method,
                        Object[] args)
Invokes the method on the wrapped object.

Parameters:
method - the method to invoke
args - the argument to pass to the method
Returns:
the invocation result

get

public Object get(int index,
                  net.sourceforge.htmlunit.corejs.javascript.Scriptable start)

Specified by:
get in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
Overrides:
get in class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
See Also:
ScriptableObject.get(int, net.sourceforge.htmlunit.corejs.javascript.Scriptable)

getDefaultValue

public Object getDefaultValue(Class<?> hint)

Specified by:
getDefaultValue in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
Overrides:
getDefaultValue in class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
See Also:
ScriptableObject.getDefaultValue(java.lang.Class)

jsToString

public String jsToString()
To use as "toString" function in JavaScript.

Returns:
the string representation

getClassName

public String getClassName()

Specified by:
getClassName in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
Specified by:
getClassName in class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
See Also:
ScriptableObject.getClassName()

getWrappedObject

public Object getWrappedObject()
Gets the java object made availabe to JavaScript through this wrapper.

Returns:
the wrapped object


Copyright © 2002-2011 Gargoyle Software Inc.. All Rights Reserved.