/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 2000-2002,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* AttributeMap inherits from NamedNodeMapImpl and extends it to deal with the
* specifics of storing attributes. These are:
* <ul>
* <li>managing ownership of attribute nodes
* <li>managing default attributes
* <li>firing mutation events
* </ul>
* <p>
* This class doesn't directly support mutation events, however, it notifies
* the document when mutations are performed so that the document class do so.
*
* @xerces.internal
*
* @version $Id: AttributeMap.java,v 1.7 2010-11-01 04:39:37 joehw Exp $
*/
/** Serialization version. */
//
// Constructors
//
/** Constructs a named node map. */
super(ownerNode);
// initialize map with the defaults
hasDefaults(true);
}
}
}
/**
* Adds an attribute using its nodeName attribute.
* @see org.w3c.dom.NamedNodeMap#setNamedItem
* @return If the new Node replaces an existing node the replaced Node is
* returned, otherwise null is returned.
* @param arg
* An Attr node to store in this map.
* @exception org.w3c.dom.DOMException The exception description.
*/
throws DOMException {
if (errCheck) {
if (isReadOnly()) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
}
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
}
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "HIERARCHY_REQUEST_ERR", null);
}
}
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INUSE_ATTRIBUTE_ERR", null);
}
// replacing an Attribute with itself does nothing
return arg;
}
// set owner
if (i >= 0) {
// make sure it won't be mistaken with defaults in case it's reused
previous.isSpecified(true);
} else {
i = -1 - i; // Insert point (may be end of list)
}
}
// notify document
// If the new attribute is not normalized,
// the owning element is inherently not normalized.
if (!argn.isNormalized()) {
ownerNode.isNormalized(false);
}
return previous;
} // setNamedItem(Node):Node
/**
* Adds an attribute using its namespaceURI and localName.
* @see org.w3c.dom.NamedNodeMap#setNamedItem
* @return If the new Node replaces an existing node the replaced Node is
* returned, otherwise null is returned.
* @param arg A node to store in a named node map.
*/
throws DOMException {
if (errCheck) {
if (isReadOnly()) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
}
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
}
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "HIERARCHY_REQUEST_ERR", null);
}
}
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INUSE_ATTRIBUTE_ERR", null);
}
// replacing an Attribute with itself does nothing
return arg;
}
// set owner
if (i >= 0) {
// make sure it won't be mistaken with defaults in case it's reused
previous.isSpecified(true);
} else {
// If we can't find by namespaceURI, localName, then we find by
// nodeName so we know where to insert.
if (i >=0) {
} else {
i = -1 - i; // Insert point (may be end of list)
}
}
}
// changed(true);
// notify document
// If the new attribute is not normalized,
// the owning element is inherently not normalized.
if (!argn.isNormalized()) {
ownerNode.isNormalized(false);
}
return previous;
} // setNamedItemNS(Node):Node
/**
* Removes an attribute specified by name.
* @param name
* The name of a node to remove. If the
* removed attribute is known to have a default value, an
* attribute immediately appears containing the default value
* as well as the corresponding namespace URI, local name,
* and prefix when applicable.
* @return The node removed from the map if a node with such a name exists.
* @throws NOT_FOUND_ERR: Raised if there is no node named
* name in the map.
*/
/***/
throws DOMException {
return internalRemoveNamedItem(name, true);
}
/**
* Same as removeNamedItem except that it simply returns null if the
* specified name is not found.
*/
return internalRemoveNamedItem(name, false);
}
/**
* NON-DOM: Remove the node object
*
* NOTE: Specifically removes THIS NODE -- not the node with this
* name, nor the node with these contents. If node does not belong to
* this named node map, we throw a DOMException.
*
* @param item The node to remove
* @param addDefault true -- magically add default attribute
* @return Removed node
* @exception DOMException
*/
throws DOMException {
int index = -1;
for (int i = 0; i < size; ++i) {
index = i;
break;
}
}
}
if (index < 0) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
}
}
/**
* Internal removeNamedItem method allowing to specify whether an exception
* must be thrown if the specified name is not found.
*/
if (isReadOnly()) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
}
if (i < 0) {
if (raiseEx) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
} else {
return null;
}
}
} // internalRemoveNamedItem(String,boolean):Node
boolean addDefault) {
if (attr.isIdAttribute()) {
}
if (hasDefaults() && addDefault) {
// If there's a default, add it instead
Node d;
if (d.getLocalName() !=null){
// we must rely on the name to find a default attribute
// ("test:attr"), but while copying it from the DOCTYPE
// we should not loose namespace URI that was assigned
// to the attribute in the instance document.
}
clone.isSpecified(false);
if (attr.isIdAttribute()) {
}
} else {
}
} else {
}
// changed(true);
// remove reference to owner
// make sure it won't be mistaken with defaults in case it's
// reused
attr.isSpecified(true);
attr.isIdAttribute(false);
// notify document
return attr;
}
/**
* Introduced in DOM Level 2. <p>
* Removes an attribute specified by local name and namespace URI.
* @param namespaceURI
* The namespace URI of the node to remove.
* When it is null or an empty string, this
* method behaves like removeNamedItem.
* @param name The local name of the node to remove. If the
* removed attribute is known to have a default
* value, an attribute immediately appears
* containing the default value.
* @return Node The node removed from the map if a node with such
* a local name and namespace URI exists.
* @throws NOT_FOUND_ERR: Raised if there is no node named
* name in the map.
*/
throws DOMException {
}
/**
* Same as removeNamedItem except that it simply returns null if the
* specified local name and namespace URI is not found.
*/
}
/**
* Internal removeNamedItemNS method allowing to specify whether an
* exception must be thrown if the specified local name and namespace URI
* is not found.
*/
boolean raiseEx) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
}
if (i < 0) {
if (raiseEx) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
} else {
return null;
}
}
if (n.isIdAttribute()) {
}
// If there's a default, add it instead
if (hasDefaults()) {
Node d;
{
if (d.getLocalName() != null) {
// we must rely on the name to find a default attribute
// ("test:attr"), but while copying it from the DOCTYPE
// we should not loose namespace URI that was assigned
// to the attribute in the instance document.
}
clone.isSpecified(false);
if (clone.isIdAttribute()) {
}
} else {
}
} else {
}
} else {
}
// changed(true);
// remove reference to owner
n.ownerNode = ownerDocument;
n.isOwned(false);
// make sure it won't be mistaken with defaults in case it's
// reused
n.isSpecified(true);
// update id table if needed
n.isIdAttribute(false);
// notify document
return n;
} // internalRemoveNamedItemNS(String,String,boolean):Node
//
// Public methods
//
/**
* Cloning a NamedNodeMap is a DEEP OPERATION; it always clones
* all the nodes contained in the map.
*/
newmap.cloneContent(this);
return newmap;
} // cloneMap():AttributeMap
/**
* Override parent's method to set the ownerNode correctly
*/
if (size != 0) {
}
else {
}
for (int i = 0; i < size; ++i) {
}
}
}
} // cloneContent():AttributeMap
/**
* Move specified attributes from the given map to this one
*/
if (attr.isSpecified()) {
}
else {
}
}
}
} // moveSpecifiedAttributes(AttributeMap):void
/**
* Get this AttributeMap in sync with the given "defaults" map.
* @param defaults The default attributes map to sync with.
*/
// remove any existing default
if (!attr.isSpecified()) {
}
}
// add the new defaults
return;
}
}
else {
for (int n = 0; n < dsize; ++n) {
if (i < 0) {
i = -1 - i;
clone.isSpecified(false);
}
}
}
} // reconcileDefaults()
// set owner
if (i >= 0) {
}
else {
// If we can't find by namespaceURI, localName, then we find by
// nodeName so we know where to insert.
if (i >= 0) {
}
else {
i = -1 - i; // Insert point (may be end of list)
}
}
}
// notify document
return i;
}
} // class AttributeMap