com.gargoylesoftware.htmlunit.javascript.host
Class SimpleArray

java.lang.Object
  extended by net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
      extended by com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
          extended by com.gargoylesoftware.htmlunit.javascript.host.SimpleArray
All Implemented Interfaces:
ScriptableWithFallbackGetter, Serializable, Cloneable, net.sourceforge.htmlunit.corejs.javascript.ConstProperties, net.sourceforge.htmlunit.corejs.javascript.debug.DebuggableObject, net.sourceforge.htmlunit.corejs.javascript.Scriptable
Direct Known Subclasses:
MimeTypeArray, Plugin, PluginArray

public class SimpleArray
extends SimpleScriptable
implements ScriptableWithFallbackGetter

A JavaScript object for simple array allowing access per key and index (like MimeTypeArray).

Version:
$Revision: 7931 $
Author:
Marc Guillemot
See Also:
XUL Planet, Serialized Form

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
SimpleArray()
          Creates an instance.
 
Method Summary
 Object get(int index, net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
          Returns the element at the specified index, or NOT_FOUND if the index is invalid.
protected  String getItemName(Object element)
          Gets the name of the element.
 int getLength()
          Gets the array size.
 Object getWithFallback(String name)
          Fallback called when no configured property is found with the given name on the Scriptable object.
 Object item(int index)
          Returns the item at the given index.
 Object namedItem(String name)
          Returns the item at the given index.
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
clone, defineFunctionProperties, defineProperty, equivalentValues, get, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getTransformerScriptableFor, getWindow, getWindow, getWithPreemption, hasInstance, initParentScope, isReadOnlySettable, makeScriptableFor, setCaseSensitive, setDomNode, setDomNode, setHtmlElement, setParentScope
 
Methods inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setPrototype, size
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
delete, delete, get, getClassName, getDefaultValue, getIds, getParentScope, getPrototype, has, has, hasInstance, put, put, setParentScope, setPrototype
 

Constructor Detail

SimpleArray

public SimpleArray()
Creates an instance. JavaScript objects must have a default constructor.

Method Detail

item

public Object item(int index)
Returns the item at the given index.

Parameters:
index - the index
Returns:
the item at the given position

getWithFallback

public Object getWithFallback(String name)
Fallback called when no configured property is found with the given name on the Scriptable object.

Specified by:
getWithFallback in interface ScriptableWithFallbackGetter
Parameters:
name - the name of the requested property
Returns:
the object value, Scriptable.NOT_FOUND if nothing is found

get

public final Object get(int index,
                        net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
Returns the element at the specified index, or NOT_FOUND if the index is invalid.

Specified by:
get in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
Overrides:
get in class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject

namedItem

public Object namedItem(String name)
Returns the item at the given index.

Parameters:
name - the item name
Returns:
the item with the given name

getItemName

protected String getItemName(Object element)
Gets the name of the element. Should be abstract but current implementation of prototype configuration doesn't allow it.

Parameters:
element - the array's element
Returns:
the element's name

getLength

public int getLength()
Gets the array size.

Returns:
the number elements


Copyright © 2002–2013 Gargoyle Software Inc.. All rights reserved.