|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.xmlbeans.XmlError
public class XmlError
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.
XmlOptions.setErrorListener(java.util.Collection)
,
XmlException
,
Serialized FormField Summary | |
---|---|
static int |
SEVERITY_ERROR
An error. |
static int |
SEVERITY_INFO
An informational message. |
static int |
SEVERITY_WARNING
A warning. |
Constructor Summary | |
---|---|
protected |
XmlError(java.lang.String code,
java.lang.Object[] args,
int severity,
javax.xml.stream.Location loc)
|
protected |
XmlError(java.lang.String code,
java.lang.Object[] args,
int severity,
XmlCursor cursor)
|
protected |
XmlError(java.lang.String message,
java.lang.String code,
int severity,
javax.xml.stream.Location loc)
The static factory methods should be used instead of this constructor. |
protected |
XmlError(java.lang.String message,
java.lang.String code,
int severity,
XmlCursor cursor)
The static factory methods should be used instead of this constructor. |
|
XmlError(XmlError src)
Copy constructor. |
Method Summary | |
---|---|
static XmlError |
forCursor(java.lang.String message,
int severity,
XmlCursor cursor)
Returns an XmlError for the given message, with the given severity, located at the XmlCursor. |
static XmlError |
forCursor(java.lang.String code,
java.lang.Object[] args,
int severity,
XmlCursor cursor)
Returns an XmlError for the given message, with the given severity, located at the XmlCursor. |
static XmlError |
forCursor(java.lang.String code,
java.lang.Object[] args,
XmlCursor cursor)
Returns an XmlError for the given message, located at the XmlCursor, with SEVERITY_ERROR . |
static XmlError |
forCursor(java.lang.String message,
XmlCursor cursor)
Returns an XmlError for the given message, located at the XmlCursor, with SEVERITY_ERROR . |
static XmlError |
forLocation(java.lang.String message,
int severity,
java.lang.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(java.lang.String code,
java.lang.Object[] args,
int severity,
java.lang.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(java.lang.String message,
java.lang.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 SEVERITY_ERROR . |
static XmlError |
forLocation(java.lang.String message,
java.lang.String sourceName,
javax.xml.stream.Location location)
Returns an XmlError for the given message, located at a specific point in the given file and SEVERITY_ERROR . |
static XmlError |
forLocationAndCursor(java.lang.String message,
int severity,
java.lang.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 java.lang.String |
formattedFileName(java.lang.String rawString,
java.net.URI base)
Tries to produce a nicely formatted filename from the given string. |
static java.lang.String |
formattedMessage(java.lang.String code,
java.lang.Object[] args)
Tries to format a message using the error code. |
static XmlError |
forMessage(java.lang.String message)
Returns an XmlError for the given message, with no location and SEVERITY_ERROR . |
static XmlError |
forMessage(java.lang.String message,
int severity)
Returns an XmlError for the given message, with no location and the given severity. |
static XmlError |
forMessage(java.lang.String code,
java.lang.Object[] args)
Returns an XmlError for the given message, with no location and the given severity. |
static XmlError |
forMessage(java.lang.String code,
java.lang.Object[] args,
int severity)
Returns an XmlError for the given message, with no location and the given severity. |
static XmlError |
forObject(java.lang.String message,
int severity,
XmlObject xobj)
Returns an XmlError for the given message, with the given severity, located at the XmlObject. |
static XmlError |
forObject(java.lang.String code,
java.lang.Object[] args,
int severity,
XmlObject xobj)
Returns an XmlError for the given message, with the given severity, located at the XmlObject. |
static XmlError |
forObject(java.lang.String code,
java.lang.Object[] args,
XmlObject xobj)
Returns an XmlError for the given message, located at the XmlObject, with SEVERITY_ERROR . |
static XmlError |
forObject(java.lang.String message,
XmlObject xobj)
Returns an XmlError for the given message, located at the XmlObject, with SEVERITY_ERROR . |
static XmlError |
forSource(java.lang.String message,
int severity,
java.lang.String sourceName)
Returns an XmlError for the given message, with the given severity, located in the given file. |
static XmlError |
forSource(java.lang.String code,
java.lang.Object[] args,
int severity,
java.lang.String sourceName)
Returns an XmlError for the given message, with the given severity, located in the given file. |
static XmlError |
forSource(java.lang.String message,
java.lang.String sourceName)
Returns an XmlError for the given message, located in the given file and SEVERITY_ERROR . |
int |
getColumn()
Returns the column number of the error, if available, -1 if not. |
XmlCursor |
getCursorLocation()
Returns a location of the error as an XmlCursor , null if
not available. |
java.lang.String |
getErrorCode()
Returns the error code or null. |
int |
getLine()
Returns the line number of the error, if available, -1 if not. |
java.lang.Object |
getLocation(java.lang.Object type)
Returns a location object of the given type. |
java.lang.String |
getMessage()
Returns the error message without location information. |
XmlObject |
getObjectLocation()
Returns a location of the error as an XmlObject , null if
not available. |
int |
getOffset()
Returns the file character offset of the error, if available, -1 if not. |
int |
getSeverity()
Returns the severity. |
java.lang.String |
getSourceName()
Returns the URL (or other name) of the file with the error, if available. |
static java.lang.String |
severityAsString(int severity)
|
java.lang.String |
toString()
Produces a standard string for the error message, complete with filename and location offsets if available. |
java.lang.String |
toString(java.net.URI base)
Produces a standard string with the error message. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int SEVERITY_ERROR
getSeverity()
.
public static final int SEVERITY_WARNING
getSeverity()
.
public static final int SEVERITY_INFO
getSeverity()
.
Constructor Detail |
---|
public XmlError(XmlError src)
src
- The original XmlError to copy.protected XmlError(java.lang.String message, java.lang.String code, int severity, XmlCursor cursor)
protected XmlError(java.lang.String code, java.lang.Object[] args, int severity, XmlCursor cursor)
protected XmlError(java.lang.String message, java.lang.String code, int severity, javax.xml.stream.Location loc)
protected XmlError(java.lang.String code, java.lang.Object[] args, int severity, javax.xml.stream.Location loc)
Method Detail |
---|
public static XmlError forMessage(java.lang.String message)
SEVERITY_ERROR
.
message
- the error messagepublic static XmlError forMessage(java.lang.String message, int severity)
message
- the error messageseverity
- the severity (SEVERITY_ERROR
, SEVERITY_WARNING
, or SEVERITY_INFO
)public static XmlError forMessage(java.lang.String code, java.lang.Object[] args)
code
- the error codeargs
- the arguments to use in formatting the error messagepublic static XmlError forMessage(java.lang.String code, java.lang.Object[] args, int severity)
code
- the error codeargs
- the arguments to use in formatting the error messageseverity
- the severity (SEVERITY_ERROR
, SEVERITY_WARNING
, or SEVERITY_INFO
)public static XmlError forSource(java.lang.String message, java.lang.String sourceName)
SEVERITY_ERROR
.
message
- the error messagesourceName
- the URL or other name for the filepublic static XmlError forSource(java.lang.String message, int severity, java.lang.String sourceName)
message
- the error messageseverity
- the severity (SEVERITY_ERROR
, SEVERITY_WARNING
, or SEVERITY_INFO
)sourceName
- the URL or other name for the filepublic static XmlError forSource(java.lang.String code, java.lang.Object[] args, int severity, java.lang.String sourceName)
code
- the error codeargs
- the arguments to use in formatting the error messageseverity
- the severity (SEVERITY_ERROR
, SEVERITY_WARNING
, or SEVERITY_INFO
)sourceName
- the URL or other name for the filepublic static XmlError forLocation(java.lang.String message, java.lang.String sourceName, javax.xml.stream.Location location)
SEVERITY_ERROR
.
message
- the error messagesourceName
- the URL or other name for the filelocation
- the location from an xml streampublic static XmlError forLocation(java.lang.String message, java.lang.String sourceName, int line, int column, int offset)
SEVERITY_ERROR
.
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 knownpublic static XmlError forLocation(java.lang.String code, java.lang.Object[] args, int severity, java.lang.String sourceName, int line, int column, int offset)
code
- the error codeargs
- the arguments to use in formatting the error messageseverity
- the severity (SEVERITY_ERROR
, SEVERITY_WARNING
, or SEVERITY_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 knownpublic static XmlError forLocation(java.lang.String message, int severity, java.lang.String sourceName, int line, int column, int offset)
message
- the error messageseverity
- the severity (SEVERITY_ERROR
, SEVERITY_WARNING
, or SEVERITY_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 knownpublic static XmlError forLocationAndCursor(java.lang.String message, int severity, java.lang.String sourceName, int line, int column, int offset, XmlCursor cursor)
message
- the error messageseverity
- the severity (SEVERITY_ERROR
, SEVERITY_WARNING
, or SEVERITY_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 errorpublic static XmlError forObject(java.lang.String message, XmlObject xobj)
SEVERITY_ERROR
.
message
- the error messagexobj
- the XmlObject representing the location of the errorpublic static XmlError forObject(java.lang.String code, java.lang.Object[] args, XmlObject xobj)
SEVERITY_ERROR
.
code
- the error codeargs
- the arguments to use in formatting the error messagexobj
- the XmlObject representing the location of the errorpublic static XmlError forObject(java.lang.String message, int severity, XmlObject xobj)
message
- the error messageseverity
- the severity (SEVERITY_ERROR
, SEVERITY_WARNING
, or SEVERITY_INFO
)xobj
- the XmlObject representing the location of the errorpublic static XmlError forObject(java.lang.String code, java.lang.Object[] args, int severity, XmlObject xobj)
code
- the error codeargs
- the arguments to use in formatting the error messageseverity
- the severity (SEVERITY_ERROR
, SEVERITY_WARNING
, or SEVERITY_INFO
)xobj
- the XmlObject representing the location of the errorpublic static XmlError forCursor(java.lang.String message, XmlCursor cursor)
SEVERITY_ERROR
.
message
- the error messagecursor
- the XmlCursor representing the location of the errorpublic static XmlError forCursor(java.lang.String code, java.lang.Object[] args, XmlCursor cursor)
SEVERITY_ERROR
.
code
- the error codeargs
- the arguments to use in formatting the error messagecursor
- the XmlCursor representing the location of the errorpublic static XmlError forCursor(java.lang.String message, int severity, XmlCursor cursor)
message
- the error messageseverity
- the severity (SEVERITY_ERROR
, SEVERITY_WARNING
, or SEVERITY_INFO
)cursor
- the XmlCursor representing the location of the errorpublic static XmlError forCursor(java.lang.String code, java.lang.Object[] args, int severity, XmlCursor cursor)
code
- the error codeargs
- the arguments to use in formatting the error messageseverity
- the severity (SEVERITY_ERROR
, SEVERITY_WARNING
, or SEVERITY_INFO
)cursor
- the XmlCursor representing the location of the errorprotected static java.lang.String formattedFileName(java.lang.String rawString, java.net.URI base)
public static java.lang.String formattedMessage(java.lang.String code, java.lang.Object[] args)
public int getSeverity()
SEVERITY_ERROR
, SEVERITY_WARNING
, or SEVERITY_INFO
.
public java.lang.String getMessage()
public java.lang.String getErrorCode()
XmlErrorCodes
.
public java.lang.String getSourceName()
public int getLine()
public int getColumn()
public int getOffset()
public java.lang.Object getLocation(java.lang.Object type)
public XmlCursor getCursorLocation()
XmlCursor
, null if
not available.
public XmlObject getObjectLocation()
XmlObject
, null if
not available.
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(java.net.URI base)
public static java.lang.String severityAsString(int severity)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |