Package org.htmlunit.javascript.host
Class SimpleArray
- java.lang.Object
-
- org.htmlunit.corejs.javascript.ScriptableObject
-
- org.htmlunit.javascript.HtmlUnitScriptable
-
- org.htmlunit.javascript.host.SimpleArray
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,org.htmlunit.corejs.javascript.ConstProperties
,org.htmlunit.corejs.javascript.debug.DebuggableObject
,org.htmlunit.corejs.javascript.Scriptable
,org.htmlunit.corejs.javascript.SymbolScriptable
- Direct Known Subclasses:
MimeTypeArray
,Plugin
,PluginArray
public class SimpleArray extends HtmlUnitScriptable
A JavaScript object forSimpleArray
allowing access per key and index (likeMimeTypeArray
).- See Also:
- XUL Planet, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.Object>
elements_
-
Constructor Summary
Constructors Constructor Description SimpleArray()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
add(java.lang.Object element)
Adds an element.java.lang.Object
get(int index, org.htmlunit.corejs.javascript.Scriptable start)
Returns the element at the specified index, ornull
if the index is invalid.protected java.lang.String
getItemName(java.lang.Object element)
Gets the name of the element.int
getLength()
Gets the array size.protected java.lang.Object
getWithPreemption(java.lang.String name)
Called byHtmlUnitScriptable.get(String, Scriptable)
to allow retrieval of the property before the prototype chain is searched.java.lang.Object
item(int index)
Returns the item at the given index.java.lang.Object
namedItem(java.lang.String name)
Returns the item at the given index.-
Methods inherited from class org.htmlunit.javascript.HtmlUnitScriptable
clone, equivalentValues, get, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, has, hasInstance, initParentScope, makeScriptableFor, put, setClassName, setDomNode, setDomNode, setParentScope, setupPromise, setupRejectedPromise
-
Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, size
-
-
-
-
Method Detail
-
item
public java.lang.Object item(int index)
Returns the item at the given index.- Parameters:
index
- the index- Returns:
- the item at the given position
-
getWithPreemption
protected java.lang.Object getWithPreemption(java.lang.String name)
Called by
HtmlUnitScriptable.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!
- Overrides:
getWithPreemption
in classHtmlUnitScriptable
- Parameters:
name
- the property name- Returns:
Scriptable.NOT_FOUND
if not found
-
get
public final java.lang.Object get(int index, org.htmlunit.corejs.javascript.Scriptable start)
Returns the element at the specified index, ornull
if the index is invalid.- Specified by:
get
in interfaceorg.htmlunit.corejs.javascript.Scriptable
- Overrides:
get
in classorg.htmlunit.corejs.javascript.ScriptableObject
-
namedItem
public java.lang.Object namedItem(java.lang.String name)
Returns the item at the given index.- Parameters:
name
- the item name- Returns:
- the item with the given name
-
getItemName
protected java.lang.String getItemName(java.lang.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
-
add
void add(java.lang.Object element)
Adds an element.- Parameters:
element
- the element to add
-
-