# com.bea.xml
XmlError Class

public class XmlError
extends `Object`
implements `Serializable`

Represents a message at a specific XML location.

The message can be an error, warning, or simple information, and it may optionally be associated with a specific location in an XML document. The class includes methods for extracting the location as a line number, XmlCursor, or XmlObject, as well as for obtaining and message and severity of the error.

Related Topics

``XmlOptions.setErrorListener(Collection)``
``XmlException``

Hierarchy
  `Object`
  `XmlError`

All Implemented Interfaces
  `Serializable`

## Field Summary

`public static final int` | `SEVERITY_ERROR` An error.
`public static final int` | `SEVERITY_INFO` An informational message.
`public static final int` | `SEVERITY_WARNING` A warning.

## Constructor Summary

XmlError(`XmlError` src) Copy constructor.

## Method Summary

`public static `XmlError`` | `forCursor`(`String` message, `XmlCursor` cursor) Returns an XmlError for the given message, located at the XmlCursor, with `XmlError.SEVERITY_ERROR```.
`public static `XmlError`` | `forCursor`(`String` message, int severity, `XmlCursor` cursor) Returns an XmlError for the given message, with the given severity, located at the XmlCursor.
`public static `XmlError`` | `forLocation`(`String` message, `String` sourceName, int line, int column, int offset) Returns an XmlError for the given message, located at a specific point in the given file and `XmlError.SEVERITY_ERROR```.
`public static `XmlError`` | `forLocation`(`String` message, int severity, `String` sourceName, int line, int column, int offset) Returns an XmlError for the given message, with the given severity, located at a specific point in the given file.
`public static `XmlError`` | `forLocationAndCursor`(`String` message, int severity, `String` sourceName, int line, int column, int offset, `XmlCursor` cursor) Returns an XmlError for the given message, with the given severity, located at the given physcial location and XmlCursor.
`protected static `String`` | `formattedFileName`(`String` rawString, `URI` base) Tries to produce a nicely formatted filename from the given string.
`public static `XmlError`` | `forMessage`(`String` message) Returns an XmlError for the given message, with no location and `XmlError.SEVERITY_ERROR```.
`public static `XmlError`` | `forMessage`(`String` message, int severity) Returns an XmlError for the given message, with no location and the given severity.
`public static `XmlError`` | `forObject`(`String` message, `XmlObject` xobj) Returns an XmlError for the given message, located at the XmlObject, with `XmlError.SEVERITY_ERROR```.
`public static `XmlError`` | `forObject`(`String` message, int severity, `XmlObject` xobj) Returns an XmlError for the given message, with the given severity, located at the XmlObject.
`public static `XmlError`` | `forSource`(`String` message, `String` sourceName) Returns an XmlError for the given message, located in the given file and `XmlError.SEVERITY_ERROR```.
`public static `XmlError`` | `forSource`(`String` message, int severity, `String` sourceName) Returns an XmlError for the given message, with the given severity, located in the given file.
`public int` | `getColumn`() Returns the column number of the error, if available, -1 if not.
`public `XmlCursor`` | `getCursorLocation`() Returns a location of the error as an `XmlCursor```, null if not available.
`public int` | `getLine`() Returns the line number of the error, if available, -1 if not.
`public `Object`` | `getLocation`(`Object` type) Returns a location object of the given type.
`public `String`` | `getMessage`() Returns the error message without location information.
`public `XmlObject`` | `getObjectLocation`() Returns a location of the error as an `XmlObject```, null if not available.
`public int` | `getOffset`() Returns the file character offset of the error, if available, -1 if not.
`public int` | `getSeverity`() Returns the severity.
`public `String`` | `getSourceName`() Returns the URL (or other name) of the file with the error, if available.
`public `String`` | `toString`() Produces a standard string for the error message, complete with filename and location offsets if available.
`public `String`` | `toString`(`URI` base) Produces a standard string with the error message.

Methods from class `java.lang.`Object``
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Detail

### SEVERITY_ERROR

    public static final int SEVERITY_ERROR

  An error. See `XmlError.getSeverity()```.

### SEVERITY_INFO

    public static final int SEVERITY_INFO

  An informational message. See `XmlError.getSeverity()```.

### SEVERITY_WARNING

    public static final int SEVERITY_WARNING

  A warning. See `XmlError.getSeverity()```.

## Constructor Detail

### XmlError

    public XmlError(XmlError src)

  Copy constructor.

## Method Detail

### forCursor(String, XmlCursor) Method

    public static XmlError forCursor(String message,
                                     XmlCursor cursor)

Returns an XmlError for the given message, located at the XmlCursor, with `XmlError.SEVERITY_ERROR```.

#### Parameters

message
  the error message

cursor
  the XmlCursor representing the location of the error

### forCursor(String, int, XmlCursor) Method

    public static XmlError forCursor(String message,
                                     int severity,
                                     XmlCursor cursor)

Returns an XmlError for the given message, with the given severity, located at the XmlCursor.

#### Parameters

message
  the error message

severity
  the severity (`XmlError.SEVERITY_ERROR```, `XmlError.SEVERITY_WARNING```, or `XmlError.SEVERITY_INFO```)

cursor
  the XmlCursor representing the location of the error

### forLocation(String, String, int, int, int) Method

    public static XmlError forLocation(String message,
                                       String sourceName,
                                       int line,
                                       int column,
                                       int offset)

