Refine search
@Override public boolean handleEvent(ValidationEvent validationEvent) { ValidationEventLocator locator = validationEvent.getLocator(); lineNumber = locator.getLineNumber(); columnNumber = locator.getColumnNumber(); message = validationEvent.getMessage(); return false; }
public boolean handleEvent(ValidationEvent ve) { if (ve.getSeverity()==ValidationEvent.FATAL_ERROR || ve.getSeverity()==ValidationEvent.ERROR){ ValidationEventLocator locator = ve.getLocator(); if (locator.getColumnNumber()>-1) { log.warn("Column is " + locator.getColumnNumber() + " at line number " + locator.getLineNumber()); if (locator.getNode()!=null) { Node node = locator.getNode(); log.warn("troublesome node: " + XmlUtils.w3CDomNodeToString(node)); if (node.getParentNode()!=null) { if (locator.getOffset()>-1) { log.warn("At offset " + locator.getOffset()); if (locator.getObject()!=null ) { log.warn(locator.getObject().getClass().getName());
StringBuffer msg = new StringBuffer(); ValidationEventLocator locator = event.getLocator(); URL url = locator.getURL(); Object obj = locator.getObject(); Node node = locator.getNode(); int line = locator.getLineNumber();
public Snapshot(LocatorEx loc) { columnNumber = loc.getColumnNumber(); lineNumber = loc.getLineNumber(); systemId = loc.getSystemId(); publicId = loc.getPublicId(); ValidationEventLocator vel = loc.getLocation(); offset = vel.getOffset(); url = vel.getURL(); object = vel.getObject(); node = vel.getNode(); }
@Override public boolean handleEvent(final ValidationEvent event) { Logger.error( this, "JAXB error: \"%s\" at '%s' [%d:%d]: %[dom]s", event.getMessage(), event.getLocator().getURL(), event.getLocator().getLineNumber(), event.getLocator().getColumnNumber(), event.getLocator().getNode() ); return false; }
private static void appendLocator(StringBuilder sb, ValidationEventLocator loc) { if (loc.getURL() == null && loc.getLineNumber() < 0 && loc.getColumnNumber() < 0 && loc.getOffset() < 0 && loc.getNode() == null && loc.getObject() == null) { return; if (loc.getURL() != null) { sb.append(loc.getURL().toExternalForm()); first = false; if (loc.getLineNumber() >= 0) { if (!first) { sb.append(", "); sb.append("line ").append(loc.getLineNumber()); first = false; if (loc.getColumnNumber() >= 0) { if (!first) { sb.append(", "); sb.append("column ").append(loc.getColumnNumber()); first = false; if (loc.getOffset() >= 0) { if (!first) { sb.append(", ");
private String getLogEntry(ValidationEvent event) { StringBuilder sb = new StringBuilder(); sb.append(event.getMessage()); sb.append(event.getLinkedException()); Object failedObject = event.getLocator().getObject(); if(failedObject != null) { sb.append(failedObject.toString()); } return sb.toString(); } }
protected boolean processEvent( ValidationEvent ve, ValidationEventLocator vel) { logger.warn(String.format( "%s:%d:%d: %s", dumpUri, vel.getLineNumber(), vel.getColumnNumber(), ve.getMessage())); return true; }
@Nullable @OverrideOnDemand protected String getLocationResourceID (@Nullable final ValidationEventLocator aLocator) { if (aLocator != null) { // Source file found? final URL aURL = aLocator.getURL (); if (aURL != null) return aURL.toString (); // Source object found? final Object aObj = aLocator.getObject (); if (aObj != null) return "obj: " + aObj.toString (); // Source node found? final Node aNode = aLocator.getNode (); if (aNode != null) return XMLWriter.getXMLString (aNode); } return null; }
import javax.xml.bind.ValidationEvent; import javax.xml.bind.ValidationEventHandler; class XopAwareUnmarshallingValidationEventHandler extends XopAwareValidationEventHandler { private static final String XOP_INCLUDE = "xop:Include"; XopAwareUnmarshallingValidationEventHandler(final ValidationEventHandler handler) { super(handler); } @Override boolean isXopEvent(final ValidationEvent validationEvent) { final ValidationEventLocator locator = validationEvent.getLocator(); return locator != null && locator.getNode() != null && locator.getNode().getFirstChild() != null && XOP_INCLUDE.equals(locator.getNode().getFirstChild().getNodeName()); } }
import javax.xml.bind.*; public class CommodityValidator extends Marshaller.Listener implements ValidationEventHandler { private Order order; @Override public void beforeMarshal(Object source) { if(source instanceof Order) { // If we are marshalling an Order Store It order = (Order) source; } } @Override public boolean handleEvent(ValidationEvent event) { if(event.getLocator().getObject() instanceof Commodity) { // If the Error was Caused by a Commodity Object Remove it from the Order order.setCommodity(null); return true; } return false; } }
@Nullable @OverrideOnDemand protected String getErrorFieldName (@Nullable final ValidationEventLocator aLocator) { if (aLocator != null) { // Source object found? final Object aObj = aLocator.getObject (); if (aObj != null) return "obj: " + aObj.toString (); // Source node found? final Node aNode = aLocator.getNode (); if (aNode != null) return XMLWriter.getNodeAsString (aNode); } return null; }
public DefaultListEntryObjectLocator(final ObjectLocator parentLocator, final int index) { super(parentLocator, parentLocator.getObject()); this.index = index; }
@Nullable @OverrideOnDemand protected String getLocationResourceID (@Nullable final ValidationEventLocator aLocator) { if (aLocator != null) { // Source file found? final URL aURL = aLocator.getURL (); if (aURL != null) return aURL.toString (); } return null; }
public Snapshot(LocatorEx loc) { columnNumber = loc.getColumnNumber(); lineNumber = loc.getLineNumber(); systemId = loc.getSystemId(); publicId = loc.getPublicId(); ValidationEventLocator vel = loc.getLocation(); offset = vel.getOffset(); url = vel.getURL(); object = vel.getObject(); node = vel.getNode(); }
protected boolean processEvent( ValidationEvent ve, ValidationEventLocator vel) { logger.warn(String.format( "%s:%d:%d: %s", dumpUri, vel.getLineNumber(), vel.getColumnNumber(), ve.getMessage())); return true; }
public DefaultFieldObjectLocator(final ObjectLocator locator, final String fieldName) { super(locator.getParentLocator(), locator.getObject()); this.fieldName = fieldName; }
@Override public boolean handleEvent(ValidationEvent validationEvent) { ValidationEventLocator locator = validationEvent.getLocator(); lineNumber = locator.getLineNumber(); columnNumber = locator.getColumnNumber(); message = validationEvent.getMessage(); return false; }
public boolean handleEvent(final ValidationEvent event) { logger.warning("JSL invalid per XSD, details: " + ("\nMESSAGE: " + event.getMessage()) + "\nSEVERITY: " + event.getSeverity() + "\nLINKED EXC: " + event.getLinkedException() + "\nLOCATOR INFO:\n------------" + "\n COLUMN NUMBER: " + event.getLocator().getColumnNumber() + "\n LINE NUMBER: " + event.getLocator().getLineNumber() + "\n OFFSET: " + event.getLocator().getOffset() + "\n CLASS: " + event.getLocator().getClass() + "\n NODE: " + event.getLocator().getNode() + "\n OBJECT: " + event.getLocator().getObject() + "\n URL: " + event.getLocator().getURL()); eventOccurred = true; // Allow more parsing feedback return true; }
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 ").append(line); if(url != null) { msg.append(" of ").append(url); } } else { if (obj != null) { msg.append(" obj: ").append(obj.toString()); } else if(node != null) { msg.append(" node: ").append(node.toString()); } } } else { msg.append("unavailable"); } return msg.toString(); }