本文整理汇总了Java中javax.xml.bind.ValidationEvent.FATAL_ERROR属性的典型用法代码示例。如果您正苦于以下问题:Java ValidationEvent.FATAL_ERROR属性的具体用法?Java ValidationEvent.FATAL_ERROR怎么用?Java ValidationEvent.FATAL_ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.xml.bind.ValidationEvent
的用法示例。
在下文中一共展示了ValidationEvent.FATAL_ERROR属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleEvent
public boolean handleEvent( ValidationEvent event ) {
events.add(event);
boolean retVal = true;
switch( event.getSeverity() ) {
case ValidationEvent.WARNING:
retVal = true; // continue validation
break;
case ValidationEvent.ERROR:
retVal = true; // continue validation
break;
case ValidationEvent.FATAL_ERROR:
retVal = false; // halt validation
break;
default:
_assert( false,
Messages.format( Messages.UNRECOGNIZED_SEVERITY,
event.getSeverity() ) );
break;
}
return retVal;
}
示例2: handleEvent
@Override
public boolean handleEvent(ValidationEvent event) {
events.add(event);
boolean retVal = true;
switch (event.getSeverity()) {
case ValidationEvent.WARNING:
retVal = true; // continue validation
break;
case ValidationEvent.ERROR:
retVal = true; // continue validation
break;
case ValidationEvent.FATAL_ERROR:
retVal = true; // continue validation
break;
}
return retVal;
}
示例3: getErrorLevel
/**
* Get the error level matching the passed JAXB severity.
*
* @param nSeverity
* The JAXB severity.
* @return The matching {@link IErrorLevel}. Never <code>null</code>.
*/
@Nonnull
@OverrideOnDemand
protected IErrorLevel getErrorLevel (final int nSeverity)
{
switch (nSeverity)
{
case ValidationEvent.WARNING:
return EErrorLevel.WARN;
case ValidationEvent.ERROR:
return EErrorLevel.ERROR;
case ValidationEvent.FATAL_ERROR:
return EErrorLevel.FATAL_ERROR;
default:
s_aLogger.warn ("Unknown JAXB validation severity: " + nSeverity + "; defaulting to error");
return EErrorLevel.ERROR;
}
}
示例4: setSeverity
/**
* Set the severity field of this event.
*
* @param _severity Must be one of ValidationEvent.WARNING,
* ValidationEvent.ERROR, or ValidationEvent.FATAL_ERROR.
* @throws IllegalArgumentException if an illegal severity field is supplied
*/
public void setSeverity( int _severity ) {
if( _severity != ValidationEvent.WARNING &&
_severity != ValidationEvent.ERROR &&
_severity != ValidationEvent.FATAL_ERROR ) {
throw new IllegalArgumentException(
Messages.format( Messages.ILLEGAL_SEVERITY ) );
}
this.severity = _severity;
}
示例5: handleEvent
/**
* Receive notification of a validation warning or error.
*
* <p>
*
* The ValidationEvent will have a
* {@link javax.xml.bind.ValidationEventLocator} embedded in it that
* indicates where the error or warning occurred.
*
* <p>
*
* If an unchecked runtime exception is thrown from this method, the JAXB
* provider will treat it as if the method returned false and interrupt
* the current unmarshal, validate, or marshal operation.
*
* @param event
* the encapsulated validation event information. It is a provider error if
* this parameter is null.
*
* @return
* true if the JAXB Provider should attempt to continue the current unmarshal,
* validate, or marshal operation after handling this warning/error, false if
* the provider should terminate the current operation with the appropriate
* <tt>UnmarshalException</tt>, <tt>ValidationException</tt>, or
* <tt>MarshalException</tt>.
*
* @throws IllegalArgumentException
* if the event object is null.
*/
@Override
public boolean handleEvent( ValidationEvent event )
{
if (event==null)
throw new IllegalArgumentException( "No validation event was provided!" );
int line = -1;
int col = -1;
if (event.getLocator()!=null)
{
line = event.getLocator().getLineNumber();
col = event.getLocator().getColumnNumber();
}
if (ValidationEvent.FATAL_ERROR==event.getSeverity())
{
LOGGER.warn( "fatal validation error" );
if (line>-1 && col>-1) LOGGER.warn( "> at line " + line + " / column " + col );
LOGGER.warn( "> " + event.getMessage() );
return false;
}
if (ValidationEvent.WARNING==event.getSeverity())
{
LOGGER.warn( "validation warning" );
if (line>-1 && col>-1) LOGGER.warn( "> at line " + line + " / column " + col );
LOGGER.warn( "> " + event.getMessage() );
}
else
{
LOGGER.warn( "validation error" );
if (line>-1 && col>-1) LOGGER.warn( "> at line " + line + " / column " + col );
LOGGER.warn( "> " + event.getMessage() );
}
return true;
}
示例6: handleEvent
public boolean handleEvent(ValidationEvent event) {
if ((event.getSeverity() == ValidationEvent.FATAL_ERROR)
|| (event.getSeverity() == ValidationEvent.ERROR)) {
return false;
} else if (event.getSeverity() == ValidationEvent.WARNING) {
log.debug("Validation warning: " + event.getMessage() + ".");
return true;
} else {
log.warn("Unknown validation event type.");
return false;
}
}
示例7: handleEvent
@Override
public boolean handleEvent(ValidationEvent event) {
StringBuilder msg = new StringBuilder();
LogLevel type = LogLevel.ERROR;
switch (event.getSeverity()) {
case ValidationEvent.FATAL_ERROR:
case ValidationEvent.ERROR:
msg.append("Invalid XML content");
type = LogLevel.ERROR;
isValid = false;
break;
case ValidationEvent.WARNING:
msg.append("Warning");
type = LogLevel.WARN;
break;
}
if (event.getLocator() != null) {
msg.append(" at [").append(event.getLocator().getLineNumber())
.append(", ").append(event.getLocator().getColumnNumber()).append("]");
}
msg.append(": ").append(event.getMessage());
log.log(type, msg.toString());
if (!isValid)
cause = msg.toString();
return isValid;
}
示例8: getSeverity
private static String getSeverity(int severity) {
switch (severity) {
case ValidationEvent.FATAL_ERROR:
return "FATAL";
case ValidationEvent.ERROR:
return "FATAL";
case ValidationEvent.WARNING:
return "WARNING";
default:
return "";
}
}
示例9: handleEvent
@Override
public boolean handleEvent(ValidationEvent ve)
{
if (ve.getSeverity() == ValidationEvent.FATAL_ERROR
|| ve.getSeverity() == ValidationEvent.ERROR)
{
ValidationEventLocator locator = ve.getLocator();
log.error("{}: {} at line={}, column={}", locator.getURL(),
ve.getMessage(), locator.getLineNumber(),
locator.getColumnNumber());
foundErrors = true;
}
return true;
}
示例10: handleEvent
@Override
public boolean handleEvent(ValidationEvent event) {
switch(event.getSeverity()) {
case ValidationEvent.WARNING:
return warning(event);
case ValidationEvent.ERROR:
return error(event);
case ValidationEvent.FATAL_ERROR:
return fatalError(event);
}
throw new IllegalArgumentException("Unsupported ValidationEvent severity: " + event.getSeverity());
}
示例11: handleEvent
/**
* Default error handling behavior for {@link Unmarshaller}.
*/
public boolean handleEvent(ValidationEvent event) {
return event.getSeverity()!=ValidationEvent.FATAL_ERROR;
}
示例12: handleEvent
/**
* Default error handling behavior fot {@link Unmarshaller}.
*/
public boolean handleEvent(ValidationEvent event) {
return event.getSeverity()!=ValidationEvent.FATAL_ERROR;
}