Save This Page
Home » Xerces-J-src.2.9.1 » org.apache.xerces » dom » [javadoc | source]
org.apache.xerces.dom
public class: ElementImpl [javadoc | source]
java.lang.Object
   org.apache.xerces.dom.NodeImpl
      org.apache.xerces.dom.ChildNode
         org.apache.xerces.dom.ParentNode
            org.apache.xerces.dom.ElementImpl

All Implemented Interfaces:
    TypeInfo, Element, Cloneable, Node, EventTarget, Serializable, NodeList

Direct Known Subclasses:
    WMLRefreshElementImpl, WMLTemplateElementImpl, WMLMetaElementImpl, WMLTdElementImpl, HTMLOListElementImpl, WMLSetvarElementImpl, HTMLLinkElementImpl, HTMLAreaElementImpl, HTMLPreElementImpl, HTMLMapElementImpl, HTMLFormElementImpl, HTMLTableSectionElementImpl, WMLEmElementImpl, WMLOneventElementImpl, HTMLLegendElementImpl, HTMLFontElementImpl, WMLCardElementImpl, HTMLDivElementImpl, HTMLAppletElementImpl, WMLSmallElementImpl, WMLBigElementImpl, HTMLQuoteElementImpl, WMLHeadElementImpl, WMLStrongElementImpl, HTMLImageElementImpl, WMLAccessElementImpl, HTMLHRElementImpl, HTMLAnchorElementImpl, HTMLLabelElementImpl, HTMLSelectElementImpl, WMLAnchorElementImpl, WMLPElementImpl, WMLUElementImpl, WMLSelectElementImpl, WMLOptgroupElementImpl, HTMLParamElementImpl, WMLOptionElementImpl, WMLTrElementImpl, HTMLObjectElementImpl, HTMLIFrameElementImpl, HTMLStyleElementImpl, HTMLDListElementImpl, HTMLDirectoryElementImpl, WMLTableElementImpl, WMLWmlElementImpl, DeferredElementImpl, HTMLScriptElementImpl, HTMLTableRowElementImpl, WMLTimerElementImpl, WMLDoElementImpl, HTMLMenuElementImpl, WMLImgElementImpl, DeferredElementNSImpl, HTMLTableCellElementImpl, HTMLLIElementImpl, WMLBElementImpl, HTMLIsIndexElementImpl, HTMLBRElementImpl, HTMLFieldSetElementImpl, HTMLMetaElementImpl, HTMLModElementImpl, WMLPostfieldElementImpl, WMLIElementImpl, HTMLHeadElementImpl, HTMLInputElementImpl, HTMLElementImpl, WMLInputElementImpl, HTMLFrameElementImpl, WMLFieldsetElementImpl, PSVIElementNSImpl, WMLNoopElementImpl, HTMLTextAreaElementImpl, HTMLHeadingElementImpl, HTMLBodyElementImpl, HTMLHtmlElementImpl, HTMLBaseElementImpl, HTMLTableColElementImpl, WMLElementImpl, HTMLOptGroupElementImpl, HTMLParagraphElementImpl, HTMLFrameSetElementImpl, WMLAElementImpl, HTMLBaseFontElementImpl, WMLPrevElementImpl, WMLGoElementImpl, HTMLUListElementImpl, WMLBrElementImpl, HTMLButtonElementImpl, HTMLTableCaptionElementImpl, ElementNSImpl, HTMLTableElementImpl, HTMLOptionElementImpl, HTMLTitleElementImpl

Elements represent most of the "markup" and structure of the document. They contain both the data for the element itself (element name and attributes), and any contained nodes, including document text (as children).

Elements may have Attributes associated with them; the API for this is defined in Node, but the function is implemented here. In general, XML applications should retrive Attributes as Nodes, since they may contain entity references and hence be a fairly complex sub-tree. HTML users will be dealing with simple string values, and convenience methods are provided to work in terms of Strings.

ElementImpl does not support Namespaces. ElementNSImpl, which inherits from it, does.

