Java Code Examples for org.w3c.dom.DOMException#NOT_FOUND_ERR

The following examples show how to use org.w3c.dom.DOMException#NOT_FOUND_ERR . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IIOMetadataNode.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private void removeAttribute(String name, boolean checkPresent) {
    int numAttributes = attributes.size();
    for (int i = 0; i < numAttributes; i++) {
        IIOAttr attr = (IIOAttr)attributes.get(i);
        if (name.equals(attr.getName())) {
            attr.setOwnerElement(null);
            attributes.remove(i);
            return;
        }
    }

    // If we get here, the attribute doesn't exist
    if (checkPresent) {
        throw new IIODOMException(DOMException.NOT_FOUND_ERR,
                                  "No such attribute!");
    }
}
 
Example 2
Source File: AttributeMap.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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
 */
protected Node removeItem(Node item, boolean addDefault)
    throws DOMException {

    int index = -1;
    if (nodes != null) {
        final int size = nodes.size();
        for (int i = 0; i < size; ++i) {
            if (nodes.get(i) == item) {
                index = i;
                break;
            }
        }
    }
    if (index < 0) {
        String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
        throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
    }

    return remove((AttrImpl)item, index, addDefault);
}
 
Example 3
Source File: IIOMetadataNode.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private void removeAttribute(String name, boolean checkPresent) {
    int numAttributes = attributes.size();
    for (int i = 0; i < numAttributes; i++) {
        IIOAttr attr = (IIOAttr)attributes.get(i);
        if (name.equals(attr.getName())) {
            attr.setOwnerElement(null);
            attributes.remove(i);
            return;
        }
    }

    // If we get here, the attribute doesn't exist
    if (checkPresent) {
        throw new IIODOMException(DOMException.NOT_FOUND_ERR,
                                  "No such attribute!");
    }
}
 
Example 4
Source File: IIOMetadataNode.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void removeAttribute(String name, boolean checkPresent) {
    int numAttributes = attributes.size();
    for (int i = 0; i < numAttributes; i++) {
        IIOAttr attr = (IIOAttr)attributes.get(i);
        if (name.equals(attr.getName())) {
            attr.setOwnerElement(null);
            attributes.remove(i);
            return;
        }
    }

    // If we get here, the attribute doesn't exist
    if (checkPresent) {
        throw new IIODOMException(DOMException.NOT_FOUND_ERR,
                                  "No such attribute!");
    }
}
 
Example 5
Source File: IIOMetadataNode.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private void removeAttribute(String name, boolean checkPresent) {
    int numAttributes = attributes.size();
    for (int i = 0; i < numAttributes; i++) {
        IIOAttr attr = (IIOAttr)attributes.get(i);
        if (name.equals(attr.getName())) {
            attr.setOwnerElement(null);
            attributes.remove(i);
            return;
        }
    }

    // If we get here, the attribute doesn't exist
    if (checkPresent) {
        throw new IIODOMException(DOMException.NOT_FOUND_ERR,
                                  "No such attribute!");
    }
}
 
Example 6
Source File: SVGNamedNodeMap.java    From latexdraw with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Node removeNamedItem(final String name) {
	if(name == null) {
		throw new DOMException(DOMException.NOT_FOUND_ERR, "name is null");
	}

	int i = 0;
	final int size = getLength();
	boolean found = false;

	while(i < size && !found) {
		if(nnm.get(i).getName().equals(name)) {
			found = true;
		}else {
			i++;
		}
	}

	if(found) {
		return nnm.remove(i);
	}

	throw new DOMException(DOMException.NOT_FOUND_ERR, name);
}
 
Example 7
Source File: DomNode.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Node replaceChild(final Node newChild, final Node oldChild) {
    if (oldChild.getParentNode() != this) {
        throw new DOMException(DOMException.NOT_FOUND_ERR, "Node is not a child of this node.");
    }
    ((DomNode) oldChild).replace((DomNode) newChild);
    return oldChild;
}
 
Example 8
Source File: DOMParserImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static DOMException newFeatureNotFoundError(String name) {
    String msg =
        DOMMessageFormatter.formatMessage (
                DOMMessageFormatter.DOM_DOMAIN,
                "FEATURE_NOT_FOUND",
                new Object[] { name });
    return new DOMException (DOMException.NOT_FOUND_ERR, msg);
}
 
