本文整理匯總了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() ) );
}