FileDocCategorySizeDatePackage
ValidationEventLocatorImpl.javaAPI DocJava SE 6 API7331Tue Jun 10 00:27:04 BST 2008javax.xml.bind.helpers

ValidationEventLocatorImpl

public class ValidationEventLocatorImpl extends Object implements ValidationEventLocator
Default implementation of the ValidationEventLocator interface.

JAXB providers are allowed to use whatever class that implements the ValidationEventLocator interface. This class is just provided for a convenience.

author
  • Kohsuke Kawaguchi, Sun Microsystems, Inc.
version
$Revision: 1.1 $
see
javax.xml.bind.Validator
see
javax.xml.bind.ValidationEventHandler
see
javax.xml.bind.ValidationEvent
see
javax.xml.bind.ValidationEventLocator
since
JAXB1.0

Fields Summary
private URL
url
private int
offset
private int
lineNumber
private int
columnNumber
private Object
object
private Node
node
Constructors Summary
public ValidationEventLocatorImpl()
Creates an object with all fields unavailable.

    
public ValidationEventLocatorImpl(Locator loc)
Constructs an object from an org.xml.sax.Locator. The object's ColumnNumber, LineNumber, and URL become available from the values returned by the locator's getColumnNumber(), getLineNumber(), and getSystemId() methods respectively. Node, Object, and Offset are not available.

param
loc the SAX Locator object that will be used to populate this event locator.
throws
IllegalArgumentException if the Locator is null

        if( loc == null ) {
            throw new IllegalArgumentException(
                Messages.format( Messages.MUST_NOT_BE_NULL, "loc" ) );
        }

        this.url = toURL(loc.getSystemId());
        this.columnNumber = loc.getColumnNumber();
        this.lineNumber = loc.getLineNumber();
    
public ValidationEventLocatorImpl(SAXParseException e)
Constructs an object from the location information of a SAXParseException. The object's ColumnNumber, LineNumber, and URL become available from the values returned by the locator's getColumnNumber(), getLineNumber(), and getSystemId() methods respectively. Node, Object, and Offset are not available.

param
e the SAXParseException object that will be used to populate this event locator.
throws
IllegalArgumentException if the SAXParseException is null

        if( e == null ) {
            throw new IllegalArgumentException(
                Messages.format( Messages.MUST_NOT_BE_NULL, "e" ) );
        }

        this.url = toURL(e.getSystemId());
        this.columnNumber = e.getColumnNumber();
        this.lineNumber = e.getLineNumber();
    
public ValidationEventLocatorImpl(Node _node)
Constructs an object that points to a DOM Node. The object's Node becomes available. ColumnNumber, LineNumber, Object, Offset, and URL are not available.

param
_node the DOM Node object that will be used to populate this event locator.
throws
IllegalArgumentException if the Node is null

        if( _node == null ) {
            throw new IllegalArgumentException(
                Messages.format( Messages.MUST_NOT_BE_NULL, "_node" ) );
        }

        this.node = _node;
    
public ValidationEventLocatorImpl(Object _object)
Constructs an object that points to a JAXB content object. The object's Object becomes available. ColumnNumber, LineNumber, Node, Offset, and URL are not available.

param
_object the Object that will be used to populate this event locator.
throws
IllegalArgumentException if the Object is null

        if( _object == null ) {
            throw new IllegalArgumentException(
                Messages.format( Messages.MUST_NOT_BE_NULL, "_object" ) );
        }

        this.object = _object;
    
Methods Summary
public intgetColumnNumber()

see
javax.xml.bind.ValidationEventLocator#getColumnNumber()

        return columnNumber;
    
public intgetLineNumber()

see
javax.xml.bind.ValidationEventLocator#getLineNumber()

        return lineNumber;
    
public org.w3c.dom.NodegetNode()

see
javax.xml.bind.ValidationEventLocator#getNode()

        return node;
    
public java.lang.ObjectgetObject()

see
javax.xml.bind.ValidationEventLocator#getObject()

        return object;
    
public intgetOffset()

see
javax.xml.bind.ValidationEventLocator#getOffset()

        return offset;
    
public java.net.URLgetURL()

see
javax.xml.bind.ValidationEventLocator#getURL()

    
    
           
       
        return url;
    
public voidsetColumnNumber(int _columnNumber)
Set the columnNumber field on this event locator.

param
_columnNumber the column number

        this.columnNumber = _columnNumber;
    
public voidsetLineNumber(int _lineNumber)
Set the lineNumber field on this event locator.

param
_lineNumber the line number

        this.lineNumber = _lineNumber;
    
public voidsetNode(org.w3c.dom.Node _node)
Set the Node field on this event locator. Null values are allowed.

param
_node the Node

        this.node = _node;
    
public voidsetObject(java.lang.Object _object)
Set the Object field on this event locator. Null values are allowed.

param
_object the java content object

        this.object = _object;
    
public voidsetOffset(int _offset)
Set the offset field on this event locator.

param
_offset the offset

        this.offset = _offset;
    
public voidsetURL(java.net.URL _url)
Set the URL field on this event locator. Null values are allowed.

param
_url the url

        this.url = _url;
    
public java.lang.StringtoString()
Returns a string representation of this object in a format helpful to debugging.

see
Object#equals(Object)

        return MessageFormat.format("[node={0},object={1},url={2},line={3},col={4},offset={5}]",
            getNode(),
            getObject(),
            getURL(),
            String.valueOf(getLineNumber()),
            String.valueOf(getColumnNumber()),
            String.valueOf(getOffset()));
    
private static java.net.URLtoURL(java.lang.String systemId)
Converts a system ID to an URL object.

        try {
            return new URL(systemId);
        } catch( MalformedURLException e ) {
            // TODO: how should we handle system id here?
            return null;    // for now
        }