javax.xml.bind.ValidationEventLocator Java Examples

The following examples show how to use javax.xml.bind.ValidationEventLocator. 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: AbstractValidationEventHandler.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #2
Source File: StAXConnector.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
protected final void handleStartDocument(NamespaceContext nsc) throws SAXException {
    visitor.startDocument(new LocatorEx() {
        public ValidationEventLocator getLocation() {
            return new ValidationEventLocatorImpl(this);
        }
        public int getColumnNumber() {
            return getCurrentLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return getCurrentLocation().getLineNumber();
        }
        public String getPublicId() {
            return getCurrentLocation().getPublicId();
        }
        public String getSystemId() {
            return getCurrentLocation().getSystemId();
        }
    },nsc);
}
 
Example #3
Source File: StAXConnector.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected final void handleStartDocument(NamespaceContext nsc) throws SAXException {
    visitor.startDocument(new LocatorEx() {
        public ValidationEventLocator getLocation() {
            return new ValidationEventLocatorImpl(this);
        }
        public int getColumnNumber() {
            return getCurrentLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return getCurrentLocation().getLineNumber();
        }
        public String getPublicId() {
            return getCurrentLocation().getPublicId();
        }
        public String getSystemId() {
            return getCurrentLocation().getSystemId();
        }
    },nsc);
}
 
Example #4
Source File: ParseXML.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Output parse errors.
 *
 * @param fullResourceName the full resource name
 * @param vec the vec
 * @param xsdURL the xsd URL
 */
private static void outputParseErrors(
        String fullResourceName, ValidationEventCollector vec, URL xsdURL) {
    if (vec.hasEvents()) {

        for (ValidationEvent ve : vec.getEvents()) {
            String msg = ve.getMessage();
            ValidationEventLocator vel = ve.getLocator();

            String message =
                    String.format(
                            "%s %s %s %s %s %d %s %d %s",
                            Localisation.getField(ParseXML.class, "ParseXML.failedToValidate"),
                            fullResourceName,
                            Localisation.getField(ParseXML.class, "ParseXML.usingXSD"),
                            xsdURL.toString(),
                            Localisation.getField(ParseXML.class, "ParseXML.line"),
                            vel.getLineNumber(),
                            Localisation.getField(ParseXML.class, "ParseXML.column"),
                            vel.getColumnNumber(),
                            msg);
            ConsoleManager.getInstance().error(ParseXML.class, message);
        }
    }
}
 
Example #5
Source File: StAXConnector.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected final void handleStartDocument(NamespaceContext nsc) throws SAXException {
    visitor.startDocument(new LocatorEx() {
        public ValidationEventLocator getLocation() {
            return new ValidationEventLocatorImpl(this);
        }
        public int getColumnNumber() {
            return getCurrentLocation().getColumnNumber();
        }
        public int getLineNumber() {
            return getCurrentLocation().getLineNumber();
        }
        public String getPublicId() {
            return getCurrentLocation().getPublicId();
        }
        public String getSystemId() {
            return getCurrentLocation().getSystemId();
        }
    },nsc);
}
 
Example #6
Source File: LocatorEx.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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();
}
 
Example #7
Source File: LocatorEx.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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();
}
 
Example #8
Source File: LocatorEx.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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();
}
 
Example #9
Source File: DefaultValidationEventHandler.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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: LocatorEx.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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();
}
 
Example #11
Source File: XMLTransmitter.java    From sailfish-core with Apache License 2.0 5 votes vote down vote up
@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 #12
Source File: DefaultValidationEventHandler.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * 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: LocatorEx.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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();
}
 
Example #14
Source File: DefaultValidationEventHandler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 #15
Source File: XmlBindingTool.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
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 #16
Source File: DefaultValidationEventHandler.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * 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: LocatorEx.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public ValidationEventLocator getLocation() {
    return this;
}
 
Example #18
Source File: UnmarshallingContext.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected ValidationEventLocator getLocation() {
    return locator.getLocation();
}
 
Example #19
Source File: LocatorExWrapper.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public ValidationEventLocator getLocation() {
    return new ValidationEventLocatorImpl(locator);
}
 
Example #20
Source File: ValidationEventImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public ValidationEventLocator getLocator() {
    return locator;
}
 
Example #21
Source File: ValidationEventImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public ValidationEventLocator getLocator() {
    return locator;
}
 
Example #22
Source File: LocatorExWrapper.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public ValidationEventLocator getLocation() {
    return new ValidationEventLocatorImpl(locator);
}
 
Example #23
Source File: DOMScanner.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public ValidationEventLocator getLocation() {
    return new ValidationEventLocatorImpl(getCurrentLocation());
}
 
Example #24
Source File: LocatorExWrapper.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public ValidationEventLocator getLocation() {
    return new ValidationEventLocatorImpl(locator);
}
 
Example #25
Source File: XMLSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public ValidationEventLocator getCurrentLocation(String fieldName) {
    return new ValidationEventLocatorExImpl(cycleDetectionStack.peek(),fieldName);
}
 
Example #26
Source File: XMLSerializer.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public ValidationEventLocator getCurrentLocation(String fieldName) {
    return new ValidationEventLocatorExImpl(cycleDetectionStack.peek(),fieldName);
}
 
Example #27
Source File: DOMScanner.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public ValidationEventLocator getLocation() {
    return new ValidationEventLocatorImpl(getCurrentLocation());
}
 
Example #28
Source File: UnmarshallingContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected ValidationEventLocator getLocation() {
    return locator.getLocation();
}
 
Example #29
Source File: XMLSerializer.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public ValidationEventLocator getCurrentLocation(String fieldName) {
    return new ValidationEventLocatorExImpl(cycleDetectionStack.peek(),fieldName);
}
 
Example #30
Source File: DOMScanner.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public ValidationEventLocator getLocation() {
    return new ValidationEventLocatorImpl(getCurrentLocation());
}