com.gargoylesoftware.htmlunit.html
Class DomElement

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.html.DomNode
      extended by com.gargoylesoftware.htmlunit.html.DomNamespaceNode
          extended by com.gargoylesoftware.htmlunit.html.DomElement
All Implemented Interfaces:
Serializable, Cloneable, Element, Node
Direct Known Subclasses:
HtmlElement

public class DomElement
extends DomNamespaceNode
implements Element

Version:
$Revision: 5628 $
Author:
Ahmed Ashour, Marc Guillemot, Tom Anderson
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.gargoylesoftware.htmlunit.html.DomNode
DomNode.ChildIterator, DomNode.DescendantElementsIterator<T extends DomNode>
 
Field Summary
static String ATTRIBUTE_NOT_DEFINED
          Constant meaning that the specified attribute was not defined.
static String ATTRIBUTE_VALUE_EMPTY
          Constant meaning that the specified attribute was found but its value was empty.
 
Fields inherited from class com.gargoylesoftware.htmlunit.html.DomNode
AS_TEXT_BLANK, AS_TEXT_BLOCK_SEPARATOR, AS_TEXT_NEW_LINE, AS_TEXT_TAB, PROPERTY_ELEMENT, READY_STATE_COMPLETE, READY_STATE_INTERACTIVE, READY_STATE_LOADED, READY_STATE_LOADING, READY_STATE_UNINITIALIZED
 
Fields inherited from interface org.w3c.dom.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
 
Constructor Summary
DomElement(String namespaceURI, String qualifiedName, SgmlPage page, Map<String,DomAttr> attributes)
          Creates an instance of a DOM element that can have a namespace.
 
Method Summary
 DomNode cloneNode(boolean deep)
          
 String getAttribute(String attributeName)
          Returns the value of the attribute specified by name or an empty string.
 DomAttr getAttributeNode(String name)
          
 DomAttr getAttributeNodeNS(String namespaceURI, String localName)
          
 String getAttributeNS(String namespaceURI, String localName)
          Returns the value of the attribute specified by namespace and local name or an empty string.
 NamedNodeMap getAttributes()
          
 Map<String,DomAttr> getAttributesMap()
          Returns the map holding the attributes, keyed by name.
 DomNodeList<HtmlElement> getElementsByTagName(String tagName)
          
 DomNodeList<HtmlElement> getElementsByTagNameNS(String namespace, String localName)
           Not yet implemented.
 String getNodeName()
          Returns this node's node name.
 short getNodeType()
          Returns this node's node type.
 TypeInfo getSchemaTypeInfo()
           Not yet implemented.
 String getTagName()
          Returns the tag name of this element.
 boolean hasAttribute(String attributeName)
          Returns whether the attribute specified by name has a value.
 boolean hasAttributeNS(String namespaceURI, String localName)
          Returns whether the attribute specified by namespace and local name has a value.
 boolean hasAttributes()
          
protected  boolean isAttributeCaseSensitive()
          Indicates if the attribute names are case sensitive.
