com.gargoylesoftware.htmlunit.javascript.host
Class Element

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.Node
              extended by com.gargoylesoftware.htmlunit.javascript.host.EventNode
                  extended by com.gargoylesoftware.htmlunit.javascript.host.Element
All Implemented Interfaces:
Serializable, Cloneable, Map, net.sourceforge.htmlunit.corejs.javascript.ConstProperties, net.sourceforge.htmlunit.corejs.javascript.debug.DebuggableObject, net.sourceforge.htmlunit.corejs.javascript.Scriptable
Direct Known Subclasses:
HTMLElement

public class Element
extends EventNode

A JavaScript object for DomElement.

Version:
$Revision: 5864 $
Author:
Ahmed Ashour, Marc Guillemot, Sudhan Moghe
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 com.gargoylesoftware.htmlunit.javascript.host.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
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
Element()
           
 
Method Summary
protected  NamedNodeMap createAttributesObject()
          Creates the JS object for the property attributes.
protected  String fixAttributeName(String attributeName)
          Allows subclasses to transform the attribute name before it gets used.
 DomElement getDomNodeOrDie()
          Returns the DOM node that corresponds to this JavaScript object or throw an exception if one cannot be found.
 Object jsxFunction_getAttribute(String attributeName, Integer flags)
          Returns the value of the specified attribute.
 Object jsxFunction_getAttributeNode(String name)
          Retrieves an attribute node by name.
 Object jsxFunction_getElementsByTagName(String tagName)
          Returns all the descendant elements with the specified tag name.
 Object jsxFunction_getElementsByTagNameNS(Object namespaceURI, String localName)
          Returns a list of elements with the given tag name belonging to the given namespace.
 boolean jsxFunction_hasAttribute(String name)
          Returns true when an attribute with a given name is specified on this element or has a default value.
 void jsxFunction_removeAttribute(String name)
          Removes the specified attribute.
 HTMLCollection jsxFunction_selectNodes(String expression)
          Applies the specified XPath expression to this node's context and returns the generated list of matching nodes.
 Object jsxFunction_selectSingleNode(String expression)
          Applies the specified pattern-matching operation to this node's context and returns the first matching node.
 void jsxFunction_setAttribute(String name, String value)
          Sets an attribute.
 Object jsxGet_attributes()
          Returns the attributes of this XML element.
 String jsxGet_tagName()
          Returns the tag name of this element.
 String jsxGet_text()
          Represents the text content of the node or the concatenated text representing the node and its descendants.
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.host.EventNode
jsxFunction_fireEvent, jsxGet_onblur, jsxGet_onclick, jsxGet_oncontextmenu, jsxGet_ondblclick, jsxGet_onerror, jsxGet_onfocus, jsxGet_onfocusin, jsxGet_onfocusout, jsxGet_onkeydown, jsxGet_onkeypress, jsxGet_onkeyup, jsxGet_onmousedown, jsxGet_onmousemove, jsxGet_onmouseout, jsxGet_onmouseover, jsxGet_onmouseup, jsxGet_onpropertychange, jsxGet_onresize, jsxSet_onblur, jsxSet_onclick, jsxSet_oncontextmenu, jsxSet_ondblclick, jsxSet_onerror, jsxSet_onfocus, jsxSet_onfocusin, jsxSet_onfocusout, jsxSet_onkeydown, jsxSet_onkeypress, jsxSet_onkeyup, jsxSet_onmousedown, jsxSet_onmousemove, jsxSet_onmouseout, jsxSet_onmouseover, jsxSet_onmouseup, jsxSet_onpropertychange, jsxSet_onresize
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.host.Node
executeEvent, fireEvent, getEventHandler, getEventHandlerProp, getJavaScriptNode, getParent, hasEventHandlers, jsxFunction_addEventListener, jsxFunction_appendChild, jsxFunction_attachEvent, jsxFunction_cloneNode, jsxFunction_compareDocumentPosition, jsxFunction_detachEvent, jsxFunction_hasChildNodes, jsxFunction_insertBefore, jsxFunction_insertBefore, jsxFunction_isSameNode, jsxFunction_normalize, jsxFunction_removeChild, jsxFunction_removeEventListener, jsxFunction_replaceChild, jsxGet_childNodes, jsxGet_firstChild, jsxGet_lastChild, jsxGet_localName, jsxGet_namespaceURI, jsxGet_nextSibling, jsxGet_nodeName, jsxGet_nodeType, jsxGet_nodeValue, jsxGet_ownerDocument, jsxGet_parentNode, jsxGet_prefix, jsxGet_previousSibling, jsxGet_textContent, jsxGet_xml, jsxSet_nodeValue, jsxSet_textContent, setDomNode, setEventHandler, setEventHandlerProp
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
clone, defineFunctionProperties, defineProperty, equivalentValues, get, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getTransformerScriptableFor, getWindow, getWindow, getWithPreemption, hasInstance, initParentScope, makeScriptableFor, setCaseSensitive, setDomNode, setHtmlElement
 