Example 9
Source File: ElementImpl.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public void setIdAttributeNS(String namespaceURI, String localName,
        boolean isId) throws DOMException {
    AttrImpl attr = getAttributeNodeNS(namespaceURI, localName);
    if (attr == null) {
        throw new DOMException(DOMException.NOT_FOUND_ERR,
                "No such attribute: " + namespaceURI +  " " + localName);
    }
    attr.isId = isId;
}
 
Example 10
Source File: DOMParserImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static DOMException newFeatureNotFoundError(String name) {
    String msg =
        DOMMessageFormatter.formatMessage (
                DOMMessageFormatter.DOM_DOMAIN,
                "FEATURE_NOT_FOUND",
                new Object[] { name });
    return new DOMException (DOMException.NOT_FOUND_ERR, msg);
}
 
Example 11
Source File: DOMParserImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static DOMException newFeatureNotFoundError(String name) {
    String msg =
        DOMMessageFormatter.formatMessage (
                DOMMessageFormatter.DOM_DOMAIN,
                "FEATURE_NOT_FOUND",
                new Object[] { name });
    return new DOMException (DOMException.NOT_FOUND_ERR, msg);
}
 
Example 12
Source File: ElementImpl.java    From j2objc with Apache License 2.0 5 votes vote down vote up
public Node removeNamedItem(String name) throws DOMException {
    int i = indexOfItem(name);

    if (i == -1) {
        throw new DOMException(DOMException.NOT_FOUND_ERR, null);
    }

    return ElementImpl.this.attributes.remove(i);
}
 
Example 13
Source File: ParentNode.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/** NON-DOM INTERNAL: Within DOM actions,we sometimes need to be able
 * to control which mutation events are spawned. This version of the
 * removeChild operation allows us to do so. It is not intended
 * for use by application programs.
 */
Node internalRemoveChild(Node oldChild, boolean replace)
    throws DOMException {

    CoreDocumentImpl ownerDocument = ownerDocument();
    if (ownerDocument.errorChecking) {
        if (isReadOnly()) {
            throw new DOMException(
                        DOMException.NO_MODIFICATION_ALLOWED_ERR,
                        DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null));
        }
        if (oldChild != null && oldChild.getParentNode() != this) {
            throw new DOMException(DOMException.NOT_FOUND_ERR,
                        DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null));
        }
    }

    ChildNode oldInternal = (ChildNode) oldChild;

    // notify document
    ownerDocument.removingNode(this, oldInternal, replace);

    // update cached length if we have any
    if (fNodeListCache != null) {
        if (fNodeListCache.fLength != -1) {
            fNodeListCache.fLength--;
        }
        if (fNodeListCache.fChildIndex != -1) {
            // if the removed node is the cached node
            // move the cache to its (soon former) previous sibling
            if (fNodeListCache.fChild == oldInternal) {
                fNodeListCache.fChildIndex--;
                fNodeListCache.fChild = oldInternal.previousSibling();
            } else {
                // otherwise just invalidate the cache
                fNodeListCache.fChildIndex = -1;
            }
        }
    }

    // Patch linked list around oldChild
    // Note: lastChild == firstChild.previousSibling
    if (oldInternal == firstChild) {
        // removing first child
        oldInternal.isFirstChild(false);
        firstChild = oldInternal.nextSibling;
        if (firstChild != null) {
            firstChild.isFirstChild(true);
            firstChild.previousSibling = oldInternal.previousSibling;
        }
    } else {
        ChildNode prev = oldInternal.previousSibling;
        ChildNode next = oldInternal.nextSibling;
        prev.nextSibling = next;
        if (next == null) {
            // removing last child
            firstChild.previousSibling = prev;
        } else {
            // removing some other child in the middle
            next.previousSibling = prev;
        }
    }

    // Save previous sibling for normalization checking.
    ChildNode oldPreviousSibling = oldInternal.previousSibling();

    // Remove oldInternal's references to tree
    oldInternal.ownerNode       = ownerDocument;
    oldInternal.isOwned(false);
    oldInternal.nextSibling     = null;
    oldInternal.previousSibling = null;

    changed();

    // notify document
    ownerDocument.removedNode(this, replace);

    checkNormalizationAfterRemove(oldPreviousSibling);

    return oldInternal;

}
 
