org.w3c.dom.DOMError#SEVERITY_FATAL_ERROR源码实例Demo

下面列出了org.w3c.dom.DOMError#SEVERITY_FATAL_ERROR 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Bytecoder   文件: DOMNormalizer.java
/**
 * 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();
}
 
源代码2 项目: openjdk-8   文件: DOMNormalizer.java
/**
 * 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;
}
 
源代码3 项目: TencentKona-8   文件: DOMNormalizer.java
/**
 * 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();
}
 
源代码4 项目: openjdk-jdk9   文件: DOMNormalizer.java
/**
 * 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();
}
 
源代码5 项目: jdk8u60   文件: DOMNormalizer.java
/**
 * 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;
}
 
源代码6 项目: JDKSourceCode1.8   文件: DOMNormalizer.java
/**
 * 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();
}
 
源代码7 项目: j2objc   文件: DOMErrorHandlerImpl.java
/**
 * 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;
}
 
源代码8 项目: openjdk-8   文件: XMLSchemaLoader.java
void reportDOMFatalError(Exception e) {
    if (fErrorHandler != null) {
        DOMErrorImpl error = new DOMErrorImpl();
        error.fException = e;
        error.fMessage = e.getMessage();
        error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
        fErrorHandler.getErrorHandler().handleError(error);
    }
}
 
源代码9 项目: TencentKona-8   文件: XMLSchemaLoader.java
void reportDOMFatalError(Exception e) {
    if (fErrorHandler != null) {
        DOMErrorImpl error = new DOMErrorImpl();
        error.fException = e;
        error.fMessage = e.getMessage();
        error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
        fErrorHandler.getErrorHandler().handleError(error);
    }
}
 
源代码10 项目: Bytecoder   文件: XMLSchemaLoader.java
void reportDOMFatalError(Exception e) {
    if (fErrorHandler != null) {
        DOMErrorImpl error = new DOMErrorImpl();
        error.fException = e;
        error.fMessage = e.getMessage();
        error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
        fErrorHandler.getErrorHandler().handleError(error);
    }
}
 
源代码11 项目: openjdk-8-source   文件: XMLSchemaLoader.java
void reportDOMFatalError(Exception e) {
    if (fErrorHandler != null) {
        DOMErrorImpl error = new DOMErrorImpl();
        error.fException = e;
        error.fMessage = e.getMessage();
        error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
        fErrorHandler.getErrorHandler().handleError(error);
    }
}
 
源代码12 项目: JDKSourceCode1.8   文件: XMLSchemaLoader.java
void reportDOMFatalError(Exception e) {
    if (fErrorHandler != null) {
        DOMErrorImpl error = new DOMErrorImpl();
        error.fException = e;
        error.fMessage = e.getMessage();
        error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
        fErrorHandler.getErrorHandler().handleError(error);
    }
}
 
源代码13 项目: jdk1.8-source-analysis   文件: DOMParserImpl.java
/**
 * Parse an XML document from a resource identified by an
 * <code>LSInput</code>.
 *
 */
public Document parse (LSInput is) throws LSException {

    // need to wrap the LSInput with an XMLInputSource
    XMLInputSource xmlInputSource = dom2xmlInputSource (is);
    if ( fBusy ) {
        String msg = DOMMessageFormatter.formatMessage (
        DOMMessageFormatter.DOM_DOMAIN,
        "INVALID_STATE_ERR",null);
        throw new DOMException ( DOMException.INVALID_STATE_ERR,msg);
    }

    try {
        currentThread = Thread.currentThread();
                    fBusy = true;
        parse (xmlInputSource);
        fBusy = false;
        if (abortNow && currentThread.isInterrupted()) {
            //reset interrupt state
            abortNow = false;
            Thread.interrupted();
        }
    } catch (Exception e) {
        fBusy = false;
        if (abortNow && currentThread.isInterrupted()) {
            Thread.interrupted();
        }
        if (abortNow) {
            abortNow = false;
            restoreHandlers();
            return null;
        }
        // Consume this exception if the user
        // issued an interrupt or an abort.
        if (e != Abort.INSTANCE) {
            if (!(e instanceof XMLParseException) && fErrorHandler != null) {
               DOMErrorImpl error = new DOMErrorImpl ();
               error.fException = e;
               error.fMessage = e.getMessage ();
               error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
               fErrorHandler.getErrorHandler().handleError (error);
            }
            if (DEBUG) {
               e.printStackTrace ();
            }
            throw (LSException) DOMUtil.createLSException(LSException.PARSE_ERR, e).fillInStackTrace();
        }
    }
    Document doc = getDocument();
    dropDocumentReferences();
    return doc;
}
 