protected  boolean isEmptyXmlTagExpanded()
          Indicates if a node without children should be written in expanded form as XML (i.e.
protected  Map<String,String> namespaces()
          Returns namespaces.
protected  void printOpeningTagContentAsXml(PrintWriter printWriter)
          Prints the content between "<" and ">" (or "/>") in the output of the tag name and its attributes in XML format.
protected  void printXml(String indent, PrintWriter printWriter)
          Recursively write the XML data for the node tree starting at node.
 void removeAttribute(String attributeName)
          Removes an attribute specified by name from this element.
 Attr removeAttributeNode(Attr attribute)
           Not yet implemented.
 void removeAttributeNS(String namespaceURI, String localName)
          Removes an attribute specified by namespace and local name from this element.
 void setAttribute(String attributeName, String attributeValue)
          Sets the value of the attribute specified by name.
 Attr setAttributeNode(Attr attribute)
          
 Attr setAttributeNodeNS(Attr attribute)
           Not yet implemented.
 void setAttributeNS(String namespaceURI, String qualifiedName, String attributeValue)
          Sets the value of the attribute specified by namespace and qualified name.
 void setIdAttribute(String name, boolean isId)
           Not yet implemented.
 void setIdAttributeNode(Attr idAttr, boolean isId)
           Not yet implemented.
 void setIdAttributeNS(String namespaceURI, String localName, boolean isId)
           Not yet implemented.
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.DomNamespaceNode
getLocalName, getNamespaceURI, getPrefix, getQualifiedName, setPrefix
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.DomNode
addDomChangeListener, appendChild, asText, asXml, checkChildHierarchy, compareDocumentPosition, fireNodeAdded, fireNodeDeleted, getAllHtmlChildElements, getAncestors, getBaseURI, getByXPath, getCanonicalXPath, getChildNodes, getChildren, getDescendants, getEndColumnNumber, getEndLineNumber, getFeature, getFirstByXPath, getFirstChild, getHtmlElementDescendants, getIndex, getLastChild, getNextSibling, getNodeValue, getOwnerDocument, getPage, getParentNode, getPreviousSibling, getReadyState, getScriptObject, getStartColumnNumber, getStartLineNumber, getTextContent, getUserData, hasChildNodes, insertBefore, insertBefore, isAncestorOf, isAncestorOfAny, isBlock, isDefaultNamespace, isDisplayed, isEqualNode, isSameNode, isSupported, isTrimmedText, lookupNamespaceURI, lookupPrefix, mayBeDisplayed, normalize, notifyIncorrectness, onAddedToPage, onAllChildrenAddedToPage, printChildrenAsXml, remove, removeAllChildren, removeChild, removeDomChangeListener, replace, replaceChild, setNextSibling, setNodeValue, setParentNode, setPreviousSibling, setReadyState, setScriptObject, setTextContent, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, compareDocumentPosition, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
 

Field Detail

ATTRIBUTE_NOT_DEFINED

public static final String ATTRIBUTE_NOT_DEFINED
Constant meaning that the specified attribute was not defined.


ATTRIBUTE_VALUE_EMPTY

public static final String ATTRIBUTE_VALUE_EMPTY
Constant meaning that the specified attribute was found but its value was empty.

Constructor Detail

DomElement

public DomElement(String namespaceURI,
                  String qualifiedName,
                  SgmlPage page,
                  Map<String,DomAttr> attributes)
Creates an instance of a DOM element that can have a namespace.

Parameters:
namespaceURI - the URI that identifies an XML namespace
qualifiedName - the qualified name of the element type to instantiate
page - the page that contains this element
attributes - a map ready initialized with the attributes for this element, or null. The map will be stored as is, not copied.
Method Detail

getNodeName

public String getNodeName()
Returns this node's node name.

Specified by:
getNodeName in interface Node
Specified by:
getNodeName in class DomNode
Returns:
this node's node name

getNodeType

public final short getNodeType()
Returns this node's node type.

Specified by:
getNodeType in interface Node
Specified by:
getNodeType in class DomNode
Returns:
this node's node type

namespaces

protected Map<String,String> namespaces()
Returns namespaces.

Returns:
namespaces

getTagName

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

Specified by:
getTagName in interface Element
Returns:
the tag name of this element

hasAttributes

public final boolean hasAttributes()

Specified by:
hasAttributes in interface Node
Overrides:
hasAttributes in class DomNode

hasAttribute

public boolean hasAttribute(String attributeName)
Returns whether the attribute specified by name has a value.

Specified by:
hasAttribute in interface Element
Parameters:
attributeName - the name of the attribute
Returns:
true if an attribute with the given name is specified on this element or has a default value, false otherwise.

printOpeningTagContentAsXml

protected void printOpeningTagContentAsXml(PrintWriter printWriter)
Prints the content between "<" and ">" (or "/>") in the output of the tag name and its attributes in XML format.

Parameters:
printWriter - the writer to print in

printXml

protected void printXml(String indent,
                        PrintWriter printWriter)
Recursively write the XML data for the node tree starting at node.

Overrides:
printXml in class DomNode
Parameters:
indent - white space to indent child nodes
printWriter - writer where child nodes are written

isEmptyXmlTagExpanded

protected boolean isEmptyXmlTagExpanded()
Indicates if a node without children should be written in expanded form as XML (i.e. with closing tag rather than with "/>")

Returns:
false by default

getAttribute

public String getAttribute(String attributeName)
Returns the value of the attribute specified by name or an empty string. If the result is an empty string then it will be either ATTRIBUTE_NOT_DEFINED if the attribute wasn't specified or ATTRIBUTE_VALUE_EMPTY if the attribute was specified but it was empty.

Specified by:
getAttribute in interface Element
Parameters:
attributeName - the name of the attribute
Returns:
the value of the attribute or ATTRIBUTE_NOT_DEFINED or ATTRIBUTE_VALUE_EMPTY

removeAttribute

public void removeAttribute(String attributeName)
Removes an attribute specified by name from this element.

Specified by:
removeAttribute in interface Element
Parameters:
attributeName - the attribute attributeName

removeAttributeNS

public final void removeAttributeNS(String namespaceURI,
                                    String localName)
Removes an attribute specified by namespace and local name from this element.

Specified by:
removeAttributeNS in interface Element
Parameters:
namespaceURI - the URI that identifies an XML namespace
localName - the name within the namespace

removeAttributeNode

public final Attr removeAttributeNode(Attr attribute)
Not yet implemented.

Specified by:
removeAttributeNode in interface Element

hasAttributeNS

public final boolean hasAttributeNS(String namespaceURI,
                                    String localName)
Returns whether the attribute specified by namespace and local name has a value.

Specified by:
hasAttributeNS in interface Element
Parameters:
namespaceURI - the URI that identifies an XML namespace
localName - the name within the namespace
Returns:
true if an attribute with the given name is specified on this element or has a default value, false otherwise.

getAttributesMap

public final Map<String,DomAttr> getAttributesMap()
Returns the map holding the attributes, keyed by name.

Returns:
the attributes map

getAttributes

public NamedNodeMap getAttributes()

Specified by:
getAttributes in interface Node
Overrides:
getAttributes in class DomNode

setAttribute

public final void setAttribute(String attributeName,
                               String attributeValue)
Sets the value of the attribute specified by name.

Specified by:
setAttribute in interface Element
Parameters:
attributeName - the name of the attribute
attributeValue - the value of the attribute

setAttributeNS

public void setAttributeNS(String namespaceURI,
                           String qualifiedName,
                           String attributeValue)
Sets the value of the attribute specified by namespace and qualified name.

Specified by:
setAttributeNS in interface Element
Parameters:
namespaceURI - the URI that identifies an XML namespace
qualifiedName - the qualified name (prefix:local) of the attribute
attributeValue - the value of the attribute

isAttributeCaseSensitive

protected boolean isAttributeCaseSensitive()
Indicates if the attribute names are case sensitive.

Returns:
true

getAttributeNS

public final String getAttributeNS(String namespaceURI,
                                   String localName)
Returns the value of the attribute specified by namespace and local name or an empty string. If the result is an empty string then it will be either ATTRIBUTE_NOT_DEFINED if the attribute wasn't specified or ATTRIBUTE_VALUE_EMPTY if the attribute was specified but it was empty.

Specified by:
getAttributeNS in interface Element
Parameters:
namespaceURI - the URI that identifies an XML namespace
localName - the name within the namespace
Returns:
the value of the attribute or ATTRIBUTE_NOT_DEFINED or ATTRIBUTE_VALUE_EMPTY

getAttributeNode

public DomAttr getAttributeNode(String name)

Specified by:
getAttributeNode in interface Element

getAttributeNodeNS

public DomAttr getAttributeNodeNS(String namespaceURI,
                                  String localName)

Specified by:
getAttributeNodeNS in interface Element

getElementsByTagName

public DomNodeList<HtmlElement> getElementsByTagName(String tagName)

Specified by:
getElementsByTagName in interface Element

getElementsByTagNameNS

public DomNodeList<HtmlElement> getElementsByTagNameNS(String namespace,
                                                       String localName)
Not yet implemented.

Specified by:
getElementsByTagNameNS in interface Element

getSchemaTypeInfo

public TypeInfo getSchemaTypeInfo()
Not yet implemented.

Specified by:
getSchemaTypeInfo in interface Element

setIdAttribute

public void setIdAttribute(String name,
                           boolean isId)
Not yet implemented.

Specified by:
setIdAttribute in interface Element

setIdAttributeNS

public void setIdAttributeNS(String namespaceURI,
                             String localName,
                             boolean isId)
Not yet implemented.

Specified by:
setIdAttributeNS in interface Element

setAttributeNode

public Attr setAttributeNode(Attr attribute)

Specified by:
setAttributeNode in interface Element

setAttributeNodeNS

public Attr setAttributeNodeNS(Attr attribute)
Not yet implemented.

Specified by:
setAttributeNodeNS in interface Element

setIdAttributeNode

public final void setIdAttributeNode(Attr idAttr,
                                     boolean isId)
Not yet implemented.

Specified by:
setIdAttributeNode in interface Element

cloneNode

public DomNode cloneNode(boolean deep)

Specified by:
cloneNode in interface Node
Overrides:
cloneNode in class DomNode


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