Example 14
Source File: DOMConfigurationImpl.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
* DOM Level 3 WD - Experimental.
* getParameter
*/
   public Object getParameter(String name) throws DOMException {

           // REVISIT: Recognizes DOM L3 default features only.
           //          Does not yet recognize Xerces features.

           if (name.equalsIgnoreCase(Constants.DOM_COMMENTS)) {
                   return ((features & COMMENTS) != 0) ? Boolean.TRUE : Boolean.FALSE;
           }
           else if (name.equalsIgnoreCase(Constants.DOM_NAMESPACES)) {
                   return (features & NAMESPACES) != 0 ? Boolean.TRUE : Boolean.FALSE;
           }
           else if (name.equalsIgnoreCase(Constants.DOM_DATATYPE_NORMALIZATION)) {
                   // REVISIT: datatype-normalization only takes effect if validation is on
                   return (features & DTNORMALIZATION) != 0 ? Boolean.TRUE : Boolean.FALSE;
           }
           else if (name.equalsIgnoreCase(Constants.DOM_CDATA_SECTIONS)) {
                   return (features & CDATA) != 0 ? Boolean.TRUE : Boolean.FALSE;
           }
           else if (name.equalsIgnoreCase(Constants.DOM_ENTITIES)) {
                   return (features & ENTITIES) != 0 ? Boolean.TRUE : Boolean.FALSE;
           }
           else if (name.equalsIgnoreCase(Constants.DOM_SPLIT_CDATA)) {
                   return (features & SPLITCDATA) != 0 ? Boolean.TRUE : Boolean.FALSE;
           }
           else if (name.equalsIgnoreCase(Constants.DOM_VALIDATE)) {
                   return (features & VALIDATE) != 0 ? Boolean.TRUE : Boolean.FALSE;
           }
           else if (name.equalsIgnoreCase(Constants.DOM_WELLFORMED)) {
                   return (features & WELLFORMED) != 0 ? Boolean.TRUE : Boolean.FALSE;
           }
           else if (name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)) {
               return (features & NSDECL) != 0 ? Boolean.TRUE : Boolean.FALSE;
           }
           else if (name.equalsIgnoreCase(Constants.DOM_INFOSET)) {
                   return (features & INFOSET_MASK) == INFOSET_TRUE_PARAMS ? Boolean.TRUE : Boolean.FALSE;
           }
           else if (name.equalsIgnoreCase(Constants.DOM_NORMALIZE_CHARACTERS)
                           || name.equalsIgnoreCase(Constants.DOM_CANONICAL_FORM)
                           || name.equalsIgnoreCase(Constants.DOM_VALIDATE_IF_SCHEMA)
                           || name.equalsIgnoreCase(Constants.DOM_CHECK_CHAR_NORMALIZATION)
           ) {
                   return Boolean.FALSE;
           }
   else if (name.equalsIgnoreCase(SEND_PSVI)) {
       return Boolean.TRUE;
   }
   else if (name.equalsIgnoreCase(Constants.DOM_PSVI)) {
       return (features & PSVI) != 0 ? Boolean.TRUE : Boolean.FALSE;
   }
   else if (name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE)) {
                   return Boolean.TRUE;
           }
           else if (name.equalsIgnoreCase(Constants.DOM_ERROR_HANDLER)) {
       return fErrorHandlerWrapper.getErrorHandler();
           }
           else if (name.equalsIgnoreCase(Constants.DOM_RESOURCE_RESOLVER)) {
                   XMLEntityResolver entityResolver = getEntityResolver();
                   if (entityResolver != null && entityResolver instanceof DOMEntityResolverWrapper) {
                           return ((DOMEntityResolverWrapper) entityResolver).getEntityResolver();
                   }
                   return null;
           }
           else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_TYPE)) {
                   return getProperty(Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE);
           }
           else if (name.equalsIgnoreCase(Constants.DOM_SCHEMA_LOCATION)) {
                   return getProperty(Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE);
           }
   else if (name.equalsIgnoreCase(SYMBOL_TABLE)){
       return getProperty(SYMBOL_TABLE);
   }
   else if (name.equalsIgnoreCase(GRAMMAR_POOL)){
       return getProperty(GRAMMAR_POOL);
   }
           else {
                   String msg =
                           DOMMessageFormatter.formatMessage(
                                   DOMMessageFormatter.DOM_DOMAIN,
                                   "FEATURE_NOT_FOUND",
                                   new Object[] { name });
                   throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
           }

   }
 