源代码14 项目: openjdk-jdk9   文件: DOMParserImpl.java
/**
 * Parse an XML document from a location identified by an URI reference.
 * If the URI contains a fragment identifier (see section 4.1 in ), the
 * behavior is not defined by this specification.
 *
 */
public Document parseURI (String uri) throws LSException {

    //If DOMParser insstance is already busy parsing another document when this
    // method is called, then raise INVALID_STATE_ERR according to DOM L3 LS spec
    if ( fBusy ) {
        String msg = DOMMessageFormatter.formatMessage (
        DOMMessageFormatter.DOM_DOMAIN,
        "INVALID_STATE_ERR",null);
        throw new DOMException ( DOMException.INVALID_STATE_ERR,msg);
    }

    XMLInputSource source = new XMLInputSource (null, uri, null, false);
    try {
        currentThread = Thread.currentThread();
                    fBusy = true;
        parse (source);
        fBusy = false;
        if (abortNow && currentThread.isInterrupted()) {
            //reset interrupt state
            abortNow = false;
            Thread.interrupted();
        }
    } catch (Exception e){
        fBusy = false;
        if (abortNow && currentThread.isInterrupted()) {
            Thread.interrupted();
        }
        if (abortNow) {
            abortNow = false;
            restoreHandlers();
            return null;
        }
        // Consume this exception if the user
        // issued an interrupt or an abort.
        if (e != Abort.INSTANCE) {
            if (!(e instanceof XMLParseException) && fErrorHandler != null) {
                DOMErrorImpl error = new DOMErrorImpl ();
                error.fException = e;
                error.fMessage = e.getMessage ();
                error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
                fErrorHandler.getErrorHandler ().handleError (error);
            }
            if (DEBUG) {
                e.printStackTrace ();
            }
            throw (LSException) DOMUtil.createLSException(LSException.PARSE_ERR, e).fillInStackTrace();
        }
    }
    Document doc = getDocument();
    dropDocumentReferences();
    return doc;
}
 
源代码15 项目: hottub   文件: DOMParserImpl.java
/**
 * Parse an XML document from a resource identified by an
 * <code>LSInput</code>.
 *
 */
public Document parse (LSInput is) throws LSException {

    // need to wrap the LSInput with an XMLInputSource
    XMLInputSource xmlInputSource = dom2xmlInputSource (is);
    if ( fBusy ) {
        String msg = DOMMessageFormatter.formatMessage (
        DOMMessageFormatter.DOM_DOMAIN,
        "INVALID_STATE_ERR",null);
        throw new DOMException ( DOMException.INVALID_STATE_ERR,msg);
    }

    try {
        currentThread = Thread.currentThread();
                    fBusy = true;
        parse (xmlInputSource);
        fBusy = false;
        if (abortNow && currentThread.isInterrupted()) {
            //reset interrupt state
            abortNow = false;
            Thread.interrupted();
        }
    } catch (Exception e) {
        fBusy = false;
        if (abortNow && currentThread.isInterrupted()) {
            Thread.interrupted();
        }
        if (abortNow) {
            abortNow = false;
            restoreHandlers();
            return null;
        }
        // Consume this exception if the user
        // issued an interrupt or an abort.
        if (e != Abort.INSTANCE) {
            if (!(e instanceof XMLParseException) && fErrorHandler != null) {
               DOMErrorImpl error = new DOMErrorImpl ();
               error.fException = e;
               error.fMessage = e.getMessage ();
               error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
               fErrorHandler.getErrorHandler().handleError (error);
            }
            if (DEBUG) {
               e.printStackTrace ();
            }
            throw (LSException) DOMUtil.createLSException(LSException.PARSE_ERR, e).fillInStackTrace();
        }
    }
    Document doc = getDocument();
    dropDocumentReferences();
    return doc;
}
 
源代码16 项目: TencentKona-8   文件: DOMParserImpl.java
/**
 * Parse an XML document from a location identified by an URI reference.
 * If the URI contains a fragment identifier (see section 4.1 in ), the
 * behavior is not defined by this specification.
 *
 */
