Java Code Examples for javax.xml.bind.ValidationEvent#getMessage()
The following examples show how to use
javax.xml.bind.ValidationEvent#getMessage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AmazonValidationEventHandler.java From amazon-pay-sdk-java with Apache License 2.0 | 6 votes |
/** * Rather than ignore any XML parsing events, we will log these with a * short message indicating where the parsing failed accompanied with * a corresponding stack trace. An exception is not being thrown * because the events could be benign and we would not want to halt * execution of the process. For example, if the Amazon Pay API's * started returning a new element in the XML that the SDK did not * know about, that's OK, and we don't want to kill the program * because something new is discovered. */ public boolean handleEvent(ValidationEvent event) { try { String message = "XML Parse Event at " + "Line " + event.getLocator().getLineNumber() + ", Column " + event.getLocator().getColumnNumber() + ": Message=" + event.getMessage(); StringWriter sw = new StringWriter(); new Exception(message).printStackTrace(new PrintWriter(sw)); log.debug(sw.toString()); } catch (Exception e) { throw new AmazonClientException("Encountered an Exception: ", e); } return true; }
Example 2
Source File: XMLSerializer.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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()); } }
Example 3
Source File: UnmarshallingContext.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * 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() ) ); }
Example 4
Source File: XMLSerializer.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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()); } }
Example 5
Source File: UnmarshallingContext.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * 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() ) ); }
Example 6
Source File: XMLSerializer.java From hottub with GNU General Public License v2.0 | 6 votes |
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()); } }
Example 7
Source File: UnmarshallingContext.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * 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() ) ); }
Example 8
Source File: UnmarshallingContext.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * 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() ) ); }
Example 9
Source File: XMLSerializer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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()); } }
Example 10
Source File: UnmarshallingContext.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * 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() ) ); }
Example 11
Source File: XMLSerializer.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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()); } }
Example 12
Source File: UnmarshallingContext.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * 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() ) ); }
Example 13
Source File: ContextProvidingValidationEventHandler.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public boolean handleEvent(ValidationEvent validationEvent) { ValidationEventLocator locator = validationEvent.getLocator(); lineNumber = locator.getLineNumber(); columnNumber = locator.getColumnNumber(); message = validationEvent.getMessage(); return false; }
Example 14
Source File: NonStoppingValidationEventHandler.java From chipster with MIT License | 5 votes |
public String getValidationEventsAsString() { String s = ""; for (ValidationEvent event : validationEvents) { s += event.getMessage() + "\n"; } return s; }
Example 15
Source File: DataReaderImpl.java From cxf with Apache License 2.0 | 5 votes |
public boolean handleEvent(ValidationEvent event) { // if the original handler has already handled the event, no need for us // to do anything, otherwise if not yet handled, then do this 'hack' if (origHandler != null && origHandler.handleEvent(event)) { return true; } // hack for CXF-3453 String msg = event.getMessage(); return msg != null && msg.contains(":Id") && (msg.startsWith("cvc-type.3.1.1") || msg.startsWith("cvc-type.3.2.2") || msg.startsWith("cvc-complex-type.3.1.1") || msg.startsWith("cvc-complex-type.3.2.2")); }
Example 16
Source File: AbstractValidationEventHandler.java From ph-commons with Apache License 2.0 | 5 votes |
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); }
Example 17
Source File: XMLTransmitter.java From sailfish-core with Apache License 2.0 | 5 votes |
@Override public boolean handleEvent(ValidationEvent ve) { String msg = ve.getMessage(); ValidationEventLocator vel = ve.getLocator(); logger.error( "location : {}.{}: {}", vel.getLineNumber(), vel.getColumnNumber(), msg ); return false; }
Example 18
Source File: XMLTransmitter.java From sailfish-core with Apache License 2.0 | 5 votes |
@Override public boolean handleEvent(ValidationEvent ve) { String msg = ve.getMessage(); ValidationEventLocator vel = ve.getLocator(); Node node = vel.getNode(); String name = node!=null?node.getLocalName():"null"; logger.error( "node : {}.{}: {}", name, vel.getOffset(), msg ); return false; }
Example 19
Source File: XmlValidationHandler.java From aion-germany with GNU General Public License v3.0 | 5 votes |
@Override public boolean handleEvent(ValidationEvent event) { if (event.getSeverity() == ValidationEvent.FATAL_ERROR || event.getSeverity() == ValidationEvent.ERROR) { ValidationEventLocator locator = event.getLocator(); String message = event.getMessage(); int line = locator.getLineNumber(); int column = locator.getColumnNumber(); log.error("Error at [line=" + line + ", column=" + column + "]: " + message); throw new Error(event.getLinkedException()); } return true; }
Example 20
Source File: DataWriterImpl.java From cxf with Apache License 2.0 | 5 votes |
public boolean handleEvent(ValidationEvent event) { // CXF-1194/CXF-7438 this hack is specific to MTOM, so pretty safe to leave in // here before calling the origHandler. String msg = event.getMessage(); if ((msg.startsWith("cvc-type.3.1.2") || msg.startsWith("cvc-complex-type.2.2")) && msg.contains(marshaller.getLastMTOMElementName().getLocalPart())) { return true; } if (origHandler != null) { return origHandler.handleEvent(event); } return false; }