Methods inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, clear, containsKey, containsValue, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, entrySet, get, 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, has, 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
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

Element

public Element()
Method Detail

jsxFunction_selectNodes

public HTMLCollection jsxFunction_selectNodes(String expression)
Applies the specified XPath expression to this node's context and returns the generated list of matching nodes.

Parameters:
expression - a string specifying an XPath expression
Returns:
list of the found elements

jsxFunction_selectSingleNode

public Object jsxFunction_selectSingleNode(String expression)
Applies the specified pattern-matching operation to this node's context and returns the first matching node.

Parameters:
expression - a string specifying an XPath expression
Returns:
the first node that matches the given pattern-matching operation If no nodes match the expression, returns a null value.

jsxGet_tagName

public final String jsxGet_tagName()
Returns the tag name of this element.

Returns:
the tag name

jsxGet_attributes

public Object jsxGet_attributes()
Returns the attributes of this XML element.

Returns:
the attributes of this XML element
See Also:
Gecko DOM Reference

createAttributesObject

protected NamedNodeMap createAttributesObject()
Creates the JS object for the property attributes. This object will the be cached.

Returns:
the JS object

jsxFunction_getAttribute

public Object jsxFunction_getAttribute(String attributeName,
                                       Integer flags)
Returns the value of the specified attribute.

Parameters:
attributeName - attribute name
flags - IE-specific flags (see the MSDN documentation for more info)
Returns:
the value of the specified attribute, null if the attribute is not defined
See Also:
MSDN Documentation, IE Bug Documentation

fixAttributeName

protected String fixAttributeName(String attributeName)
Allows subclasses to transform the attribute name before it gets used.

Parameters:
attributeName - the original attribute
Returns:
this implementation returns the original value

jsxFunction_setAttribute

public void jsxFunction_setAttribute(String name,
                                     String value)
Sets an attribute.

Parameters:
name - Name of the attribute to set
value - Value to set the attribute to

jsxFunction_getElementsByTagName

public Object jsxFunction_getElementsByTagName(String tagName)
Returns all the descendant elements with the specified tag name.

Parameters:
tagName - the name to search for
Returns:
all the descendant elements with the specified tag name

jsxFunction_getAttributeNode

public Object jsxFunction_getAttributeNode(String name)
Retrieves an attribute node by name.

Parameters:
name - the name of the attribute to retrieve
Returns:
the XMLAttr node with the specified name or null if there is no such attribute

jsxGet_text

public String jsxGet_text()
Represents the text content of the node or the concatenated text representing the node and its descendants.

Returns:
the text content of the node or the concatenated text representing the node and its descendants

jsxFunction_getElementsByTagNameNS

public Object jsxFunction_getElementsByTagNameNS(Object namespaceURI,
                                                 String localName)
Returns a list of elements with the given tag name belonging to the given namespace.

Parameters:
namespaceURI - the namespace URI of elements to look for
localName - is either the local name of elements to look for or the special value "*", which matches all elements.
Returns:
a live NodeList of found elements in the order they appear in the tree

jsxFunction_hasAttribute

public boolean jsxFunction_hasAttribute(String name)
Returns true when an attribute with a given name is specified on this element or has a default value. See also the DOM reference

Parameters:
name - the name of the attribute to look for
Returns:
true if an attribute with the given name is specified on this element or has a default value

getDomNodeOrDie

public DomElement getDomNodeOrDie()
Returns the DOM node that corresponds to this JavaScript object or throw an exception if one cannot be found.

Overrides:
getDomNodeOrDie in class SimpleScriptable
Returns:
the DOM node

jsxFunction_removeAttribute

public void jsxFunction_removeAttribute(String name)
Removes the specified attribute.

Parameters:
name - the name of the attribute to remove


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