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


Java DOMError类代码示例

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


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

示例1: reportDOMError

import org.w3c.dom.DOMError; //导入依赖的package包/类
/**
 * Reports a DOM error to the user handler.
 *
 * If the error is fatal, the processing will be always aborted.
 */
public static final void reportDOMError(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
                    String message, short severity, String type ) {
    if( errorHandler!=null ) {
        error.reset();
        error.fMessage = message;
        error.fSeverity = severity;
        error.fLocator = locator;
        error.fType = type;
        error.fRelatedData = locator.fRelatedNode;

        if(!errorHandler.handleError(error))
            throw abort;
    }
    if( severity==DOMError.SEVERITY_FATAL_ERROR )
        throw abort;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:DOMNormalizer.java

示例2: warning

import org.w3c.dom.DOMError; //导入依赖的package包/类
/**
 * Reports a warning. Warnings are non-fatal and can be safely ignored
 * by most applications.
 *
 * @param domain    The domain of the warning. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this warning.
 * @param key       The warning key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */

public void warning(String domain, String key,
                    XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_WARNING;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode = fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:DOMErrorHandlerWrapper.java

示例3: error

import org.w3c.dom.DOMError; //导入依赖的package包/类
/**
 * Reports an error. Errors are non-fatal and usually signify that the
 * document is invalid with respect to its grammar(s).
 *
 * @param domain    The domain of the error. The domain can be any
 *                  string but is suggested to be a valid URI. The
 *                  domain can be used to conveniently specify a web
 *                  site location of the relevent specification or
 *                  document pertaining to this error.
 * @param key       The error key. This key can be any string and
 *                  is implementation dependent.
 * @param exception Exception.
 *
 * @throws XNIException Thrown to signal that the parser should stop
 *                      parsing the document.
 */
public void error(String domain, String key,
                  XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_ERROR;
    fDOMError.fException = exception;
    // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
    fDOMError.fType = key;
    fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
    DOMLocatorImpl locator = fDOMError.fLocator;
    if (locator != null) {
        locator.fColumnNumber = exception.getColumnNumber();
        locator.fLineNumber = exception.getLineNumber();
        locator.fUtf16Offset = exception.getCharacterOffset();
        locator.fUri = exception.getExpandedSystemId();
        locator.fRelatedNode= fCurrentNode;
    }
    if (fDomErrorHandler != null) {
        fDomErrorHandler.handleError(fDOMError);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:DOMErrorHandlerWrapper.java

示例4: reportDOMError

import org.w3c.dom.DOMError; //导入依赖的package包/类
/**
 * Reports a DOM error to the user handler.
 *
 * If the error is fatal, the processing will be always aborted.
 */
public static final void reportDOMError(DOMErrorHandler errorHandler, DOMErrorImpl error, DOMLocatorImpl locator,
                    String message, short severity, String type ) {
    if( errorHandler!=null ) {
        error.reset();
        error.fMessage = message;
        error.fSeverity = severity;
        error.fLocator = locator;
        error.fType = type;
        error.fRelatedData = locator.fRelatedNode;

        if(!errorHandler.handleError(error))
            throw new AbortException();
    }
    if( severity==DOMError.SEVERITY_FATAL_ERROR )
        throw new AbortException();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:DOMNormalizer.java

示例5: isCDATASectionWellFormed

import org.w3c.dom.DOMError; //导入依赖的package包/类
/**
 * Checks if an CDATASection node is well-formed, by checking it's data
 * for well-formedness.  Note that the presence of a CDATA termination mark
 * in the contents of a CDATASection is handled by the parameter
 * spli-cdata-sections
 *
 * @param data The contents of the comment node
 */
protected void isCDATASectionWellFormed(CDATASection node) {
    // Does the data valid XML character data
    Character invalidChar = isWFXMLChar(node.getData());
    //if (!isWFXMLChar(node.getData(), invalidChar)) {
    if (invalidChar != null) {
        String msg =
            Utils.messages.createMessage(
                MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA,
                new Object[] { Integer.toHexString(Character.getNumericValue(invalidChar.charValue())) });

        if (fErrorHandler != null) {
            fErrorHandler.handleError(
                new DOMErrorImpl(
                    DOMError.SEVERITY_FATAL_ERROR,
                    msg,
                    MsgKey.ER_WF_INVALID_CHARACTER,
                    null,
                    null,
                    null));
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:DOM3TreeWalker.java

示例6: isTextWellFormed

import org.w3c.dom.DOMError; //导入依赖的package包/类
/**
 * Checks if an Text node is well-formed, by checking if it contains invalid
 * XML characters.
 *
 * @param data The contents of the comment node
 */
protected void isTextWellFormed(Text node) {
    // Does the data valid XML character data
    Character invalidChar = isWFXMLChar(node.getData());
    if (invalidChar != null) {
        String msg =
            Utils.messages.createMessage(
                MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT,
                new Object[] { Integer.toHexString(Character.getNumericValue(invalidChar.charValue())) });

        if (fErrorHandler != null) {
            fErrorHandler.handleError(
                new DOMErrorImpl(
                    DOMError.SEVERITY_FATAL_ERROR,
                    msg,
                    MsgKey.ER_WF_INVALID_CHARACTER,
                    null,
                    null,
                    null));
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:DOM3TreeWalker.java

示例7: handleError

import org.w3c.dom.DOMError; //导入依赖的package包/类
/**
 * Implementation of DOMErrorHandler.handleError that
 * adds copy of error to list for later retrieval.
 *
 */
public boolean handleError(DOMError error) {
    boolean fail = true;
    String severity = null;
    if (error.getSeverity() == DOMError.SEVERITY_WARNING) {
        fail = false;
        severity = "[Warning]";
    } else if (error.getSeverity() == DOMError.SEVERITY_ERROR) {
        severity = "[Error]";
    } else if (error.getSeverity() == DOMError.SEVERITY_FATAL_ERROR) {
        severity = "[Fatal Error]";
    }

    System.err.println(severity + ": " + error.getMessage() + "\t");
    System.err.println("Type : " + error.getType() + "\t" + "Related Data: "
            + error.getRelatedData() + "\t" + "Related Exception: "
            + error.getRelatedException() );

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

示例8: createDOMError

import org.w3c.dom.DOMError; //导入依赖的package包/类
/**
 * Creates a DOMError object with the given parameters.
 */
protected DOMError createDOMError(String type,
                                  short severity,
                                  String key,
                                  Object[] args,
                                  Node related,
                                  Exception e) {
    try {
        return new DocumentError(type,
                                 severity,
                                 getCurrentDocument().formatMessage(key, args),
                                 related,
                                 e);
    } catch (Exception ex) {
        return new DocumentError(type,
                                 severity,
                                 key,
                                 related,
                                 e);
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:24,代码来源:AbstractDocument.java

示例9: handleError

import org.w3c.dom.DOMError; //导入依赖的package包/类
public boolean handleError(DOMError error) {
    String from = schemaResource != null ? schemaResource : "string";
    log.warn("DOM error reported loading schema from " + from + ":\n" +
            "  message: " + error.getMessage() + "\n" +
            "  type: " + error.getType() + "\n" +
            "  related data: " + error.getRelatedData() + "\n" +
            "  related exception: " + error.getRelatedException() + "\n" +
            "  severity: " + error.getSeverity() + "\n" +
            "  location: " + error.getLocation());

    if (error.getRelatedException() instanceof Throwable) {
        Throwable t = (Throwable) error.getRelatedException();
        log.warn("DOM error related exception: " + t.getMessage(), t);
    }

    return false;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:18,代码来源:XSDSchemaMapper.java

示例10: isCDATASectionWellFormed

import org.w3c.dom.DOMError; //导入依赖的package包/类
/**
 * Checks if an CDATASection node is well-formed, by checking it's data
 * for well-formedness.  Note that the presence of a CDATA termination mark
 * in the contents of a CDATASection is handled by the parameter 
 * spli-cdata-sections
 * 
 * @param data The contents of the comment node
 */
protected void isCDATASectionWellFormed(CDATASection node) {
    // Does the data valid XML character data        
    Character invalidChar = isWFXMLChar(node.getData());
    //if (!isWFXMLChar(node.getData(), invalidChar)) {
    if (invalidChar != null) {
        String msg =
            Utils.messages.createMessage(
                MsgKey.ER_WF_INVALID_CHARACTER_IN_CDATA,
                new Object[] { Integer.toHexString(Character.getNumericValue(invalidChar.charValue())) });

        if (fErrorHandler != null) {
            fErrorHandler.handleError(
                new DOMErrorImpl(
                    DOMError.SEVERITY_FATAL_ERROR,
                    msg,
                    MsgKey.ER_WF_INVALID_CHARACTER,
                    null,
                    null,
                    null));
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:31,代码来源:DOM3TreeWalker.java

示例11: isTextWellFormed

import org.w3c.dom.DOMError; //导入依赖的package包/类
/**
 * Checks if an Text node is well-formed, by checking if it contains invalid
 * XML characters.
 * 
 * @param data The contents of the comment node
 */
protected void isTextWellFormed(Text node) {
    // Does the data valid XML character data        
	Character invalidChar = isWFXMLChar(node.getData());
	if (invalidChar != null) {
        String msg =
            Utils.messages.createMessage(
                MsgKey.ER_WF_INVALID_CHARACTER_IN_TEXT,
                new Object[] { Integer.toHexString(Character.getNumericValue(invalidChar.charValue())) });

        if (fErrorHandler != null) {
            fErrorHandler.handleError(
                new DOMErrorImpl(
                    DOMError.SEVERITY_FATAL_ERROR,
                    msg,
                    MsgKey.ER_WF_INVALID_CHARACTER,
                    null,
                    null,
                    null));
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:28,代码来源:DOM3TreeWalker.java

示例12: handleError

import org.w3c.dom.DOMError; //导入依赖的package包/类
/**
 * Implementation of DOMErrorHandler.handleError that
 * adds copy of error to list for later retrieval.
 *
 */
public boolean handleError(DOMError error) {
    boolean fail = true;
    String severity = null;
    if (error.getSeverity() == DOMError.SEVERITY_WARNING) {
        fail = false;
        severity = "[Warning]";
    } else if (error.getSeverity() == DOMError.SEVERITY_ERROR) {
        severity = "[Error]";
    } else if (error.getSeverity() == DOMError.SEVERITY_FATAL_ERROR) {
        severity = "[Fatal Error]";
    }
    
    System.err.println(severity + ": " + error.getMessage() + "\t");
    System.err.println("Type : " + error.getType() + "\t" + "Related Data: "
            + error.getRelatedData() + "\t" + "Related Exception: "
            + error.getRelatedException() );
    
    return fail;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:25,代码来源:DOMErrorHandlerImpl.java

示例13: testInvalidCharactersCdata

import org.w3c.dom.DOMError; //导入依赖的package包/类
public void testInvalidCharactersCdata() throws Exception {
    ErrorRecorder errorRecorder = new ErrorRecorder();
    domConfiguration.setParameter("cdata-sections", true);
    domConfiguration.setParameter("error-handler", errorRecorder);
    domConfiguration.setParameter("namespaces", false);
    Element root = document.createElement("foo");
    document.appendChild(root);
    CDATASection cdata = document.createCDATASection("");
    root.appendChild(cdata);

    for (int c = 0; c <= Character.MAX_VALUE; c++) {
        cdata.setData(new String(new char[]{ 'A', 'B', (char) c }));
        document.normalizeDocument();
        if (isValid((char) c)) {
            assertEquals(Collections.<DOMError>emptyList(), errorRecorder.errors);
        } else {
            errorRecorder.assertAllErrors("For character " + c,
                    DOMError.SEVERITY_ERROR, "wf-invalid-character");
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:22,代码来源:NormalizeTest.java

示例14: testInvalidCharactersText

import org.w3c.dom.DOMError; //导入依赖的package包/类
public void testInvalidCharactersText() throws Exception {
    ErrorRecorder errorRecorder = new ErrorRecorder();
    domConfiguration.setParameter("error-handler", errorRecorder);
    domConfiguration.setParameter("namespaces", false);
    Element root = document.createElement("foo");
    document.appendChild(root);
    Text text = document.createTextNode("");
    root.appendChild(text);

    for (int c = 0; c <= Character.MAX_VALUE; c++) {
        text.setData(new String(new char[]{ 'A', 'B', (char) c }));
        document.normalizeDocument();
        if (isValid((char) c)) {
            assertEquals(Collections.<DOMError>emptyList(), errorRecorder.errors);
        } else {
            errorRecorder.assertAllErrors("For character " + c,
                    DOMError.SEVERITY_ERROR, "wf-invalid-character");
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:21,代码来源:NormalizeTest.java

示例15: testInvalidCharactersAttribute

import org.w3c.dom.DOMError; //导入依赖的package包/类
public void testInvalidCharactersAttribute() throws Exception {
    ErrorRecorder errorRecorder = new ErrorRecorder();
    domConfiguration.setParameter("error-handler", errorRecorder);
    domConfiguration.setParameter("namespaces", false);
    Element root = document.createElement("foo");
    document.appendChild(root);

    for (int c = 0; c <= Character.MAX_VALUE; c++) {
        root.setAttribute("bar", new String(new char[] { 'A', 'B', (char) c}));
        document.normalizeDocument();
        if (isValid((char) c)) {
            assertEquals(Collections.<DOMError>emptyList(), errorRecorder.errors);
        } else {
            errorRecorder.assertAllErrors("For character " + c,
                    DOMError.SEVERITY_ERROR, "wf-invalid-character");
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:19,代码来源:NormalizeTest.java


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