Returns an XmlError for the given message, located at a specific point in the given file and `XmlError.SEVERITY_ERROR```.

#### Parameters

message
  the error message

sourceName
  the URL or other name for the file

line
  the 1-based line number, or -1 if not known

column
  the 1-based column number, or -1 if not known

offset
  the 0-base file character offset, or -1 if not known

### forLocation(String, int, String, int, int, int) Method

    public static XmlError forLocation(String message,
                                       int severity,
                                       String sourceName,
                                       int line,
                                       int column,
                                       int offset)

Returns an XmlError for the given message, with the given severity, located at a specific point in the given file.

#### Parameters

message
  the error message

severity
  the severity (`XmlError.SEVERITY_ERROR```, `XmlError.SEVERITY_WARNING```, or `XmlError.SEVERITY_INFO```)

sourceName
  the URL or other name for the file

line
  the 1-based line number, or -1 if not known

column
  the 1-based column number, or -1 if not known

offset
  the 0-base file character offset, or -1 if not known

### forLocationAndCursor(String, int, String, int, int, int, XmlCursor) Method

    public static XmlError forLocationAndCursor(String message,
                                                int severity,
                                                String sourceName,
                                                int line,
                                                int column,
                                                int offset,
                                                XmlCursor cursor)

Returns an XmlError for the given message, with the given severity, located at the given physcial location and XmlCursor.

#### Parameters

message
  the error message

severity
  the severity (`XmlError.SEVERITY_ERROR```, `XmlError.SEVERITY_WARNING```, or `XmlError.SEVERITY_INFO```)

sourceName
  the URL or other name for the file

line
  the 1-based line number, or -1 if not known

column
  the 1-based column number, or -1 if not known

offset
  the 0-base file character offset, or -1 if not known

cursor
  the XmlCursor representing the location of the error

### formattedFileName(String, URI) Method

    protected static String formattedFileName(String rawString,
                                              URI base)

Tries to produce a nicely formatted filename from the given string.

### forMessage(String) Method

    public static XmlError forMessage(String message)

Returns an XmlError for the given message, with no location and `XmlError.SEVERITY_ERROR```.

#### Parameters

message
  the error message

### forMessage(String, int) Method

    public static XmlError forMessage(String message,
                                      int severity)

Returns an XmlError for the given message, with no location and the given severity.

#### Parameters

message
  the error message

severity
  the severity (`XmlError.SEVERITY_ERROR```, `XmlError.SEVERITY_WARNING```, or `XmlError.SEVERITY_INFO```)

### forObject(String, XmlObject) Method

    public static XmlError forObject(String message,
                                     XmlObject xobj)

Returns an XmlError for the given message, located at the XmlObject, with `XmlError.SEVERITY_ERROR```.

#### Parameters

message
  the error message

xobj
  the XmlObject representing the location of the error

### forObject(String, int, XmlObject) Method

    public static XmlError forObject(String message,
                                     int severity,
                                     XmlObject xobj)

Returns an XmlError for the given message, with the given severity, located at the XmlObject.

#### Parameters

message
  the error message

severity
  the severity (`XmlError.SEVERITY_ERROR```, `XmlError.SEVERITY_WARNING```, or `XmlError.SEVERITY_INFO```)

xobj
  the XmlObject representing the location of the error

### forSource(String, String) Method

    public static XmlError forSource(String message,
                                     String sourceName)

Returns an XmlError for the given message, located in the given file and `XmlError.SEVERITY_ERROR```.

#### Parameters

message
  the error message

sourceName
  the URL or other name for the file

### forSource(String, int, String) Method

    public static XmlError forSource(String message,
                                     int severity,
                                     String sourceName)

Returns an XmlError for the given message, with the given severity, located in the given file.

#### Parameters

message
  the error message

severity
  the severity (`XmlError.SEVERITY_ERROR```, `XmlError.SEVERITY_WARNING```, or `XmlError.SEVERITY_INFO```)

sourceName
  the URL or other name for the file

### getColumn() Method

    public int getColumn()

Returns the column number of the error, if available, -1 if not.

### getCursorLocation() Method

    public XmlCursor getCursorLocation()

Returns a location of the error as an `XmlCursor```, null if not available.

### getLine() Method

    public int getLine()

Returns the line number of the error, if available, -1 if not.

### getLocation(Object) Method

    public Object getLocation(Object type)

Returns a location object of the given type. XmlCursor.class and XmlObject.class can be passed, for example. Null if not available.

### getMessage() Method

    public String getMessage()

Returns the error message without location information.

### getObjectLocation() Method

    public XmlObject getObjectLocation()

Returns a location of the error as an `XmlObject```, null if not available.

### getOffset() Method

    public int getOffset()

Returns the file character offset of the error, if available, -1 if not.

### getSeverity() Method

    public int getSeverity()

Returns the severity. Either `XmlError.SEVERITY_ERROR```, `XmlError.SEVERITY_WARNING```, or `XmlError.SEVERITY_INFO```.

### getSourceName() Method

    public String getSourceName()

Returns the URL (or other name) of the file with the error, if available.

### toString() Method

    public String toString()

Produces a standard string for the error message, complete with filename and location offsets if available.

Overrides
  `Object.toString()`

### toString(URI) Method

    public String toString(URI base)

Produces a standard string with the error message. If a non-null URI is supplied, source names are relativized against the given URI.