Java Code Examples for javax.xml.bind.ValidationEvent#getLocator()
The following examples show how to use
javax.xml.bind.ValidationEvent#getLocator() .
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: MyValidationEventHandler.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
@Override public boolean handleEvent(ValidationEvent ve) { if (ve.getSeverity() == ValidationEvent.FATAL_ERROR || ve.getSeverity() == ValidationEvent.ERROR){ ValidationEventLocator locator = ve.getLocator(); //print message from valdation event logger.info("Message is {}", ve.getMessage()); //output line and column number logger.info("Column is {} at line number {}", locator.getColumnNumber(), locator.getLineNumber()); return false; } return true; }
Example 2
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 3
Source File: ValidationEventHandlerImpl.java From web-feature-service with Apache License 2.0 | 5 votes |
@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; }
Example 4
Source File: DefaultValidationEventHandler.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Calculate a location message for the event * */ private String getLocation(ValidationEvent event) { StringBuffer msg = new StringBuffer(); ValidationEventLocator locator = event.getLocator(); if( locator != null ) { URL url = locator.getURL(); Object obj = locator.getObject(); Node node = locator.getNode(); int line = locator.getLineNumber(); if( url!=null || line!=-1 ) { msg.append( "line " + line ); if( url!=null ) msg.append( " of " + url ); } else if( obj != null ) { msg.append( " obj: " + obj.toString() ); } else if( node != null ) { msg.append( " node: " + node.toString() ); } } else { msg.append( Messages.format( Messages.LOCATION_UNAVAILABLE ) ); } return msg.toString(); }
Example 5
Source File: DefaultValidationEventHandler.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Calculate a location message for the event * */ private String getLocation(ValidationEvent event) { StringBuffer msg = new StringBuffer(); ValidationEventLocator locator = event.getLocator(); if( locator != null ) { URL url = locator.getURL(); Object obj = locator.getObject(); Node node = locator.getNode(); int line = locator.getLineNumber(); if( url!=null || line!=-1 ) { msg.append( "line " + line ); if( url!=null ) msg.append( " of " + url ); } else if( obj != null ) { msg.append( " obj: " + obj.toString() ); } else if( node != null ) { msg.append( " node: " + node.toString() ); } } else { msg.append( Messages.format( Messages.LOCATION_UNAVAILABLE ) ); } return msg.toString(); }
Example 6
Source File: DefaultValidationEventHandler.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Calculate a location message for the event * */ private String getLocation(ValidationEvent event) { StringBuffer msg = new StringBuffer(); ValidationEventLocator locator = event.getLocator(); if( locator != null ) { URL url = locator.getURL(); Object obj = locator.getObject(); Node node = locator.getNode(); int line = locator.getLineNumber(); if( url!=null || line!=-1 ) { msg.append( "line " + line ); if( url!=null ) msg.append( " of " + url ); } else if( obj != null ) { msg.append( " obj: " + obj.toString() ); } else if( node != null ) { msg.append( " node: " + node.toString() ); } } else { msg.append( Messages.format( Messages.LOCATION_UNAVAILABLE ) ); } return msg.toString(); }
Example 7
Source File: DefaultValidationEventHandler.java From Java8CN with Apache License 2.0 | 5 votes |
/** * Calculate a location message for the event * */ private String getLocation(ValidationEvent event) { StringBuffer msg = new StringBuffer(); ValidationEventLocator locator = event.getLocator(); if( locator != null ) { URL url = locator.getURL(); Object obj = locator.getObject(); Node node = locator.getNode(); int line = locator.getLineNumber(); if( url!=null || line!=-1 ) { msg.append( "line " + line ); if( url!=null ) msg.append( " of " + url ); } else if( obj != null ) { msg.append( " obj: " + obj.toString() ); } else if( node != null ) { msg.append( " node: " + node.toString() ); } } else { msg.append( Messages.format( Messages.LOCATION_UNAVAILABLE ) ); } return msg.toString(); }
Example 8
Source File: DefaultValidationEventHandler.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Calculate a location message for the event * */ private String getLocation(ValidationEvent event) { StringBuffer msg = new StringBuffer(); ValidationEventLocator locator = event.getLocator(); if( locator != null ) { URL url = locator.getURL(); Object obj = locator.getObject(); Node node = locator.getNode(); int line = locator.getLineNumber(); if( url!=null || line!=-1 ) { msg.append( "line " + line ); if( url!=null ) msg.append( " of " + url ); } else if( obj != null ) { msg.append( " obj: " + obj.toString() ); } else if( node != null ) { msg.append( " node: " + node.toString() ); } } else { msg.append( Messages.format( Messages.LOCATION_UNAVAILABLE ) ); } return msg.toString(); }
Example 9
Source File: DefaultValidationEventHandler.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Calculate a location message for the event * */ private String getLocation(ValidationEvent event) { StringBuffer msg = new StringBuffer(); ValidationEventLocator locator = event.getLocator(); if( locator != null ) { URL url = locator.getURL(); Object obj = locator.getObject(); Node node = locator.getNode(); int line = locator.getLineNumber(); if( url!=null || line!=-1 ) { msg.append( "line " + line ); if( url!=null ) msg.append( " of " + url ); } else if( obj != null ) { msg.append( " obj: " + obj.toString() ); } else if( node != null ) { msg.append( " node: " + node.toString() ); } } else { msg.append( Messages.format( Messages.LOCATION_UNAVAILABLE ) ); } return msg.toString(); }
Example 10
Source File: JaxbCfgProcessor.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 11
Source File: DefaultValidationEventHandler.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Calculate a location message for the event * */ private String getLocation(ValidationEvent event) { StringBuffer msg = new StringBuffer(); ValidationEventLocator locator = event.getLocator(); if( locator != null ) { URL url = locator.getURL(); Object obj = locator.getObject(); Node node = locator.getNode(); int line = locator.getLineNumber(); if( url!=null || line!=-1 ) { msg.append( "line " + line ); if( url!=null ) msg.append( " of " + url ); } else if( obj != null ) { msg.append( " obj: " + obj.toString() ); } else if( node != null ) { msg.append( " node: " + node.toString() ); } } else { msg.append( Messages.format( Messages.LOCATION_UNAVAILABLE ) ); } return msg.toString(); }
Example 12
Source File: DefaultValidationEventHandler.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Calculate a location message for the event * */ private String getLocation(ValidationEvent event) { StringBuffer msg = new StringBuffer(); ValidationEventLocator locator = event.getLocator(); if( locator != null ) { URL url = locator.getURL(); Object obj = locator.getObject(); Node node = locator.getNode(); int line = locator.getLineNumber(); if( url!=null || line!=-1 ) { msg.append( "line " + line ); if( url!=null ) msg.append( " of " + url ); } else if( obj != null ) { msg.append( " obj: " + obj.toString() ); } else if( node != null ) { msg.append( " node: " + node.toString() ); } } else { msg.append( Messages.format( Messages.LOCATION_UNAVAILABLE ) ); } return msg.toString(); }
Example 13
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 14
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 15
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 16
Source File: DefaultValidationEventHandler.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Calculate a location message for the event * */ private String getLocation(ValidationEvent event) { StringBuffer msg = new StringBuffer(); ValidationEventLocator locator = event.getLocator(); if( locator != null ) { URL url = locator.getURL(); Object obj = locator.getObject(); Node node = locator.getNode(); int line = locator.getLineNumber(); if( url!=null || line!=-1 ) { msg.append( "line " + line ); if( url!=null ) msg.append( " of " + url ); } else if( obj != null ) { msg.append( " obj: " + obj.toString() ); } else if( node != null ) { msg.append( " node: " + node.toString() ); } } else { msg.append( Messages.format( Messages.LOCATION_UNAVAILABLE ) ); } return msg.toString(); }
Example 17
Source File: DefaultValidationEventHandler.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Calculate a location message for the event * */ private String getLocation(ValidationEvent event) { StringBuffer msg = new StringBuffer(); ValidationEventLocator locator = event.getLocator(); if( locator != null ) { URL url = locator.getURL(); Object obj = locator.getObject(); Node node = locator.getNode(); int line = locator.getLineNumber(); if( url!=null || line!=-1 ) { msg.append( "line " + line ); if( url!=null ) msg.append( " of " + url ); } else if( obj != null ) { msg.append( " obj: " + obj.toString() ); } else if( node != null ) { msg.append( " node: " + node.toString() ); } } else { msg.append( Messages.format( Messages.LOCATION_UNAVAILABLE ) ); } return msg.toString(); }
Example 18
Source File: XmlBindingTool.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
private String getLocationDescription(ValidationEvent event) { ValidationEventLocator locator = event.getLocator(); if (locator == null) { return "XML with location unavailable"; } else { StringBuffer msg = new StringBuffer(); URL url = locator.getURL(); Object obj = locator.getObject(); Node node = locator.getNode(); int line = locator.getLineNumber(); if (url == null && line == -1) { if (obj != null) { msg.append("obj: "); msg.append(obj); } else if (node != null) { msg.append("node: "); msg.append(node); } } else { msg.append("line "); msg.append(line); if (url != null) { msg.append(" of "); msg.append(url); } } return msg.toString(); } }
Example 19
Source File: XmlBindingTool.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
private String getLocationDescription(ValidationEvent event) { ValidationEventLocator locator = event.getLocator(); if (locator == null) { return "XML with location unavailable"; } else { StringBuffer msg = new StringBuffer(); URL url = locator.getURL(); Object obj = locator.getObject(); Node node = locator.getNode(); int line = locator.getLineNumber(); if (url == null && line == -1) { if (obj != null) { msg.append("obj: "); msg.append(obj); } else if (node != null) { msg.append("node: "); msg.append(node); } } else { msg.append("line "); msg.append(line); if (url != null) { msg.append(" of "); msg.append(url); } } return msg.toString(); } }
Example 20
Source File: DefaultValidationEventHandler.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Calculate a location message for the event * */ private String getLocation(ValidationEvent event) { StringBuffer msg = new StringBuffer(); ValidationEventLocator locator = event.getLocator(); if( locator != null ) { URL url = locator.getURL(); Object obj = locator.getObject(); Node node = locator.getNode(); int line = locator.getLineNumber(); if( url!=null || line!=-1 ) { msg.append( "line " + line ); if( url!=null ) msg.append( " of " + url ); } else if( obj != null ) { msg.append( " obj: " + obj.toString() ); } else if( node != null ) { msg.append( " node: " + node.toString() ); } } else { msg.append( Messages.format( Messages.LOCATION_UNAVAILABLE ) ); } return msg.toString(); }