Java Code Examples for javax.xml.bind.ValidationEventLocator#getNode()

The following examples show how to use javax.xml.bind.ValidationEventLocator#getNode() . 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: 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 3
Source File: DefaultValidationEventHandler.java    From openjdk-8-source 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 4
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 5
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 6
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 7
Source File: DefaultValidationEventHandler.java    From openjdk-jdk9 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 8
Source File: LocatorEx.java    From openjdk-jdk9 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-jdk8u-backup 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-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 11
Source File: DefaultValidationEventHandler.java    From jdk1.8-source-analysis 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 12
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 13
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();
	Node  node = vel.getNode();

	String name = node!=null?node.getLocalName():"null";
	logger.error(  "node  : {}.{}: {}", name, vel.getOffset(), msg );
	return false;
}
 
Example 14
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 15
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 16
Source File: LocatorEx.java    From jdk8u60 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 17
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 18
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 19
Source File: DefaultValidationEventHandler.java    From TencentKona-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 20
Source File: LocatorEx.java    From TencentKona-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();
}