当前位置: 首页>>代码示例>>Java>>正文


Java DOMException类代码示例

本文整理汇总了Java中org.w3c.dom.DOMException的典型用法代码示例。如果您正苦于以下问题:Java DOMException类的具体用法?Java DOMException怎么用?Java DOMException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DOMException类属于org.w3c.dom包,在下文中一共展示了DOMException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: appendData

import org.w3c.dom.DOMException; //导入依赖的package包/类
/**
 * Concatenate additional characters onto the end of the data
 * stored in this node. Note that this, and insert(), are the paths
 * by which a DOM could wind up accumulating more data than the
 * language's strings can easily handle. (See above discussion.)
 *
 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) if node is readonly.
 */
public void appendData(String data) {

    if (isReadOnly()) {
        String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null);
        throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
    }
    if (data == null) {
        return;
    }
    if (needsSyncData()) {
        synchronizeData();
    }

    setNodeValue(this.data + data);

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:CharacterDataImpl.java

示例2: getDOMImplementation

import org.w3c.dom.DOMException; //导入依赖的package包/类
/**
 * Obtains DOMImpementaton interface providing a number of methods for performing
 * operations that are independent of any particular DOM instance.
 *
 * @throw DOMException <code>NOT_SUPPORTED_ERR</code> if cannot get DOMImplementation
 * @throw FactoryConfigurationError Application developers should never need to directly catch errors of this type.
 *
 * @return DOMImplementation implementation
 */
