Package org.apache.xmlbeans
Class XmlError
java.lang.Object
org.apache.xmlbeans.XmlError
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
XmlValidationError
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.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
An error.static final int
An informational message.static final int
A warning. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic XmlError
Returns an XmlError for the given message, with the given severity, located at the XmlCursor.static XmlError
Returns an XmlError for the given message, with the given severity, located at the XmlCursor.static XmlError
Returns an XmlError for the given message, located at the XmlCursor, withSEVERITY_ERROR
.static XmlError
Returns an XmlError for the given message, located at the XmlCursor, withSEVERITY_ERROR
.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.static XmlError
forLocation
(String code, Object[] args, 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.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 andSEVERITY_ERROR
.static XmlError
forLocation
(String message, String sourceName, Location location) Returns an XmlError for the given message, located at a specific point in the given file andSEVERITY_ERROR
.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.static String
formattedMessage
(String code, Object[] args) Tries to format a message using the error code.static XmlError
forMessage
(String message) Returns an XmlError for the given message, with no location andSEVERITY_ERROR
.static XmlError
forMessage
(String message, int severity) Returns an XmlError for the given message, with no location and the given severity.static XmlError
forMessage
(String code, Object[] args) Returns an XmlError for the given message, with no location and the given severity.static XmlError
forMessage
(String code, Object[] args, int severity) Returns an XmlError for the given message, with no location and the given severity.static XmlError
Returns an XmlError for the given message, with the given severity, located at the XmlObject.static XmlError
Returns an XmlError for the given message, with the given severity, located at the XmlObject.static XmlError
Returns an XmlError for the given message, located at the XmlObject, withSEVERITY_ERROR
.static XmlError
Returns an XmlError for the given message, located at the XmlObject, withSEVERITY_ERROR
.static XmlError
Returns an XmlError for the given message, with the given severity, located in the given file.static XmlError
Returns an XmlError for the given message, with the given severity, located in the given file.static XmlError
Returns an XmlError for the given message, located in the given file andSEVERITY_ERROR
.int
Returns the column number of the error, if available, -1 if not.Returns a location of the error as anXmlCursor
, null if not available.Returns the error code or null.int
getLine()
Returns the line number of the error, if available, -1 if not.getLocation
(Object type) Returns a location object of the given type.Returns the error message without location information.Returns a location of the error as anXmlObject
, null if not available.int
Returns the file character offset of the error, if available, -1 if not.int
Returns the severity.Returns the URL (or other name) of the file with the error, if available.static String
severityAsString
(int severity) toString()
Produces a standard string for the error message, complete with filename and location offsets if available.Produces a standard string with the error message.
-
Field Details
-
SEVERITY_ERROR
public static final int SEVERITY_ERRORAn error. SeegetSeverity()
.- See Also:
-
SEVERITY_WARNING
public static final int SEVERITY_WARNINGA warning. SeegetSeverity()
.- See Also:
-
SEVERITY_INFO
public static final int SEVERITY_INFOAn informational message. SeegetSeverity()
.- See Also:
-
-
Constructor Details
-
XmlError
Copy constructor.- Parameters:
src
- The original XmlError to copy.
-
-
Method Details
-
forMessage
Returns an XmlError for the given message, with no location andSEVERITY_ERROR
.- Parameters:
message
- the error message
-
forMessage
Returns an XmlError for the given message, with no location and the given severity.- Parameters:
message
- the error messageseverity
- the severity (SEVERITY_ERROR
,SEVERITY_WARNING
, orSEVERITY_INFO
)
-
forMessage
Returns an XmlError for the given message, with no location and the given severity.- Parameters:
code
- the error codeargs
- the arguments to use in formatting the error message
-
forMessage
Returns an XmlError for the given message, with no location and the given severity.- Parameters:
code
- the error codeargs
- the arguments to use in formatting the error messageseverity
- the severity (SEVERITY_ERROR
,SEVERITY_WARNING
, orSEVERITY_INFO
)
-
forSource
Returns an XmlError for the given message, located in the given file andSEVERITY_ERROR
.- Parameters:
message
- the error messagesourceName
- the URL or other name for the file
-
forSource
Returns an XmlError for the given message, with the given severity, located in the given file.- Parameters:
message
- the error messageseverity
- the severity (SEVERITY_ERROR
,SEVERITY_WARNING
, orSEVERITY_INFO
)sourceName
- the URL or other name for the file
-
forSource
Returns an XmlError for the given message, with the given severity, located in the given file.- Parameters:
code
- the error codeargs
- the arguments to use in formatting the error messageseverity
- the severity (SEVERITY_ERROR
,SEVERITY_WARNING
, orSEVERITY_INFO
)sourceName
- the URL or other name for the file
-
forLocation
Returns an XmlError for the given message, located at a specific point in the given file andSEVERITY_ERROR
.- Parameters:
message
- the error messagesourceName
- the URL or other name for the filelocation
- the location from an xml stream
-
forLocation
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 andSEVERITY_ERROR
.- Parameters:
message
- the error messagesourceName
- the URL or other name for the fileline
- the 1-based line number, or -1 if not knowncolumn
- the 1-based column number, or -1 if not knownoffset
- the 0-base file character offset, or -1 if not known
-
forLocation
public static XmlError forLocation(String code, Object[] args, 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:
code
- the error codeargs
- the arguments to use in formatting the error messageseverity
- the severity (SEVERITY_ERROR
,SEVERITY_WARNING
, orSEVERITY_INFO
)sourceName
- the URL or other name for the fileline
- the 1-based line number, or -1 if not knowncolumn
- the 1-based column number, or -1 if not knownoffset
- the 0-base file character offset, or -1 if not known
-
forLocation
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 messageseverity
- the severity (SEVERITY_ERROR
,SEVERITY_WARNING
, orSEVERITY_INFO
)sourceName
- the URL or other name for the fileline
- the 1-based line number, or -1 if not knowncolumn
- the 1-based column number, or -1 if not knownoffset
- the 0-base file character offset, or -1 if not known
-
forLocationAndCursor
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 messageseverity
- the severity (SEVERITY_ERROR
,SEVERITY_WARNING
, orSEVERITY_INFO
)sourceName
- the URL or other name for the fileline
- the 1-based line number, or -1 if not knowncolumn
- the 1-based column number, or -1 if not knownoffset
- the 0-base file character offset, or -1 if not knowncursor
- the XmlCursor representing the location of the error
-
forObject
Returns an XmlError for the given message, located at the XmlObject, withSEVERITY_ERROR
.- Parameters:
message
- the error messagexobj
- the XmlObject representing the location of the error
-
forObject
Returns an XmlError for the given message, located at the XmlObject, withSEVERITY_ERROR
.- Parameters:
code
- the error codeargs
- the arguments to use in formatting the error messagexobj
- the XmlObject representing the location of the error
-
forObject
Returns an XmlError for the given message, with the given severity, located at the XmlObject.- Parameters:
message
- the error messageseverity
- the severity (SEVERITY_ERROR
,SEVERITY_WARNING
, orSEVERITY_INFO
)xobj
- the XmlObject representing the location of the error
-
forObject
Returns an XmlError for the given message, with the given severity, located at the XmlObject.- Parameters:
code
- the error codeargs
- the arguments to use in formatting the error messageseverity
- the severity (SEVERITY_ERROR
,SEVERITY_WARNING
, orSEVERITY_INFO
)xobj
- the XmlObject representing the location of the error
-
forCursor
Returns an XmlError for the given message, located at the XmlCursor, withSEVERITY_ERROR
.- Parameters:
message
- the error messagecursor
- the XmlCursor representing the location of the error
-
forCursor
Returns an XmlError for the given message, located at the XmlCursor, withSEVERITY_ERROR
.- Parameters:
code
- the error codeargs
- the arguments to use in formatting the error messagecursor
- the XmlCursor representing the location of the error
-
forCursor
Returns an XmlError for the given message, with the given severity, located at the XmlCursor.- Parameters:
message
- the error messageseverity
- the severity (SEVERITY_ERROR
,SEVERITY_WARNING
, orSEVERITY_INFO
)cursor
- the XmlCursor representing the location of the error
-
forCursor
Returns an XmlError for the given message, with the given severity, located at the XmlCursor.- Parameters:
code
- the error codeargs
- the arguments to use in formatting the error messageseverity
- the severity (SEVERITY_ERROR
,SEVERITY_WARNING
, orSEVERITY_INFO
)cursor
- the XmlCursor representing the location of the error
-
formattedMessage
Tries to format a message using the error code. -
getSeverity
public int getSeverity() -
getMessage
Returns the error message without location information. -
getErrorCode
Returns the error code or null. SeeXmlErrorCodes
. -
getSourceName
Returns the URL (or other name) of the file with the error, if available. -
getLine
public int getLine()Returns the line number of the error, if available, -1 if not. -
getColumn
public int getColumn()Returns the column number of the error, if available, -1 if not. -
getOffset
public int getOffset()Returns the file character offset of the error, if available, -1 if not. -
getLocation
Returns a location object of the given type. XmlCursor.class and XmlObject.class can be passed, for example. Null if not available. -
getCursorLocation
Returns a location of the error as anXmlCursor
, null if not available. -
getObjectLocation
Returns a location of the error as anXmlObject
, null if not available. -
toString
Produces a standard string for the error message, complete with filename and location offsets if available. -
toString
Produces a standard string with the error message. If a non-null URI is supplied, source names are relativized against the given URI. -
severityAsString
-