ElementImplpublic class ElementImpl extends ParentNode implements Element, TypeInfoElements 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. |
Fields Summary |
---|
static final long | serialVersionUIDSerialization version. | protected String | nameElement name. | protected AttributeMap | attributesAttributes. |
Constructors Summary |
---|
public ElementImpl(CoreDocumentImpl ownerDoc, String name)Factory constructor.
//
// Constructors
//
super(ownerDoc);
this.name = name;
needsSyncData(true); // synchronizeData will initialize attributes
| protected ElementImpl()
|
Methods Summary |
---|
public org.w3c.dom.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.
ElementImpl newnode = (ElementImpl) super.cloneNode(deep);
// Replicate NamedNodeMap rather than sharing it.
if (attributes != null) {
newnode.attributes = (AttributeMap) attributes.cloneMap(newnode);
}
return newnode;
| public java.lang.String | getAttribute(java.lang.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().
if (needsSyncData()) {
synchronizeData();
}
if (attributes == null) {
return "";
}
Attr attr = (Attr)(attributes.getNamedItem(name));
return (attr == null) ? "" : attr.getValue();
| public java.lang.String | getAttributeNS(java.lang.String namespaceURI, java.lang.String localName)Introduced in DOM Level 2.
Retrieves an attribute value by local name and namespace URI.
if (needsSyncData()) {
synchronizeData();
}
if (attributes == null) {
return "";
}
Attr attr = (Attr)(attributes.getNamedItemNS(namespaceURI, localName));
return (attr == null) ? "" : attr.getValue();
| public org.w3c.dom.Attr | getAttributeNode(java.lang.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.
if (needsSyncData()) {
synchronizeData();
}
if (attributes == null) {
return null;
}
return (Attr)attributes.getNamedItem(name);
| public org.w3c.dom.Attr | getAttributeNodeNS(java.lang.String namespaceURI, java.lang.String localName)Retrieves an Attr node by local name and namespace URI.
if (needsSyncData()) {
synchronizeData();
}
if (attributes == null) {
return null;
}
return (Attr)attributes.getNamedItemNS(namespaceURI, localName);
| public org.w3c.dom.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.
if (needsSyncData()) {
synchronizeData();
}
if (attributes == null) {
attributes = new AttributeMap(this, null);
}
return attributes;
| public java.lang.String | getBaseURI()DOM Level 3 WD - Experimental.
Retrieve baseURI
if (needsSyncData()) {
synchronizeData();
}
// Absolute base URI is computed according to
// XML Base (http://www.w3.org/TR/xmlbase/#granularity)
// 1. The base URI specified by an xml:base attribute on the element,
// if one exists
if (attributes != null) {
Attr attrNode = (Attr)attributes.getNamedItem("xml:base");
if (attrNode != null) {
String uri = attrNode.getNodeValue();
if (uri.length() != 0 ) {// attribute value is always empty string
try {
uri = new URI(uri).toString();
}
catch (com.sun.org.apache.xerces.internal.util.URI.MalformedURIException e) {
// This may be a relative URI.
// Make any parentURI into a URI object to use with the URI(URI, String) constructor
String parentBaseURI = (this.ownerNode != null) ? this.ownerNode.getBaseURI() : null;
if (parentBaseURI != null){
try{
uri = new URI(new URI(parentBaseURI), uri).toString();
}
catch (com.sun.org.apache.xerces.internal.util.URI.MalformedURIException ex){
// This should never happen: parent should have checked the URI and returned null if invalid.
return null;
}
return uri;
}
return null;
}
return uri;
}
}
}
// 2.the base URI of the element's parent element within the
// document or external entity, if one exists
// 3. the base URI of the document entity or external entity
// containing the element
// ownerNode serves as a parent or as document
String baseURI = (this.ownerNode != null) ? this.ownerNode.getBaseURI() : null ;
//base URI of parent element is not null
if(baseURI != null){
try {
//return valid absolute base URI
return new URI(baseURI).toString();
}
catch (com.sun.org.apache.xerces.internal.util.URI.MalformedURIException e){
return null;
}
}
return null;
| protected com.sun.org.apache.xerces.internal.dom.NamedNodeMapImpl | getDefaultAttributes()Get the default attributes.
DocumentTypeImpl doctype =
(DocumentTypeImpl) ownerDocument.getDoctype();
if (doctype == null) {
return null;
}
ElementDefinitionImpl eldef =
(ElementDefinitionImpl)doctype.getElements()
.getNamedItem(getNodeName());
if (eldef == null) {
return null;
}
return (NamedNodeMapImpl) eldef.getAttributes();
| public org.w3c.dom.NodeList | getElementsByTagName(java.lang.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.
return new DeepNodeListImpl(this,tagname);
| public org.w3c.dom.NodeList | getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.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.
return new DeepNodeListImpl(this, namespaceURI, localName);
| public java.lang.String | getNodeName()Returns the element name
if (needsSyncData()) {
synchronizeData();
}
return 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.
return Node.ELEMENT_NODE;
| public org.w3c.dom.TypeInfo | getSchemaTypeInfo()Method getSchemaTypeInfo.
if(needsSyncData()) {
synchronizeData();
}
return this;
| public java.lang.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.
if (needsSyncData()) {
synchronizeData();
}
return name;
| public java.lang.String | getTypeName()
return null;
| public java.lang.String | getTypeNamespace()
return null;
| protected int | getXercesAttribute(java.lang.String namespaceURI, java.lang.String localName)NON-DOM: get inded of an attribute
if (needsSyncData()) {
synchronizeData();
}
if (attributes == null) {
return -1;
}
return attributes.getNamedItemIndex(namespaceURI, localName);
| public boolean | hasAttribute(java.lang.String name)Introduced in DOM Level 2.
return getAttributeNode(name) != null;
| public boolean | hasAttributeNS(java.lang.String namespaceURI, java.lang.String localName)Introduced in DOM Level 2.
return getAttributeNodeNS(namespaceURI, localName) != null;
| public boolean | hasAttributes()Introduced in DOM Level 2.
if (needsSyncData()) {
synchronizeData();
}
return (attributes != null && attributes.getLength() != 0);
| public boolean | isDerivedFrom(java.lang.String typeNamespaceArg, java.lang.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
return false;
| public boolean | isEqualNode(org.w3c.dom.Node arg)DOM Level 3 WD- Experimental.
Override inherited behavior from NodeImpl and ParentNode to check on
attributes
if (!super.isEqualNode(arg)) {
return false;
}
boolean hasAttrs = hasAttributes();
if (hasAttrs != ((Element) arg).hasAttributes()) {
return false;
}
if (hasAttrs) {
NamedNodeMap map1 = getAttributes();
NamedNodeMap map2 = ((Element) arg).getAttributes();
int len = map1.getLength();
if (len != map2.getLength()) {
return false;
}
for (int i = 0; i < len; i++) {
Node n1 = map1.item(i);
if (n1.getLocalName() == null) { // DOM Level 1 Node
Node n2 = map2.getNamedItem(n1.getNodeName());
if (n2 == null || !((NodeImpl) n1).isEqualNode(n2)) {
return false;
}
}
else {
Node n2 = map2.getNamedItemNS(n1.getNamespaceURI(),
n1.getLocalName());
if (n2 == null || !((NodeImpl) n1).isEqualNode(n2)) {
return false;
}
}
}
}
return true;
| void | moveSpecifiedAttributes(com.sun.org.apache.xerces.internal.dom.ElementImpl el)
if (needsSyncData()) {
synchronizeData();
}
if (el.hasAttributes()) {
if (attributes == null) {
attributes = new AttributeMap(this, null);
}
attributes.moveSpecifiedAttributes(el.attributes);
}
| 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.
// No need to normalize if already normalized.
if (isNormalized()) {
return;
}
if (needsSyncChildren()) {
synchronizeChildren();
}
ChildNode kid, next;
for (kid = firstChild; kid != null; kid = next) {
next = kid.nextSibling;
// If kid is a text node, we need to check for one of two
// conditions:
// 1) There is an adjacent text node
// 2) There is no adjacent text node, but kid is
// an empty text node.
if ( kid.getNodeType() == Node.TEXT_NODE )
{
// If an adjacent text node, merge it with kid
if ( next!=null && next.getNodeType() == Node.TEXT_NODE )
{
((Text)kid).appendData(next.getNodeValue());
removeChild( next );
next = kid; // Don't advance; there might be another.
}
else
{
// If kid is empty, remove it
if ( kid.getNodeValue() == null || kid.getNodeValue().length() == 0 ) {
removeChild( kid );
}
}
}
// Otherwise it might be an Element, which is handled recursively
else if (kid.getNodeType() == Node.ELEMENT_NODE) {
kid.normalize();
}
}
// We must also normalize all of the attributes
if ( attributes!=null )
{
for( int i=0; i<attributes.getLength(); ++i )
{
Node attr = attributes.item(i);
attr.normalize();
}
}
// changed() will have occurred when the removeChild() was done,
// so does not have to be reissued.
isNormalized(true);
| protected void | reconcileDefaultAttributes()Reconcile default attributes.
if (attributes != null) {
NamedNodeMapImpl defaults = getDefaultAttributes();
attributes.reconcileDefaults(defaults);
}
| public void | removeAttribute(java.lang.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.
if (ownerDocument.errorChecking && isReadOnly()) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
}
if (needsSyncData()) {
synchronizeData();
}
if (attributes == null) {
return;
}
attributes.safeRemoveNamedItem(name);
| public void | removeAttributeNS(java.lang.String namespaceURI, java.lang.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.
if (ownerDocument.errorChecking && isReadOnly()) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
}
if (needsSyncData()) {
synchronizeData();
}
if (attributes == null) {
return;
}
attributes.safeRemoveNamedItemNS(namespaceURI, localName);
| public org.w3c.dom.Attr | removeAttributeNode(org.w3c.dom.Attr oldAttr)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().
if (ownerDocument.errorChecking && isReadOnly()) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
}
if (needsSyncData()) {
synchronizeData();
}
if (attributes == null) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
}
return (Attr) attributes.removeItem(oldAttr, true);
| void | rename(java.lang.String name)
if (needsSyncData()) {
synchronizeData();
}
this.name = name;
reconcileDefaultAttributes();
| public void | setAttribute(java.lang.String name, java.lang.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.
if (ownerDocument.errorChecking && isReadOnly()) {
String msg =
DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
"NO_MODIFICATION_ALLOWED_ERR",
null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
}
if (needsSyncData()) {
synchronizeData();
}
Attr newAttr = getAttributeNode(name);
if (newAttr == null) {
newAttr = getOwnerDocument().createAttribute(name);
if (attributes == null) {
attributes = new AttributeMap(this, null);
}
newAttr.setNodeValue(value);
attributes.setNamedItem(newAttr);
}
else {
newAttr.setNodeValue(value);
}
| public void | setAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.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.
if (ownerDocument.errorChecking && isReadOnly()) {
String msg =
DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
"NO_MODIFICATION_ALLOWED_ERR",
null);
throw new DOMException(
DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
if (needsSyncData()) {
synchronizeData();
}
int index = qualifiedName.indexOf(':");
String prefix, localName;
if (index < 0) {
prefix = null;
localName = qualifiedName;
}
else {
prefix = qualifiedName.substring(0, index);
localName = qualifiedName.substring(index + 1);
}
Attr newAttr = getAttributeNodeNS(namespaceURI, localName);
if (newAttr == null) {
// REVISIT: this is not efficient, we are creating twice the same
// strings for prefix and localName.
newAttr = getOwnerDocument().createAttributeNS(
namespaceURI,
qualifiedName);
if (attributes == null) {
attributes = new AttributeMap(this, null);
}
newAttr.setNodeValue(value);
attributes.setNamedItemNS(newAttr);
}
else {
if (newAttr instanceof AttrNSImpl){
String origNodeName = ((AttrNSImpl) newAttr).name;
String newName = (prefix!=null) ? (prefix+":"+localName) : localName;
((AttrNSImpl) newAttr).name = newName;
if (!newName.equals(origNodeName)) {
// Note: we can't just change the name of the attribute. Names have to be in sorted
// order in the attributes vector because a binary search is used to locate them.
// If the new name has a different prefix, the list may become unsorted.
// Maybe it would be better to resort the list, but the simplest
// fix seems to be to remove the old attribute and re-insert it.
// -- Norman.Walsh@Sun.COM, 2 Feb 2007
newAttr = (Attr) attributes.removeItem(newAttr, false);
attributes.addItem(newAttr);
}
}
else {
// This case may happen if user calls:
// elem.setAttribute("name", "value");
// elem.setAttributeNS(null, "name", "value");
// This case is not defined by the DOM spec, we choose
// to create a new attribute in this case and remove an old one from the tree
// note this might cause events to be propagated or user data to be lost
newAttr = new AttrNSImpl((CoreDocumentImpl)getOwnerDocument(), namespaceURI, qualifiedName, localName);
attributes.setNamedItemNS(newAttr);
}
newAttr.setNodeValue(value);
}
| public org.w3c.dom.Attr | setAttributeNode(org.w3c.dom.Attr newAttr)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.
if (needsSyncData()) {
synchronizeData();
}
if (ownerDocument.errorChecking) {
if (isReadOnly()) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(
DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
if (newAttr.getOwnerDocument() != ownerDocument) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
}
}
if (attributes == null) {
attributes = new AttributeMap(this, null);
}
// This will throw INUSE if necessary
return (Attr) attributes.setNamedItem(newAttr);
| public org.w3c.dom.Attr | setAttributeNodeNS(org.w3c.dom.Attr newAttr)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.
if (needsSyncData()) {
synchronizeData();
}
if (ownerDocument.errorChecking) {
if (isReadOnly()) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(
DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
if (newAttr.getOwnerDocument() != ownerDocument) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
}
}
if (attributes == null) {
attributes = new AttributeMap(this, null);
}
// This will throw INUSE if necessary
return (Attr) attributes.setNamedItemNS(newAttr);
| public void | setIdAttribute(java.lang.String name, boolean makeId)DOM Level 3: register the given attribute node as an ID attribute
if (needsSyncData()) {
synchronizeData();
}
Attr at = getAttributeNode(name);
if( at == null){
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
"NOT_FOUND_ERR", null);
throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
}
if (ownerDocument.errorChecking) {
if (isReadOnly()) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(
DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
if (at.getOwnerElement() != this) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
}
}
((AttrImpl) at).isIdAttribute(makeId);
if (!makeId) {
ownerDocument.removeIdentifier(at.getValue());
}
else {
ownerDocument.putIdentifier(at.getValue(), this);
}
| public void | setIdAttributeNS(java.lang.String namespaceURI, java.lang.String localName, boolean makeId)DOM Level 3: register the given attribute node as an ID attribute
if (needsSyncData()) {
synchronizeData();
}
//if namespace uri is empty string, set it to 'null'
if (namespaceURI != null) {
namespaceURI = (namespaceURI.length() == 0)? null : namespaceURI;
}
Attr at = getAttributeNodeNS(namespaceURI, localName);
if( at == null){
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN,
"NOT_FOUND_ERR", null);
throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
}
if (ownerDocument.errorChecking) {
if (isReadOnly()) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(
DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
if (at.getOwnerElement() != this) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
}
}
((AttrImpl) at).isIdAttribute(makeId);
if (!makeId) {
ownerDocument.removeIdentifier(at.getValue());
}
else {
ownerDocument.putIdentifier(at.getValue(), this);
}
| public void | setIdAttributeNode(org.w3c.dom.Attr at, boolean makeId)DOM Level 3: register the given attribute node as an ID attribute
if (needsSyncData()) {
synchronizeData();
}
if (ownerDocument.errorChecking) {
if (isReadOnly()) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(
DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
if (at.getOwnerElement() != this) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
}
}
((AttrImpl) at).isIdAttribute(makeId);
if (!makeId) {
ownerDocument.removeIdentifier(at.getValue());
}
else {
ownerDocument.putIdentifier(at.getValue(), this);
}
| void | setOwnerDocument(com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl doc)NON-DOM
set the ownerDocument of this node, its children, and its attributes
super.setOwnerDocument(doc);
if (attributes != null) {
attributes.setOwnerDocument(doc);
}
| public void | setReadOnly(boolean readOnly, boolean deep)NON-DOM: Subclassed to flip the attributes' readonly switch as well.
super.setReadOnly(readOnly,deep);
if (attributes != null) {
attributes.setReadOnly(readOnly,true);
}
| protected int | setXercesAttributeNode(org.w3c.dom.Attr attr)NON-DOM: sets attribute node for this element
if (needsSyncData()) {
synchronizeData();
}
if (attributes == null) {
attributes = new AttributeMap(this, null);
}
return attributes.addItem(attr);
| protected void | setupDefaultAttributes()Setup the default attributes.
NamedNodeMapImpl defaults = getDefaultAttributes();
if (defaults != null) {
attributes = new AttributeMap(this, defaults);
}
| protected void | synchronizeData()Synchronizes the data (name and value) for fast nodes.
// no need to sync in the future
needsSyncData(false);
// we don't want to generate any event for this so turn them off
boolean orig = ownerDocument.getMutationEvents();
ownerDocument.setMutationEvents(false);
// attributes
setupDefaultAttributes();
// set mutation events flag back to its original value
ownerDocument.setMutationEvents(orig);
|
|