public Document parseURI (String uri) throws LSException {

    //If DOMParser insstance is already busy parsing another document when this
    // method is called, then raise INVALID_STATE_ERR according to DOM L3 LS spec
    if ( fBusy ) {
        String msg = DOMMessageFormatter.formatMessage (
        DOMMessageFormatter.DOM_DOMAIN,
        "INVALID_STATE_ERR",null);
        throw new DOMException ( DOMException.INVALID_STATE_ERR,msg);
    }

    XMLInputSource source = new XMLInputSource (null, uri, null);
    try {
        currentThread = Thread.currentThread();
                    fBusy = true;
        parse (source);
        fBusy = false;
        if (abortNow && currentThread.isInterrupted()) {
            //reset interrupt state
            abortNow = false;
            Thread.interrupted();
        }
    } catch (Exception e){
        fBusy = false;
        if (abortNow && currentThread.isInterrupted()) {
            Thread.interrupted();
        }
        if (abortNow) {
            abortNow = false;
            restoreHandlers();
            return null;
        }
        // Consume this exception if the user
        // issued an interrupt or an abort.
        if (e != Abort.INSTANCE) {
            if (!(e instanceof XMLParseException) && fErrorHandler != null) {
                DOMErrorImpl error = new DOMErrorImpl ();
                error.fException = e;
                error.fMessage = e.getMessage ();
                error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
                fErrorHandler.getErrorHandler ().handleError (error);
            }
            if (DEBUG) {
                e.printStackTrace ();
            }
            throw (LSException) DOMUtil.createLSException(LSException.PARSE_ERR, e).fillInStackTrace();
        }
    }
    Document doc = getDocument();
    dropDocumentReferences();
    return doc;
}
 
源代码17 项目: jdk8u60   文件: DOMParserImpl.java
/**
 * Parse an XML document from a location identified by an URI reference.
 * If the URI contains a fragment identifier (see section 4.1 in ), the
 * behavior is not defined by this specification.
 *
 */
public Document parseURI (String uri) throws LSException {

    //If DOMParser insstance is already busy parsing another document when this
    // method is called, then raise INVALID_STATE_ERR according to DOM L3 LS spec
    if ( fBusy ) {
        String msg = DOMMessageFormatter.formatMessage (
        DOMMessageFormatter.DOM_DOMAIN,
        "INVALID_STATE_ERR",null);
        throw new DOMException ( DOMException.INVALID_STATE_ERR,msg);
    }

    XMLInputSource source = new XMLInputSource (null, uri, null);
    try {
        currentThread = Thread.currentThread();
                    fBusy = true;
        parse (source);
        fBusy = false;
        if (abortNow && currentThread.isInterrupted()) {
            //reset interrupt state
            abortNow = false;
            Thread.interrupted();
        }
    } catch (Exception e){
        fBusy = false;
        if (abortNow && currentThread.isInterrupted()) {
            Thread.interrupted();
        }
        if (abortNow) {
            abortNow = false;
            restoreHandlers();
            return null;
        }
        // Consume this exception if the user
        // issued an interrupt or an abort.
        if (e != Abort.INSTANCE) {
            if (!(e instanceof XMLParseException) && fErrorHandler != null) {
                DOMErrorImpl error = new DOMErrorImpl ();
                error.fException = e;
                error.fMessage = e.getMessage ();
                error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
                fErrorHandler.getErrorHandler ().handleError (error);
            }
            if (DEBUG) {
                e.printStackTrace ();
            }
            throw (LSException) DOMUtil.createLSException(LSException.PARSE_ERR, e).fillInStackTrace();
        }
    }
    Document doc = getDocument();
    dropDocumentReferences();
    return doc;
}
 
