本文整理汇总了Java中org.w3c.dom.DOMError.SEVERITY_FATAL_ERROR属性的典型用法代码示例。如果您正苦于以下问题:Java DOMError.SEVERITY_FATAL_ERROR属性的具体用法?Java DOMError.SEVERITY_FATAL_ERROR怎么用?Java DOMError.SEVERITY_FATAL_ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.w3c.dom.DOMError
的用法示例。
在下文中一共展示了DOMError.SEVERITY_FATAL_ERROR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reportDOMError
/**
* 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;
}
示例2: reportDOMError
/**
* 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();
}
示例3: handleError
/**
* 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;
}
示例4: handleError
/**
* 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;
}
示例5: reportDOMError
/**
* 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: reportDOMFatalError
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);
}
}
示例7: handleError
public boolean handleError(DOMError error) {
if (error.getSeverity() == DOMError.SEVERITY_ERROR) {
this.error = "" + error.getMessage();
return false;
}
if (error.getSeverity() == DOMError.SEVERITY_FATAL_ERROR) {
this.fatalError = "" + error.getMessage();
return false;
}
this.warning = "" + error.getMessage();
return true; // warning
}
示例8: handleError
@Override
public boolean handleError(DOMError error) {
int severity = error.getSeverity();
if (severity == DOMError.SEVERITY_FATAL_ERROR) {
logger.severe("[xs-fatal-error]: " + errorMessage(error));
System.exit(1);
} else if (severity == DOMError.SEVERITY_ERROR) {
logger.severe("[xs-error]: " + errorMessage(error));
} else if (severity == DOMError.SEVERITY_WARNING) {
logger.warning("[xs-warning]: " + errorMessage(error));
}
return true;
}
示例9: parseURI
/**
* 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;
}
示例10: parse
/**
* 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;
}
示例11: fatalError
/**
* 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);
}
}
示例12: parseURI
/**
* 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;
}
示例13: dom2xmlInputSource
/**
* NON-DOM: convert LSInput to XNIInputSource
*
* @param is
* @return
*/
XMLInputSource dom2xmlInputSource (LSInput is) {
// need to wrap the LSInput with an XMLInputSource
XMLInputSource xis = null;
// check whether there is a Reader
// according to DOM, we need to treat such reader as "UTF-16".
if (is.getCharacterStream () != null) {
xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
is.getBaseURI (), is.getCharacterStream (),
"UTF-16");
}
// check whether there is an InputStream
else if (is.getByteStream () != null) {
xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
is.getBaseURI (), is.getByteStream (),
is.getEncoding ());
}
// if there is a string data, use a StringReader
// according to DOM, we need to treat such data as "UTF-16".
else if (is.getStringData () != null && is.getStringData().length() > 0) {
xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
is.getBaseURI (), new StringReader (is.getStringData ()),
"UTF-16");
}
// otherwise, just use the public/system/base Ids
else if ((is.getSystemId() != null && is.getSystemId().length() > 0) ||
(is.getPublicId() != null && is.getPublicId().length() > 0)) {
xis = new XMLInputSource (is.getPublicId (), is.getSystemId (),
is.getBaseURI ());
}
else {
// all inputs are null
if (fErrorHandler != null) {
DOMErrorImpl error = new DOMErrorImpl();
error.fType = "no-input-specified";
error.fMessage = "no-input-specified";
error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
fErrorHandler.getErrorHandler().handleError(error);
}
throw new LSException(LSException.PARSE_ERR, "no-input-specified");
}
return xis;
}
示例14: parseURI
/**
* 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 ) {
throw newInvalidStateError();
}
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;
}
示例15: parse
/**
* 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 ) {
throw newInvalidStateError();
}
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;
}