本文整理汇总了Java中javax.xml.bind.ValidationEvent.getLinkedException方法的典型用法代码示例。如果您正苦于以下问题:Java ValidationEvent.getLinkedException方法的具体用法?Java ValidationEvent.getLinkedException怎么用?Java ValidationEvent.getLinkedException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.bind.ValidationEvent
的用法示例。
在下文中一共展示了ValidationEvent.getLinkedException方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reportError
import javax.xml.bind.ValidationEvent; //导入方法依赖的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.ValidationEvent; //导入方法依赖的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: formatEvent
import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
public static String formatEvent(ValidationEvent e) {
StringBuilder sb = new StringBuilder();
if (e.getLocator() != null) {
appendLocator(sb, e.getLocator());
}
if (e.getMessage() != null) {
sb.append(e.getMessage());
if (e.getLinkedException() != null) {
sb.append(" - ");
}
}
if (e.getLinkedException() != null) {
sb.append(e.getLinkedException().toString());
}
return sb.toString();
}
示例4: handleEvent
import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
@Override
public boolean handleEvent(ValidationEvent validationEvent) {
if (validationEvent.getLinkedException()==null){
logger.warn("detected " +validationEvent.getMessage() +" it will be ignored");
return true;
}
return false;
}
示例5: handleEvent
import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
public boolean handleEvent(ValidationEvent event) {
ValidationEventLocator loc = event.getLocator();
String file = loc.getURL().getFile();
try {
file = URLDecoder.decode(file, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
int lastSlash = file.lastIndexOf('/');
if (lastSlash > 0)
file = file.substring(lastSlash + 1);
String errorMsg = event.getMessage();
if (errorMsg == null) {
Throwable t = event.getLinkedException();
while (t != null && errorMsg == null) {
errorMsg = t.getMessage();
t = t.getCause();
}
}
JOptionPane
.showMessageDialog(null, "<html><h3>Failed to load a custom map</h3><p><i>" + errorMsg
+ "</i></p><br><p>file: \"<b>" + file + "</b>\"<br>line/column: <i>" + loc.getLineNumber()
+ "/" + loc.getColumnNumber() + "</i></p>", "Error: custom map loading failed",
JOptionPane.ERROR_MESSAGE);
log.error(event.toString());
return false;
}
示例6: handleEvent
import javax.xml.bind.ValidationEvent; //导入方法依赖的package包/类
public final boolean handleEvent (@Nonnull final ValidationEvent aEvent)
{
final IErrorLevel aErrorLevel = getErrorLevel (aEvent.getSeverity ());
final SingleErrorBuilder aErrBuilder = SingleError.builder ().setErrorLevel (aErrorLevel);
final ValidationEventLocator aLocator = aEvent.getLocator ();
aErrBuilder.setErrorLocation (new SimpleLocation (getLocationResourceID (aLocator),
aLocator != null ? aLocator.getLineNumber ()
: ILocation.ILLEGAL_NUMBER,
aLocator != null ? aLocator.getColumnNumber ()
: ILocation.ILLEGAL_NUMBER))
.setErrorFieldName (getErrorFieldName (aLocator));
// Message may be null in some cases (e.g. when a linked exception is
// present), but is not allowed to be null!
String sMsg = aEvent.getMessage ();
if (sMsg == null)
{
if (aEvent.getLinkedException () != null)
{
sMsg = aEvent.getLinkedException ().getMessage ();
if (sMsg == null)
sMsg = "Exception";
}
else
{
// Does this ever happen????
sMsg = "Validation event";
}
}
aErrBuilder.setErrorText (sMsg).setLinkedException (aEvent.getLinkedException ());
// call our callback
onEvent (aErrBuilder.build ());
// Continue processing?
return continueProcessing (aErrorLevel);
}