源代码18 项目: Bytecoder   文件: DOMErrorHandlerWrapper.java
/**
 * Report a fatal error. Fatal errors usually occur when the document
 * is not well-formed and signifies that the parser cannot continue
 * normal operation.
 * <p>
 * <strong>Note:</strong> The error handler should <em>always</em>
 * throw an <code>XNIException</code> from this method. This exception
 * can either be the same exception that is passed as a parameter to
 * the method or a new XNI exception object. If the registered error
 * handler fails to throw an exception, the continuing operation of
 * the parser is undetermined.
 *
 * @param domain    The domain of the fatal 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 fatal error.
 * @param key       The fatal 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 fatalError(String domain, String key,
                       XMLParseException exception) throws XNIException {
    fDOMError.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
    fDOMError.fException = exception;
    fErrorCode.setValues(domain, key);
    String domErrorType = DOMErrorTypeMap.getDOMErrorType(fErrorCode);
    fDOMError.fType = (domErrorType != null) ? domErrorType : 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);
    }
}
 
源代码19 项目: JDKSourceCode1.8   文件: DOMParserImpl.java
/**
 * Parse an XML document from a location identified by an URI reference.
 * If the URI contains a fragment identifier (see section 4.1 in ), the
 * behavior is not defined by this specification.
 *
 */
public Document parseURI (String uri) throws LSException {

    //If DOMParser insstance is already busy parsing another document when this
    // method is called, then raise INVALID_STATE_ERR according to DOM L3 LS spec
    if ( fBusy ) {
        String msg = DOMMessageFormatter.formatMessage (
        DOMMessageFormatter.DOM_DOMAIN,
        "INVALID_STATE_ERR",null);
        throw new DOMException ( DOMException.INVALID_STATE_ERR,msg);
    }

    XMLInputSource source = new XMLInputSource (null, uri, null);
    try {
        currentThread = Thread.currentThread();
                    fBusy = true;
        parse (source);
        fBusy = false;
        if (abortNow && currentThread.isInterrupted()) {
            //reset interrupt state
            abortNow = false;
            Thread.interrupted();
        }
    } catch (Exception e){
        fBusy = false;
        if (abortNow && currentThread.isInterrupted()) {
            Thread.interrupted();
        }
        if (abortNow) {
            abortNow = false;
            restoreHandlers();
            return null;
        }
        // Consume this exception if the user
        // issued an interrupt or an abort.
        if (e != Abort.INSTANCE) {
            if (!(e instanceof XMLParseException) && fErrorHandler != null) {
                DOMErrorImpl error = new DOMErrorImpl ();
                error.fException = e;
                error.fMessage = e.getMessage ();
                error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
                fErrorHandler.getErrorHandler ().handleError (error);
            }
            if (DEBUG) {
                e.printStackTrace ();
            }
            throw (LSException) DOMUtil.createLSException(LSException.PARSE_ERR, e).fillInStackTrace();
        }
    }
    Document doc = getDocument();
    dropDocumentReferences();
    return doc;
}
 
源代码20 项目: hottub   文件: DOMParserImpl.java
/**
 * Parse an XML document from a location identified by an URI reference.
 * If the URI contains a fragment identifier (see section 4.1 in ), the
 * behavior is not defined by this specification.
 *
 */
public Document parseURI (String uri) throws LSException {

    //If DOMParser insstance is already busy parsing another document when this
    // method is called, then raise INVALID_STATE_ERR according to DOM L3 LS spec
    if ( fBusy ) {
        String msg = DOMMessageFormatter.formatMessage (
        DOMMessageFormatter.DOM_DOMAIN,
        "INVALID_STATE_ERR",null);
        throw new DOMException ( DOMException.INVALID_STATE_ERR,msg);
    }

    XMLInputSource source = new XMLInputSource (null, uri, null);
    try {
        currentThread = Thread.currentThread();
                    fBusy = true;
        parse (source);
        fBusy = false;
        if (abortNow && currentThread.isInterrupted()) {
            //reset interrupt state
            abortNow = false;
            Thread.interrupted();
        }
    } catch (Exception e){
        fBusy = false;
        if (abortNow && currentThread.isInterrupted()) {
            Thread.interrupted();
        }
        if (abortNow) {
            abortNow = false;
            restoreHandlers();
            return null;
        }
        // Consume this exception if the user
        // issued an interrupt or an abort.
        if (e != Abort.INSTANCE) {
            if (!(e instanceof XMLParseException) && fErrorHandler != null) {
                DOMErrorImpl error = new DOMErrorImpl ();
                error.fException = e;
                error.fMessage = e.getMessage ();
                error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
                fErrorHandler.getErrorHandler ().handleError (error);
            }
            if (DEBUG) {
                e.printStackTrace ();
            }
            throw (LSException) DOMUtil.createLSException(LSException.PARSE_ERR, e).fillInStackTrace();
        }
    }
    Document doc = getDocument();
    dropDocumentReferences();
    return doc;
}