private static DOMImplementation getDOMImplementation()
throws DOMException { //can be made public

    DocumentBuilderFactory factory = getFactory(false, false);

    try {
        return factory.newDocumentBuilder().getDOMImplementation();
    } catch (ParserConfigurationException ex) {
        throw new DOMException(
            DOMException.NOT_SUPPORTED_ERR, "Cannot create parser satisfying configuration parameters"
        ); //NOI18N
    } catch (RuntimeException e) {
        // E.g. #36578, IllegalArgumentException. Try to recover gracefully.
        throw (DOMException) new DOMException(DOMException.NOT_SUPPORTED_ERR, e.toString()).initCause(e);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:XMLUtil.java

示例3: endElement

import org.w3c.dom.DOMException; //导入依赖的package包/类
/**
 * Checks whether control needs to be returned to Digester.
 * 
 * @param namespaceURI
 *            the namespace URI
 * @param localName
 *            the local name
 * @param qName
 *            the qualified (prefixed) name
 * @throws SAXException
 *             if the DOM implementation throws an exception
 */
@Override
public void endElement(String namespaceURI, String localName, String qName) throws SAXException {

	try {
		if (depth == 0) {
			getDigester().getXMLReader().setContentHandler(oldContentHandler);
			getDigester().push(root);
			getDigester().endElement(namespaceURI, localName, qName);
		}

		top = top.getParentNode();
		depth--;
	} catch (DOMException e) {
		throw new SAXException(e.getMessage(), e);
	}

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:30,代码来源:NodeCreateRule.java

示例4: createNodeIterator

import org.w3c.dom.DOMException; //导入依赖的package包/类
/**
 * Create and return a NodeIterator. The NodeIterator is
 * added to a list of NodeIterators so that it can be
 * removed to free up the DOM Nodes it references.
 *
 * @param root The root of the iterator.
 * @param whatToShow The whatToShow mask.
 * @param filter The NodeFilter installed. Null means no filter.
 * @param entityReferenceExpansion true to expand the contents of
 *                                 EntityReference nodes
 * @since WD-DOM-Level-2-19990923
 */
public NodeIterator createNodeIterator(Node root,
                                       int whatToShow,
                                       NodeFilter filter,
                                       boolean entityReferenceExpansion)
{

    if (root == null) {
              String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
              throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
    }

    NodeIterator iterator = new NodeIteratorImpl(this,
                                                 root,
                                                 whatToShow,
                                                 filter,
                                                 entityReferenceExpansion);
    if (iterators == null) {
        iterators = new ArrayList<>();
    }

    iterators.add(iterator);

    return iterator;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:DocumentImpl.java

示例5: removeAttribute

import org.w3c.dom.DOMException; //导入依赖的package包/类
/**
 * Remove the named attribute from this Element. If the removed Attribute
 * has a default value, it is immediately replaced thereby.
 * <P>
 * 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. ?????
 * <P>
 * 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.
 *
 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) if the node is
 * readonly.
 */
public void removeAttribute(String name) {

    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);

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:ElementImpl.java

示例6: createAttribute

import org.w3c.dom.DOMException; //导入依赖的package包/类
@Override
public Attr createAttribute(String name) throws DOMException {
    boolean isQualifiedName = (name.indexOf(":") > 0);
    if (isQualifiedName) {
        String nsUri = null;
        String prefix = name.substring(0, name.indexOf(":"));
        //cannot do anything to resolve the URI if prefix is not
        //XMLNS.
        if (XMLNS.equals(prefix)) {
            nsUri = ElementImpl.XMLNS_URI;
            return createAttributeNS(nsUri, name);
        }
    }

    return document.createAttribute(name);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:SOAPDocumentImpl.java

示例7: newFeatureNotFoundError

import org.w3c.dom.DOMException; //导入依赖的package包/类
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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:DOMParserImpl.java

示例8: splitText

import org.w3c.dom.DOMException; //导入依赖的package包/类
/**
 * Break a text node into two sibling nodes. (Note that if the current node
 * has no parent, they won't wind up as "siblings" -- they'll both be
 * orphans.)
 *
 * @param offset
 *            The offset at which to split. If offset is at the end of the
 *            available data, the second node will be empty.
 *
 * @return A reference to the new node (containing data after the offset
 *         point). The original node will contain data up to that point.
 *
 * @throws DOMException(INDEX_SIZE_ERR)
 *             if offset is <0 or >length.
 *
 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR)
 *             if node is read-only.
 */
public Text splitText(int offset)
    throws DOMException {

    if (isReadOnly()) {
        throw new DOMException(
        DOMException.NO_MODIFICATION_ALLOWED_ERR,
            DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null));
    }

    if (needsSyncData()) {
        synchronizeData();
    }
    if (offset < 0 || offset > data.length() ) {
        throw new DOMException(DOMException.INDEX_SIZE_ERR,
            DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INDEX_SIZE_ERR", null));
    }

    // split text into two separate nodes
    Text newText =
        getOwnerDocument().createTextNode(data.substring(offset));
    setNodeValue(data.substring(0, offset));

    // insert new text node
    Node parentNode = getParentNode();
    if (parentNode != null) {
        parentNode.insertBefore(newText, nextSibling);
    }

    return newText;

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:50,代码来源:TextImpl.java

示例9: selectNodeContents

import org.w3c.dom.DOMException; //导入依赖的package包/类
public void selectNodeContents(Node refNode)
    throws RangeException
{
    if (fDocument.errorChecking) {
        if( fDetach) {
            throw new DOMException(
                    DOMException.INVALID_STATE_ERR,
                    DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null));
        }
        if ( !isLegalContainer(refNode)) {
            throw new RangeExceptionImpl(
                    RangeException.INVALID_NODE_TYPE_ERR,
                    DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_NODE_TYPE_ERR", null));
        }
        if ( fDocument != refNode.getOwnerDocument() && fDocument != refNode) {
            throw new DOMException(
                    DOMException.WRONG_DOCUMENT_ERR,
                    DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null));
        }
    }
    fStartContainer = refNode;
    fEndContainer = refNode;
    Node first = refNode.getFirstChild();
    fStartOffset = 0;
    if (first == null) {
        fEndOffset = 0;
    } else {
        int i = 0;
        for (Node n = first; n!=null; n = n.getNextSibling()) {
            i++;
        }
        fEndOffset = i;
    }

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:RangeImpl.java

示例10: insertBefore

import org.w3c.dom.DOMException; //导入依赖的package包/类
/**
 * Since a Document may contain at most one top-level Element child,
 * and at most one DocumentType declaraction, we need to subclass our
 * add-children methods to implement this constraint.
 * Since appendChild() is implemented as insertBefore(,null),
 * altering the latter fixes both.
 * <p>
 * While I'm doing so, I've taken advantage of the opportunity to
 * cache documentElement and docType so we don't have to
 * search for them.
 *
 * REVISIT: According to the spec it is not allowed to alter neither the
 * document element nor the document type in any way
 */
public Node insertBefore(Node newChild, Node refChild)
throws DOMException {

    // Only one such child permitted
    int type = newChild.getNodeType();
    if (errorChecking) {
        if((type == Node.ELEMENT_NODE && docElement != null) ||
        (type == Node.DOCUMENT_TYPE_NODE && docType != null)) {
            String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "HIERARCHY_REQUEST_ERR", null);
            throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, msg);
        }
    }
    // Adopt orphan doctypes
    if (newChild.getOwnerDocument() == null &&
    newChild instanceof DocumentTypeImpl) {
        ((DocumentTypeImpl) newChild).ownerDocument = this;
    }
    super.insertBefore(newChild,refChild);

    // If insert succeeded, cache the kid appropriately
    if (type == Node.ELEMENT_NODE) {
        docElement = (ElementImpl)newChild;
    }
    else if (type == Node.DOCUMENT_TYPE_NODE) {
        docType = (DocumentTypeImpl)newChild;
    }

    return newChild;

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:45,代码来源:CoreDocumentImpl.java

示例11: replaceData

import org.w3c.dom.DOMException; //导入依赖的package包/类
/**
 * Replace a series of characters at the specified (zero-based)
 * offset with a new string, NOT necessarily of the same
 * length. Convenience method, equivalent to a delete followed by an
 * insert. Throws a DOMException if the specified offset is beyond
 * the end of the existing data.
 *
 * @param offset       The offset at which to begin replacing.
 *
 * @param count        The number of characters to remove,
 * interpreted as in the delete() method.
 *
 * @param data         The new string to be inserted at offset in place of
 * the removed data. Note that the entire string will
 * be inserted -- the count parameter does not affect
 * insertion, and the new data may be longer or shorter
 * than the substring it replaces.
 *
 * @throws DOMException(INDEX_SIZE_ERR) if offset is negative or
 * greater than length, or if count is negative.
 *
 * @throws DOMException(NO_MODIFICATION_ALLOWED_ERR) if node is
 * readonly.
 */
public void replaceData(int offset, int count, String data)
throws DOMException {

    CoreDocumentImpl ownerDocument = ownerDocument();

    // The read-only check is done by deleteData()
    // ***** This could be more efficient w/r/t Mutation Events,
    // specifically by aggregating DOMAttrModified and
    // DOMSubtreeModified. But mutation events are
    // underspecified; I don't feel compelled
    // to deal with it right now.
    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();
    }

    //notify document
    ownerDocument.replacingData(this);

    // keep old value for document notification
    String oldvalue = this.data;

    internalDeleteData(offset, count, true);
    internalInsertData(offset, data, true);

    ownerDocument.replacedCharacterData(this, oldvalue, this.data);

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:57,代码来源:CharacterDataImpl.java

示例12: insertBefore

import org.w3c.dom.DOMException; //导入依赖的package包/类
public Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild) throws DOMException {
    Node n = super.insertBefore(newChild, refChild);
    if (n instanceof Element) {
        if (getModel() == null || getModel().getStatus() != XDMModel.Status.PARSING) {
            consolidateNamespaces((Element)n);
        }
    }
    return n;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:Element.java

示例13: CoreDocumentImpl

import org.w3c.dom.DOMException; //导入依赖的package包/类
/** For DOM2 support. */
public CoreDocumentImpl(DocumentType doctype, boolean grammarAccess) {
    this(grammarAccess);
    if (doctype != null) {
        DocumentTypeImpl doctypeImpl;
        try {
            doctypeImpl = (DocumentTypeImpl) doctype;
        } catch (ClassCastException e) {
            String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
        }
        doctypeImpl.ownerDocument = this;
        appendChild(doctype);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:CoreDocumentImpl.java

示例14: importNode

import org.w3c.dom.DOMException; //导入依赖的package包/类
@Override
public org.w3c.dom.Node importNode(
    org.w3c.dom.Node importedNode,
    boolean deep)
    throws DOMException {
    handleNewSource();
    return document.importNode(importedNode, deep);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:SOAPPartImpl.java

示例15: createElementDefinition

import org.w3c.dom.DOMException; //导入依赖的package包/类
/**
 * NON-DOM Factory method: creates an element definition. Element
 * definitions hold default attribute values.
 */
public ElementDefinitionImpl createElementDefinition(String name)
        throws DOMException {

    if (errorChecking && !isXMLName(name, xml11Version)) {
        String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_CHARACTER_ERR", null);
        throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
    }
    return new ElementDefinitionImpl(this, name);

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:CoreDocumentImpl.java


注:本文中的org.w3c.dom.DOMException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。