本文整理汇总了Java中javax.xml.bind.ValidationEventHandler.handleEvent方法的典型用法代码示例。如果您正苦于以下问题:Java ValidationEventHandler.handleEvent方法的具体用法?Java ValidationEventHandler.handleEvent怎么用?Java ValidationEventHandler.handleEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.bind.ValidationEventHandler
的用法示例。
在下文中一共展示了ValidationEventHandler.handleEvent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reportError
import javax.xml.bind.ValidationEventHandler; //导入方法依赖的package包/类
public void reportError( ValidationEvent ve ) throws SAXException {
ValidationEventHandler handler;
try {
handler = marshaller.getEventHandler();
} catch( JAXBException e ) {
throw new SAXException2(e);
}
if(!handler.handleEvent(ve)) {
if(ve.getLinkedException() instanceof Exception)
throw new SAXException2((Exception)ve.getLinkedException());
else
throw new SAXException2(ve.getMessage());
}
}
示例2: handleEvent
import javax.xml.bind.ValidationEventHandler; //导入方法依赖的package包/类
/**
* Reports an error to the user, and asks if s/he wants
* to recover. If the canRecover flag is false, regardless
* of the client instruction, an exception will be thrown.
*
* Only if the flag is true and the user wants to recover from an error,
* the method returns normally.
*
* The thrown exception will be catched by the unmarshaller.
*/
public void handleEvent(ValidationEvent event, boolean canRecover ) throws SAXException {
ValidationEventHandler eventHandler = parent.getEventHandler();
boolean recover = eventHandler.handleEvent(event);
// if the handler says "abort", we will not return the object
// from the unmarshaller.getResult()
if(!recover) aborted = true;
if( !canRecover || !recover )
throw new SAXParseException2( event.getMessage(), locator,
new UnmarshalException(
event.getMessage(),
event.getLinkedException() ) );
}
示例3: and
import javax.xml.bind.ValidationEventHandler; //导入方法依赖的package包/类
/**
* Create an instance of {@link IValidationEventHandler} that invokes both
* passed event handlers.
*
* @param aOne
* The first event handler. May be <code>null</code>.
* @param aOther
* The second event handler. May be <code>null</code>.
* @return Never <code>null</code>.
* @since 8.6.0
*/
@Nonnull
static IValidationEventHandler and (@Nullable final ValidationEventHandler aOne,
@Nullable final ValidationEventHandler aOther)
{
if (aOne != null)
{
if (aOther != null)
return x -> {
if (!aOne.handleEvent (x))
{
// We should not continue
return false;
}
return aOther.handleEvent (x);
};
return x -> aOne.handleEvent (x);
}
if (aOther != null)
return x -> aOther.handleEvent (x);
return x -> true;
}
示例4: reportError
import javax.xml.bind.ValidationEventHandler; //导入方法依赖的package包/类
public void reportError( ValidationEvent ve ) throws AbortSerializationException {
ValidationEventHandler handler;
try {
handler = owner.getEventHandler();
} catch( JAXBException e ) {
throw new AbortSerializationException(e);
}
if(!handler.handleEvent(ve)) {
if(ve.getLinkedException() instanceof Exception)
throw new AbortSerializationException((Exception)ve.getLinkedException());
else
throw new AbortSerializationException(ve.getMessage());
}
}
示例5: handleEvent
import javax.xml.bind.ValidationEventHandler; //导入方法依赖的package包/类
public void handleEvent(ValidationEvent event, boolean canRecover ) throws SAXException {
ValidationEventHandler eventHandler;
try {
eventHandler = parent.getEventHandler();
} catch( JAXBException e ) {
// impossible.
throw new JAXBAssertionError();
}
boolean recover = eventHandler.handleEvent(event);
// if the handler says "abort", we will not return the object
// from the unmarshaller.getResult()
if(!recover) aborted = true;
if( !canRecover || !recover )
throw new SAXException( new UnmarshalException(
event.getMessage(),
event.getLinkedException() ) );
}