Example 15
Source File: ParentNode.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/** NON-DOM INTERNAL: Within DOM actions,we sometimes need to be able
 * to control which mutation events are spawned. This version of the
 * removeChild operation allows us to do so. It is not intended
 * for use by application programs.
 */
Node internalRemoveChild(Node oldChild, boolean replace)
    throws DOMException {

    CoreDocumentImpl ownerDocument = ownerDocument();
    if (ownerDocument.errorChecking) {
        if (isReadOnly()) {
            throw new DOMException(
                        DOMException.NO_MODIFICATION_ALLOWED_ERR,
                        DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null));
        }
        if (oldChild != null && oldChild.getParentNode() != this) {
            throw new DOMException(DOMException.NOT_FOUND_ERR,
                        DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null));
        }
    }

    ChildNode oldInternal = (ChildNode) oldChild;

    // notify document
    ownerDocument.removingNode(this, oldInternal, replace);

    // update cached length if we have any
    if (fNodeListCache != null) {
        if (fNodeListCache.fLength != -1) {
            fNodeListCache.fLength--;
        }
        if (fNodeListCache.fChildIndex != -1) {
            // if the removed node is the cached node
            // move the cache to its (soon former) previous sibling
            if (fNodeListCache.fChild == oldInternal) {
                fNodeListCache.fChildIndex--;
                fNodeListCache.fChild = oldInternal.previousSibling();
            } else {
                // otherwise just invalidate the cache
                fNodeListCache.fChildIndex = -1;
            }
        }
    }

    // Patch linked list around oldChild
    // Note: lastChild == firstChild.previousSibling
    if (oldInternal == firstChild) {
        // removing first child
        oldInternal.isFirstChild(false);
        firstChild = oldInternal.nextSibling;
        if (firstChild != null) {
            firstChild.isFirstChild(true);
            firstChild.previousSibling = oldInternal.previousSibling;
        }
    } else {
        ChildNode prev = oldInternal.previousSibling;
        ChildNode next = oldInternal.nextSibling;
        prev.nextSibling = next;
        if (next == null) {
            // removing last child
            firstChild.previousSibling = prev;
        } else {
            // removing some other child in the middle
            next.previousSibling = prev;
        }
    }

    // Save previous sibling for normalization checking.
    ChildNode oldPreviousSibling = oldInternal.previousSibling();

    // Remove oldInternal's references to tree
    oldInternal.ownerNode       = ownerDocument;
    oldInternal.isOwned(false);
    oldInternal.nextSibling     = null;
    oldInternal.previousSibling = null;

    changed();

    // notify document
    ownerDocument.removedNode(this, replace);

    checkNormalizationAfterRemove(oldPreviousSibling);

    return oldInternal;

}
 
Example 16
Source File: ParentNode.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/** NON-DOM INTERNAL: Within DOM actions,we sometimes need to be able
 * to control which mutation events are spawned. This version of the
 * removeChild operation allows us to do so. It is not intended
 * for use by application programs.
 */
