Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## gnu.xml.dom
Class DomAttr

    java.lang.Object
      |
      +--gnu.xml.dom.DomNode
            |
            +--gnu.xml.dom.DomNsNode
                  |
                  +--gnu.xml.dom.DomAttr

All Implemented Interfaces:
  Attr, java.lang.Cloneable, DocumentEvent, EventTarget, Node, NodeList

public class DomAttr
extends DomNsNode
implements Attr

"Attr" implementation. In DOM, attributes cost quite a lot of memory because their values are complex structures rather than just simple strings. To reduce your costs, avoid having more than one child of an attribute; stick to a single Text node child, and ignore even that by using the attribute's "nodeValue" property.

As a bit of general advice, only look at attribute modification events through the DOMAttrModified event (sent to the associated element). Implementations are not guaranteed to report other events in the same order, so you're very likely to write nonportable code if you monitor events at the "children of Attr" level.

At this writing, not all attribute modifications will cause the DOMAttrModified event to be triggered ... only the ones using the string methods (setNodeValue, setValue, and Element.setAttribute) to modify those values. That is, if you manipulate those children directly, elements won't get notified that attribute values have changed. The natural fix for that will report other modifications, but won't be able to expose "previous" attribute value; it'll need to be cached or something (at which point why bother using child nodes).

You are strongly advised not to use "children" of any attribute nodes you work with.

Version:
  $Date: 2001/11/20 04:53:46 $
Author:
  David Brownell

Fields inherited from interface org.w3c.dom.Node
`ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE`

Constructor Summary
`protected` | `DomAttr(Document owner, java.lang.String namespaceURI, java.lang.String name)` Constructs an Attr node associated with the specified document.

Method Summary
`java.lang.Object` | `clone()` Shallow clone of the attribute, breaking all ties with any elements.
`java.lang.String` | `getName()` DOM L1 Returns the attribute name (same as getNodeName)
`short` | `getNodeType()` DOM L1 Returns the constant ATTRIBUTE_NODE.
`java.lang.String` | `getNodeValue()` DOM L1 Returns the attribute value, with character and entity references substituted.
`Element` | `getOwnerElement()` DOM L2 Returns the element with which this attribute is associated.
`boolean` | `getSpecified()` DOM L1 Returns true if a parser reported this was in the source text.
`java.lang.String` | `getValue()` DOM L1 Returns the value of the attribute as a non-null string; same as getNodeValue.
`void` | `setNodeValue(java.lang.String value)` DOM L1 Assigns the attribute value; using this API, no entity or character references will exist.
`void` | `setOwnerElement(Element e)` Records the element with which this attribute is associated.
`void` | `setSpecified(boolean value)` Records whether this attribute was in the source text.
`void` | `setValue(java.lang.String value)` DOM L1 Assigns the value of the attribute; it will have one child, which is a text node with the specified value (same as setNodeValue).

Methods inherited from class gnu.xml.dom.DomNsNode
`getLocalName, getNamespaceURI, getNodeName, getPrefix, setPrefix`

Methods inherited from class gnu.xml.dom.DomNode
`addEventListener, appendChild, cloneNode, compact, createEvent, dispatchEvent, getAttributes, getChildNodes, getElementsByTagName, getElementsByTagNameNS, getFirstChild, getLastChild, getLength, getNextSibling, getOwnerDocument, getParentNode, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isReadonly, isSupported, item, makeReadonly, nameAndTypeEquals, normalize, removeChild, removeEventListener, replaceChild, trimToSize`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.w3c.dom.Node
`appendChild, cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setPrefix`

Constructor Detail

### DomAttr

    protected DomAttr(Document owner,
                      java.lang.String namespaceURI,
                      java.lang.String name)

  Constructs an Attr node associated with the specified document. The "specified" flag is initialized to true, since this DOM has no current "back door" mechanisms to manage default values so that every value must effectively be "specified".

  This constructor should only be invoked by a Document as part of its createAttribute functionality, or through a subclass which is similarly used in a "Sub-DOM" style layer.

  Parameters:
    `owner` - The document with which this node is associated
    `namespaceURI` - Combined with the local part of the name, this is used to uniquely identify a type of attribute
    `name` - Name of this attribute, which may include a prefix

Method Detail

### getName

    public final java.lang.String getName()

  DOM L1 Returns the attribute name (same as getNodeName)
  Specified by:
    `getName` in interface `Attr`

### getNodeType

    public final short getNodeType()

  DOM L1 Returns the constant ATTRIBUTE_NODE.
  Specified by:
    `getNodeType` in interface `Node`

### getSpecified

    public final boolean getSpecified()

  DOM L1 Returns true if a parser reported this was in the source text.
  Specified by:
    `getSpecified` in interface `Attr`

### setSpecified

    public final void setSpecified(boolean value)

  Records whether this attribute was in the source text.

### getNodeValue

    public java.lang.String getNodeValue()

  DOM L1 Returns the attribute value, with character and entity references substituted. NOTE: entity refs as children aren't currently handled.
  Specified by:
    `getNodeValue` in interface `Node`
  Overrides:
    `getNodeValue` in class `DomNode`
  Following copied from interface: `org.w3c.dom.Node`
  Throws:
    `DOMException` - NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
    `DOMException` - DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a `DOMString` variable on the implementation platform.

### setValue

    public final void setValue(java.lang.String value)

  DOM L1 Assigns the value of the attribute; it will have one child, which is a text node with the specified value (same as setNodeValue).
  Specified by:
    `setValue` in interface `Attr`
  Following copied from interface: `org.w3c.dom.Attr`
  Throws:
    `DOMException` - NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.

### getValue

    public final java.lang.String getValue()

  DOM L1 Returns the value of the attribute as a non-null string; same as getNodeValue. NOTE: entity refs as children aren't currently handled.
  Specified by:
    `getValue` in interface `Attr`
  Following copied from interface: `org.w3c.dom.Attr`
  Throws:
    `DOMException` - NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.

### setNodeValue

    public void setNodeValue(java.lang.String value)

  DOM L1 Assigns the attribute value; using this API, no entity or character references will exist. Causes a DOMAttrModified mutation event to be sent.
  Specified by:
    `setNodeValue` in interface `Node`
  Overrides:
    `setNodeValue` in class `DomNode`
  Following copied from interface: `org.w3c.dom.Node`
  Throws:
    `DOMException` - NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
    `DOMException` - DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a `DOMString` variable on the implementation platform.

### getOwnerElement

    public final Element getOwnerElement()

  DOM L2 Returns the element with which this attribute is associated.
  Specified by:
    `getOwnerElement` in interface `Attr`

### setOwnerElement

    public final void setOwnerElement(Element e)

  Records the element with which this attribute is associated.

### clone

    public java.lang.Object clone()

  Shallow clone of the attribute, breaking all ties with any elements.
  Overrides:
    `clone` in class `DomNode`

Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Source code is under GPL (with library exception) in the JAXP project at http://www.gnu.org/software/classpathx/jaxp
This documentation was derived from that source code on 2001-11-20.