gnu.xml.dom
Class DomAttr
- Attr, DocumentEvent, EventTarget, Node, NodeList, Cloneable, Comparable
"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.
addEventListener , appendChild , clone , cloneNode , compact , compareDocumentPosition , compareTo , createEvent , dispatchEvent , getAttributes , getBaseURI , getChildNodes , getElementsByTagName , getElementsByTagNameNS , getFeature , getFirstChild , getLastChild , getLength , getLocalName , getNamespaceURI , getNextSibling , getNodeName , getNodeType , getNodeValue , getOwnerDocument , getParentNode , getPrefix , getPreviousSibling , getTextContent , getUserData , hasAttributes , hasChildNodes , insertBefore , isDefaultNamespace , isEqualNode , isReadonly , isSameNode , isSupported , item , lookupNamespaceURI , lookupPrefix , makeReadonly , nameAndTypeEquals , normalize , removeChild , removeEventListener , replaceChild , setNodeValue , setPrefix , setTextContent , setUserData , toString , trimToSize |
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait |
DomAttr
protected DomAttr(DomDocument owner,
String namespaceURI,
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.
owner
- The document with which this node is associatednamespaceURI
- Combined with the local part of the name,
this is used to uniquely identify a type of attributename
- Name of this attribute, which may include a prefix
clone
public Object clone()
Shallow clone of the attribute, breaking all ties with any
elements.
- clone in interface DomNode
getName
public final String getName()
DOM L1
Returns the attribute name (same as getNodeName)
getNodeValue
public String getNodeValue()
DOM L1
Returns the attribute value, with character and entity
references substituted.
NOTE: entity refs as children aren't currently handled.
- getNodeValue in interface DomNode
getOwnerElement
public final Element getOwnerElement()
DOM L2
Returns the element with which this attribute is associated.
getSpecified
public final boolean getSpecified()
DOM L1
Returns true if a parser reported this was in the source text.
getValue
public final 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.
isId
public boolean isId()
setNodeValue
public void setNodeValue(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.
- setNodeValue in interface DomNode
setOwnerElement
public final void setOwnerElement(Element e)
Records the element with which this attribute is associated.
setSpecified
public final void setSpecified(boolean value)
Records whether this attribute was in the source text.
setValue
public final void setValue(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).
DomAttr.java --
Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.