public class HTMLOptionsCollection extends SimpleScriptable implements ScriptableWithFallbackGetter
Constructor and Description |
---|
HTMLOptionsCollection()
Creates an instance.
|
HTMLOptionsCollection(SimpleScriptable parentScope)
Creates an instance.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Object newOptionObject,
Object beforeOptionObject)
Adds a new item to the option collection.
|
Object |
get(int index,
net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
Returns the object at the specified index.
|
String |
getClassName()
Returns the JavaScript class name.
|
int |
getLength()
Returns the number of elements in this array.
|
Object |
getWithFallback(String name)
This method delegates the call to the parent select element.
|
void |
initialize(HtmlSelect select)
Initializes this object.
|
Object |
item(int index)
Returns the object at the specified index.
|
void |
put(int index,
net.sourceforge.htmlunit.corejs.javascript.Scriptable start,
Object newValue)
Sets the index property.
|
void |
put(String name,
net.sourceforge.htmlunit.corejs.javascript.Scriptable start,
Object value)
If IE is emulated, and this class does not have the specified property, and the owning
select *does* have the specified property, this method delegates the call to the parent
select element.
|
void |
remove(int index)
Removes the option at the specified index.
|
void |
setLength(int newLength)
Changes the number of options: removes options if the new length
is less than the current one else add new empty options to reach the
new length.
|
clone, defineFunctionProperties, defineProperty, equivalentValues, get, getBrowserVersion, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getTransformerScriptableFor, getWindow, getWindow, getWithPreemption, hasInstance, initParentScope, isReadOnlySettable, makeScriptableFor, setCaseSensitive, setClassName, setDomNode, setDomNode, setHtmlElement, setParentScope
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, getExternalArrayData, getExternalArrayLength, 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, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setPrototype, size
public HTMLOptionsCollection()
public HTMLOptionsCollection(SimpleScriptable parentScope)
parentScope
- parent scopepublic String getClassName()
getClassName
in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
getClassName
in class SimpleScriptable
public void initialize(HtmlSelect select)
select
- the HtmlSelect that this object will retrieve elements frompublic Object get(int index, net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
get
in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
get
in class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
index
- the indexstart
- the object that get is being called onpublic void put(String name, net.sourceforge.htmlunit.corejs.javascript.Scriptable start, Object value)
If IE is emulated, and this class does not have the specified property, and the owning select *does* have the specified property, this method delegates the call to the parent select element.
See getWithFallback(String)
for the corresponding getter behavior.
put
in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
put
in class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
name
- start
- value
- public Object getWithFallback(String name)
This method delegates the call to the parent select element.
See put(String, Scriptable, Object)
for the corresponding setter behavior.
getWithFallback
in interface ScriptableWithFallbackGetter
name
- the name of the requested propertyScriptable.NOT_FOUND
if nothing is foundpublic Object item(int index)
index
- the indexpublic void put(int index, net.sourceforge.htmlunit.corejs.javascript.Scriptable start, Object newValue)
put
in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
put
in class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
index
- the indexstart
- the scriptable object that was originally invoked for this propertynewValue
- the new valuepublic int getLength()
public void setLength(int newLength)
newLength
- the new length property valuepublic void add(Object newOptionObject, Object beforeOptionObject)
Implementation Note: The specification for the JavaScript add() method actually calls for the optional newIndex parameter to be an integer. However, the newIndex parameter is specified as an Object here rather than an int because of the way Rhino and HtmlUnit process optional parameters for the JavaScript method calls. If the newIndex parameter were specified as an int, then the Undefined value for an integer is specified as NaN (Not A Number, which is a Double value), but Rhino translates this value into 0 (perhaps correctly?) when converting NaN into an int. As a result, when the newIndex parameter is not specified, it is impossible to make a distinction between a caller of the form add(someObject) and add (someObject, 0). Since the behavior of these two call forms is different, the newIndex parameter is specified as an Object. If the newIndex parameter is not specified by the actual JavaScript code being run, then newIndex is of type net.sourceforge.htmlunit.corejs.javascript.Undefined. If the newIndex parameter is specified, then it should be of type java.lang.Number and can be converted into an integer value.
This method will call the put(int, Scriptable, Object)
method for actually
adding the element to the collection.
According to the Microsoft DHTML reference page for the JavaScript add() method of the options collection, the index parameter is specified as follows:
newOptionObject
- the DomNode to insert in the collectionbeforeOptionObject
- An optional parameter which specifies the index position in the
collection where the element is placed. If no value is given, the method places
the element at the end of the collection.put(int, Scriptable, Object)
public void remove(int index)
index
- the option indexCopyright © 2002–2015 Gargoyle Software Inc.. All rights reserved.