Node internalRemoveChild(Node oldChild, boolean replace)
    throws DOMException {

    CoreDocumentImpl ownerDocument = ownerDocument();
    if (ownerDocument.errorChecking) {
        if (isReadOnly()) {
            throw new DOMException(
                        DOMException.NO_MODIFICATION_ALLOWED_ERR,
                        DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null));
        }
        if (oldChild != null && oldChild.getParentNode() != this) {
            throw new DOMException(DOMException.NOT_FOUND_ERR,
                        DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null));
        }
    }

    ChildNode oldInternal = (ChildNode) oldChild;

    // notify document
    ownerDocument.removingNode(this, oldInternal, replace);

    // Save previous sibling for normalization checking.
    final ChildNode oldPreviousSibling = oldInternal.previousSibling();

    // update cached length if we have any
    if (fNodeListCache != null) {
        if (fNodeListCache.fLength != -1) {
            fNodeListCache.fLength--;
        }
        if (fNodeListCache.fChildIndex != -1) {
            // if the removed node is the cached node
            // move the cache to its (soon former) previous sibling
            if (fNodeListCache.fChild == oldInternal) {
                fNodeListCache.fChildIndex--;
                fNodeListCache.fChild = oldPreviousSibling;
            } else {
                // otherwise just invalidate the cache
                fNodeListCache.fChildIndex = -1;
            }
        }
    }

    // Patch linked list around oldChild
    // Note: lastChild == firstChild.previousSibling
    if (oldInternal == firstChild) {
        // removing first child
        oldInternal.isFirstChild(false);
        firstChild = oldInternal.nextSibling;
        if (firstChild != null) {
            firstChild.isFirstChild(true);
            firstChild.previousSibling = oldInternal.previousSibling;
        }
    } else {
        ChildNode prev = oldInternal.previousSibling;
        ChildNode next = oldInternal.nextSibling;
        prev.nextSibling = next;
        if (next == null) {
            // removing last child
            firstChild.previousSibling = prev;
        } else {
            // removing some other child in the middle
            next.previousSibling = prev;
        }
    }

    // Remove oldInternal's references to tree
    oldInternal.ownerNode       = ownerDocument;
    oldInternal.isOwned(false);
    oldInternal.nextSibling     = null;
    oldInternal.previousSibling = null;

    changed();

    // notify document
    ownerDocument.removedNode(this, replace);

    checkNormalizationAfterRemove(oldPreviousSibling);

    return oldInternal;

}
 
Example 17
Source File: AttrImpl.java    From jdk1.8-source-analysis with Apache License 2.0 3 votes vote down vote up
/**
 * Remove a child from this Node. The removed child's subtree
 * remains intact so it may be re-inserted elsewhere.
 *
 * @return oldChild, in its new state (removed).
 *
 * @throws DOMException(NOT_FOUND_ERR) if oldChild is not a child of
 * this node.
 *
 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) if this node is
 * read-only.
 */
public Node removeChild(Node oldChild)
    throws DOMException {
    // Tail-call, should be optimizable
    if (hasStringValue()) {
        // we don't have any child per say so it can't be one of them!
        String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
        throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
    }
    return internalRemoveChild(oldChild, false);
}
 
Example 18
Source File: NodeImpl.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Remove a child from this Node. The removed child's subtree
 * remains intact so it may be re-inserted elsewhere.
 * <P>
 * By default we do not have any children, ParentNode overrides this.
 * @see ParentNode
 *
 * @return oldChild, in its new state (removed).
 *
 * @throws DOMException(NOT_FOUND_ERR) if oldChild is not a child of
 * this node.
 *
 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) if this node is
 * read-only.
 */
public Node removeChild(Node oldChild)
            throws DOMException {
    throw new DOMException(DOMException.NOT_FOUND_ERR,
          DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
             "NOT_FOUND_ERR", null));
}
 
Example 19
Source File: NodeImpl.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Remove a child from this Node. The removed child's subtree
 * remains intact so it may be re-inserted elsewhere.
 * <P>
 * By default we do not have any children, ParentNode overrides this.
 * @see ParentNode
 *
 * @return oldChild, in its new state (removed).
 *
 * @throws DOMException(NOT_FOUND_ERR) if oldChild is not a child of
 * this node.
 *
 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) if this node is
 * read-only.
 */
public Node removeChild(Node oldChild)
            throws DOMException {
    throw new DOMException(DOMException.NOT_FOUND_ERR,
          DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
             "NOT_FOUND_ERR", null));
}
 
Example 20
Source File: AttrImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Remove a child from this Node. The removed child's subtree
 * remains intact so it may be re-inserted elsewhere.
 *
 * @return oldChild, in its new state (removed).
 *
 * @throws DOMException(NOT_FOUND_ERR) if oldChild is not a child of
 * this node.
 *
 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) if this node is
 * read-only.
 */
public Node removeChild(Node oldChild)
    throws DOMException {
    // Tail-call, should be optimizable
    if (hasStringValue()) {
        // we don't have any child per say so it can't be one of them!
        String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null);
        throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
    }
    return internalRemoveChild(oldChild, false);
}