Field Summary
static final  long serialVersionUID    Serialization version. 
protected  String name    Element name. 
protected  AttributeMap attributes    Attributes. 
Fields inherited from org.apache.xerces.dom.ParentNode:
serialVersionUID,  ownerDocument,  firstChild,  fNodeListCache
Fields inherited from org.apache.xerces.dom.ChildNode:
serialVersionUID,  previousSibling,  nextSibling
Fields inherited from org.apache.xerces.dom.NodeImpl:
TREE_POSITION_PRECEDING,  TREE_POSITION_FOLLOWING,  TREE_POSITION_ANCESTOR,  TREE_POSITION_DESCENDANT,  TREE_POSITION_EQUIVALENT,  TREE_POSITION_SAME_NODE,  TREE_POSITION_DISCONNECTED,  DOCUMENT_POSITION_DISCONNECTED,  DOCUMENT_POSITION_PRECEDING,  DOCUMENT_POSITION_FOLLOWING,  DOCUMENT_POSITION_CONTAINS,  DOCUMENT_POSITION_IS_CONTAINED,  DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC,  serialVersionUID,  ELEMENT_DEFINITION_NODE,  ownerNode,  flags,  READONLY,  SYNCDATA,  SYNCCHILDREN,  OWNED,  FIRSTCHILD,  SPECIFIED,  IGNORABLEWS,  HASSTRING,  NORMALIZED,  ID
Constructor:
 protected ElementImpl() 
 public ElementImpl(CoreDocumentImpl ownerDoc,
    String name) 
    Factory constructor.
