public class ValidityException extends ParsingException
Signals a validity error in a document being parsed. These are not thrown by default, unless you specifically request that the builder validate.
Constructor and Description |
---|
ValidityException(String message)
Creates a new
ValidityException
with a detail message. |
ValidityException(String message,
int lineNumber,
int columnNumber)
Creates a new
ValidityException
with a detail message and line and column numbers. |
ValidityException(String message,
int lineNumber,
int columnNumber,
Throwable cause)
Creates a new
ValidityException
with a detail message, line and column numbers,
and an underlying exception. |
ValidityException(String message,
String uri,
int lineNumber,
int columnNumber)
Creates a new
ValidityException
with a detail message, the URI of the document that contained
the error, and approximate line and column numbers of the
first validity error. |
ValidityException(String message,
String uri,
int lineNumber,
int columnNumber,
Throwable cause)
Creates a new
ValidityException
with a detail message, URI of the document containing the
validity error, line and column numbers of the error,
and an underlying exception. |
ValidityException(String message,
Throwable cause)
Creates a new
ValidityException
with a detail message and an underlying root cause. |
Modifier and Type | Method and Description |
---|---|
int | getColumnNumber(int n)
Returns the column number of the nth validity
error.
|
Document | getDocument()
Returns a
Document object for the document that
caused this exception. |
int | getErrorCount()
Returns the number of validity errors the parser detected
in the document.
|
int | getLineNumber(int n)
Returns the line number of the nth validity
error.
|
String | getValidityError(int n)
Returns a message indicating a specific validity problem
in the input document as detected by the parser.
|
getCause, getColumnNumber, getLineNumber, getURI, initCause, toString
public ValidityException(String message, Throwable cause)
Creates a new ValidityException
with a detail message and an underlying root cause.
message
- a string indicating the specific problemcause
- the original cause of this exceptionpublic ValidityException(String message, int lineNumber, int columnNumber)
Creates a new ValidityException
with a detail message and line and column numbers.
message
- a string indicating the specific problemlineNumber
- the approximate line number
where the problem occurscolumnNumber
- the approximate column number
where the problem occurspublic ValidityException(String message, int lineNumber, int columnNumber, Throwable cause)
Creates a new ValidityException
with a detail message, line and column numbers,
and an underlying exception.
message
- a string indicating the specific problemlineNumber
- the approximate line number
where the problem occurscolumnNumber
- the approximate column number
where the problem occurscause
- the original cause of this exceptionpublic ValidityException(String message, String uri, int lineNumber, int columnNumber)
Creates a new ValidityException
with a detail message, the URI of the document that contained
the error, and approximate line and column numbers of the
first validity error.
message
- a string indicating the specific problemuri
- URL of the document with a validity errorlineNumber
- the approximate line number
where the problem occurscolumnNumber
- the approximate column number
where the problem occurspublic ValidityException(String message, String uri, int lineNumber, int columnNumber, Throwable cause)
Creates a new ValidityException
with a detail message, URI of the document containing the
validity error, line and column numbers of the error,
and an underlying exception.
message
- a string indicating the specific problemuri
- URL of the document with a validity errorlineNumber
- the approximate line number
where the problem occurscolumnNumber
- the approximate column number
where the problem occurscause
- the original cause of this exceptionpublic ValidityException(String message)
Creates a new ValidityException
with a detail message.
message
- a string indicating the specific problempublic Document getDocument()
Returns a Document
object for the document that
caused this exception. This is useful if you want notification
of validity errors, but nonetheless wish to further process
the invalid document.
public int getErrorCount()
Returns the number of validity errors the parser detected in the document. This is likely to not be consistent from one parser to another.
public String getValidityError(int n)
Returns a message indicating a specific validity problem in the input document as detected by the parser. Normally, these will be in the order they appear in the document. For instance, an error in the root element is likely to appear before an error in a child element. However, this depends on the underlying parser and is not guaranteed.
n
- the index of the validity error to reportIndexOutOfBoundsException
- if n
is greater
than or equal to the number of errors detectedpublic int getLineNumber(int n)
Returns the line number of the nth validity error. It returns -1 if this is not known. This number may be helpful for debugging, but should not be relied on. Different parsers may set it differently. For instance a problem with an element might be reported using the line number of the start-tag or the line number of the end-tag.
n
- the index of the validity error to reportIndexOutOfBoundsException
- if n
is greater
than or equal to the number of errors detectedpublic int getColumnNumber(int n)
Returns the column number of the nth validity
error. It returns -1 if this is not known. This number
may be helpful for debugging, but should not be relied on.
Different parsers may set it differently. For instance
a problem with an element might be reported using the
column of the <
or the >
of the start-tag
n
- the index of the validity error to reportIndexOutOfBoundsException
- if n
is greater
than or equal to the number of errors detectedCopyright 2002-2023 Elliotte Rusty Harold
elharo@ibiblio.org