Method from org.apache.xerces.dom.ElementImpl Summary:
cloneNode,   getAttribute,   getAttributeNS,   getAttributeNode,   getAttributeNodeNS,   getAttributes,   getBaseURI,   getDefaultAttributes,   getElementsByTagName,   getElementsByTagNameNS,   getNodeName,   getNodeType,   getSchemaTypeInfo,   getTagName,   getTypeName,   getTypeNamespace,   getXercesAttribute,   hasAttribute,   hasAttributeNS,   hasAttributes,   isDerivedFrom,   isEqualNode,   moveSpecifiedAttributes,   normalize,   reconcileDefaultAttributes,   removeAttribute,   removeAttributeNS,   removeAttributeNode,   rename,   setAttribute,   setAttributeNS,   setAttributeNode,   setAttributeNodeNS,   setIdAttribute,   setIdAttributeNS,   setIdAttributeNode,   setOwnerDocument,   setReadOnly,   setXercesAttributeNode,   setupDefaultAttributes,   synchronizeData
Methods from org.apache.xerces.dom.ParentNode:
checkNormalizationAfterInsert,   checkNormalizationAfterRemove,   cloneNode,   getChildNodes,   getChildNodesUnoptimized,   getFirstChild,   getLastChild,   getLength,   getOwnerDocument,   getTextContent,   getTextContent,   hasChildNodes,   hasTextContent,   insertBefore,   internalInsertBefore,   internalRemoveChild,   isEqualNode,   item,   lastChild,   lastChild,   normalize,   ownerDocument,   removeChild,   replaceChild,   setOwnerDocument,   setReadOnly,   setTextContent,   synchronizeChildren
Methods from org.apache.xerces.dom.ChildNode:
cloneNode,   getNextSibling,   getParentNode,   getPreviousSibling,   parentNode,   previousSibling
Methods from org.apache.xerces.dom.NodeImpl:
addEventListener,   appendChild,   changed,   changes,   cloneNode,   compareDocumentPosition,   compareTreePosition,   dispatchEvent,   getAttributes,   getBaseURI,   getChildNodes,   getContainer,   getElementAncestor,   getFeature,   getFirstChild,   getLastChild,   getLength,   getLocalName,   getNamespaceURI,   getNextSibling,   getNodeName,   getNodeNumber,   getNodeType,   getNodeValue,   getOwnerDocument,   getParentNode,   getPrefix,   getPreviousSibling,   getReadOnly,   getTextContent,   getTextContent,   getUserData,   getUserData,   getUserDataRecord,   hasAttributes,   hasChildNodes,   hasStringValue,   hasStringValue,   insertBefore,   internalIsIgnorableWhitespace,   isDefaultNamespace,   isEqualNode,   isFirstChild,   isFirstChild,   isIdAttribute,   isIdAttribute,   isIgnorableWhitespace,   isNormalized,   isNormalized,   isOwned,   isOwned,   isReadOnly,   isReadOnly,   isSameNode,   isSpecified,   isSpecified,   isSupported,   item,   lookupNamespacePrefix,   lookupNamespaceURI,   lookupPrefix,   needsSyncChildren,   needsSyncChildren,   needsSyncData,   needsSyncData,   normalize,   ownerDocument,   parentNode,   previousSibling,   removeChild,   removeEventListener,   replaceChild,   setNodeValue,   setOwnerDocument,   setPrefix,   setReadOnly,   setTextContent,   setUserData,   setUserData,   synchronizeData,   toString
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.xerces.dom.ElementImpl Detail:
 public Node cloneNode(boolean deep) 
    Return a duplicate copy of this Element. Note that its children will not be copied unless the "deep" flag is true, but Attributes are always replicated.
 public String getAttribute(String name) 
    Look up a single Attribute by name. Returns the Attribute's string value, or an empty string (NOT null!) to indicate that the name did not map to a currently defined attribute.

    Note: Attributes may contain complex node trees. This method returns the "flattened" string obtained from Attribute.getValue(). If you need the structure information, see getAttributeNode().

 public String getAttributeNS(String namespaceURI,
    String localName) 
    Introduced in DOM Level 2.

    Retrieves an attribute value by local name and namespace URI.

 public Attr getAttributeNode(String name) 
    Look up a single Attribute by name. Returns the Attribute Node, so its complete child tree is available. This could be important in XML, where the string rendering may not be sufficient information.

    If no matching attribute is available, returns null.

 public Attr getAttributeNodeNS(String namespaceURI,
    String localName) 
    Retrieves an Attr node by local name and namespace URI.
 public NamedNodeMap getAttributes() 
    Retrieve all the Attributes as a set. Note that this API is inherited from Node rather than specified on Element; in fact only Elements will ever have Attributes, but they want to allow folks to "blindly" operate on the tree as a set of Nodes.
 public String getBaseURI() 
    DOM Level 3 WD - Experimental. Retrieve baseURI
 protected NamedNodeMapImpl getDefaultAttributes() 
    Get the default attributes.
 public NodeList getElementsByTagName(String tagname) 
    Returns a NodeList of all descendent nodes (children, grandchildren, and so on) which are Elements and which have the specified tag name.

    Note: NodeList is a "live" view of the DOM. Its contents will change as the DOM changes, and alterations made to the NodeList will be reflected in the DOM.

 public NodeList getElementsByTagNameNS(String namespaceURI,
    String localName) 
    Introduced in DOM Level 2.

    Returns a NodeList of all the Elements with a given local name and namespace URI in the order in which they would be encountered in a preorder traversal of the Document tree, starting from this node.

 public String getNodeName() 
    Returns the element name
 public short getNodeType() 
    A short integer indicating what type of node this is. The named constants for this value are defined in the org.w3c.dom.Node interface.
 public TypeInfo getSchemaTypeInfo() 
    Method getSchemaTypeInfo.
 public String getTagName() 
    Returns the name of the Element. Note that Element.nodeName() is defined to also return the tag name.

    This is case-preserving in XML. HTML should uppercasify it on the way in.

 public String getTypeName() 
 public String getTypeNamespace() 
 protected int getXercesAttribute(String namespaceURI,
    String localName) 
    NON-DOM: get inded of an attribute
 public boolean hasAttribute(String name) 
    Introduced in DOM Level 2.
 public boolean hasAttributeNS(String namespaceURI,
    String localName) 
    Introduced in DOM Level 2.
 public boolean hasAttributes() 
    Introduced in DOM Level 2.
 public boolean isDerivedFrom(String typeNamespaceArg,
    String typeNameArg,
    int derivationMethod) 
    Introduced in DOM Level 3.

    Checks if a type is derived from another by restriction. See: http://www.w3.org/TR/DOM-Level-3-Core/core.html#TypeInfo-isDerivedFrom

 public boolean isEqualNode(Node arg) 
    DOM Level 3 WD- Experimental. Override inherited behavior from NodeImpl and ParentNode to check on attributes
  void moveSpecifiedAttributes(ElementImpl el) 
 public  void normalize() 
    In "normal form" (as read from a source file), there will never be two Text children in succession. But DOM users may create successive Text nodes in the course of manipulating the document. Normalize walks the sub-tree and merges adjacent Texts, as if the DOM had been written out and read back in again. This simplifies implementation of higher-level functions that may want to assume that the document is in standard form.

    To normalize a Document, normalize its top-level Element child.

    As of PR-DOM-Level-1-19980818, CDATA -- despite being a subclass of Text -- is considered "markup" and will _not_ be merged either with normal Text or with other CDATASections.

 protected  void reconcileDefaultAttributes() 
    Reconcile default attributes.
 public  void removeAttribute(String name) 
    Remove the named attribute from this Element. If the removed Attribute has a default value, it is immediately replaced thereby.

    The default logic is actually implemented in NamedNodeMapImpl. PR-DOM-Level-1-19980818 doesn't fully address the DTD, so some of this behavior is likely to change in future versions. ?????

    Note that this call "succeeds" even if no attribute by this name existed -- unlike removeAttributeNode, which will throw a not-found exception in that case.

 public  void removeAttributeNS(String namespaceURI,
    String localName) 
    Introduced in DOM Level 2.

    Removes an attribute by local name and namespace URI. If the removed attribute has a default value it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix.

 public Attr removeAttributeNode(Attr oldAttr) throws DOMException 
    Remove the specified attribute/value pair. If the removed Attribute has a default value, it is immediately replaced.

    NOTE: Specifically removes THIS NODE -- not the node with this name, nor the node with these contents. If the specific Attribute object passed in is not stored in this Element, we throw a DOMException. If you really want to remove an attribute by name, use removeAttribute().

  void rename(String name) 
 public  void setAttribute(String name,
    String value) 
    Add a new name/value pair, or replace the value of the existing attribute having that name. Note: this method supports only the simplest kind of Attribute, one whose value is a string contained in a single Text node. If you want to assert a more complex value (which XML permits, though HTML doesn't), see setAttributeNode(). The attribute is created with specified=true, meaning it's an explicit value rather than inherited from the DTD as a default. Again, setAttributeNode can be used to achieve other results.
 public  void setAttributeNS(String namespaceURI,
    String qualifiedName,
    String value) 
    Introduced in DOM Level 2.

    Adds a new attribute. If the given namespaceURI is null or an empty string and the qualifiedName has a prefix that is "xml", the new attribute is bound to the predefined namespace "http://www.w3.org/XML/1998/namespace" [Namespaces]. If an attribute with the same local name and namespace URI is already present on the element, its prefix is changed to be the prefix part of the qualifiedName, and its value is changed to be the value parameter. This value is a simple string, it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNodeNS or setAttributeNode to assign it as the value of an attribute.

 public Attr setAttributeNode(Attr newAttr) throws DOMException 
    Add a new attribute/value pair, or replace the value of the existing attribute with that name.

    This method allows you to add an Attribute that has already been constructed, and hence avoids the limitations of the simple setAttribute() call. It can handle attribute values that have arbitrarily complex tree structure -- in particular, those which had entity references mixed into their text.

 public Attr setAttributeNodeNS(Attr newAttr) throws DOMException 
    Introduced in DOM Level 2.

    Adds a new attribute. If an attribute with that local name and namespace URI is already present in the element, it is replaced by the new one.

 public  void setIdAttribute(String name,
    boolean makeId) 
    DOM Level 3: register the given attribute node as an ID attribute
 public  void setIdAttributeNS(String namespaceURI,
    String localName,
    boolean makeId) 
    DOM Level 3: register the given attribute node as an ID attribute
 public  void setIdAttributeNode(Attr at,
    boolean makeId) 
    DOM Level 3: register the given attribute node as an ID attribute
 protected  void setOwnerDocument(CoreDocumentImpl doc) 
    NON-DOM set the ownerDocument of this node, its children, and its attributes
 public  void setReadOnly(boolean readOnly,
    boolean deep) 
    NON-DOM: Subclassed to flip the attributes' readonly switch as well.
 protected int setXercesAttributeNode(Attr attr) 
    NON-DOM: sets attribute node for this element
 protected  void setupDefaultAttributes() 
    Setup the default attributes.
 protected  void synchronizeData() 
    Synchronizes the data (name and value) for fast nodes.