public final class DiagnosticImpl extends Object implements Diagnostic
This class also has a number of helper functions (static methods)
operating on Diagnostic
s of any kind such as format(com.xmlmind.xml.validate.Diagnostic[])
.
Modifier and Type | Class and Description |
---|---|
static class |
DiagnosticImpl.DiagnosticComparator
Compares two diagnostics, first by the order of their elements,
then by the severity of the diagnostic (most severe comes first),
then by their messages.
|
Diagnostic.Severity
Modifier and Type | Field and Description |
---|---|
static DiagnosticImpl.DiagnosticComparator |
compareDiagnostics
A ready-to-use instance of DiagnosticComparator.
|
String |
detailId
Value returned by
getDiagnosticDetailId() . |
Object[] |
detailValues
Value returned by
getDiagnosticDetailValues() . |
Element |
element
Value returned by
getDiagnosticMessage() . |
String |
message
Value returned by
getDiagnosticMessage() . |
static DiagnosticImpl[] |
NO_DIAGNOSTICS
An empty array of DiagnosticImpl.
|
Diagnostic.Severity |
severity
Value returned by
getDiagnosticSeverity() . |
BAD_ATTRIBUTE_NAME, BROKEN_IDREF, BROKEN_LINK, DUPLICATE_ANCHOR, DUPLICATE_ID, ORIGINAL_ANCHOR, ORIGINAL_ID
Constructor and Description |
---|
DiagnosticImpl(Element element,
String message,
Diagnostic.Severity severity)
Constructs a diagnostic containing specified information.
|
DiagnosticImpl(Element element,
String message,
Diagnostic.Severity severity,
String detailId,
Object detailValue)
Constructs a diagnostic containing specified information.
|
DiagnosticImpl(Element element,
String message,
Diagnostic.Severity severity,
String detailId,
Object[] detailValues)
Constructs a diagnostic containing specified information.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
equals(Diagnostic d1,
Diagnostic d2)
Tests specified diagnostics for equality.
|
static String |
format(Diagnostic diagnostic)
Returns the formatted error message corresponding to
specified diagnostic.
|
static String |
format(Diagnostic[] diagnostics)
Returns a newline separated list of formatted error messages
corresponding to specified diagnostics.
|
static void |
format(Diagnostic diagnostic,
StringBuilder buffer)
Appends to specified buffer the formatted error message corresponding to
specified diagnostic.
|
Element |
getDiagnosedElement()
Returns the element where this error was found.
|
String |
getDiagnosticDetailId()
Returns a string identifying extra information
about this diagnostic.
|
Object[] |
getDiagnosticDetailValues()
Returns extra information about this diagnostic.
|
String |
getDiagnosticMessage()
Returns a message describing this error.
|
Diagnostic.Severity |
getDiagnosticSeverity()
Returns the severity of this error.
|
public static final DiagnosticImpl[] NO_DIAGNOSTICS
public final Element element
getDiagnosticMessage()
.public final String message
getDiagnosticMessage()
.public final Diagnostic.Severity severity
getDiagnosticSeverity()
.public final String detailId
getDiagnosticDetailId()
.public final Object[] detailValues
getDiagnosticDetailValues()
.public static final DiagnosticImpl.DiagnosticComparator compareDiagnostics
public DiagnosticImpl(Element element, String message, Diagnostic.Severity severity)
public DiagnosticImpl(Element element, String message, Diagnostic.Severity severity, String detailId, Object detailValue)
public DiagnosticImpl(Element element, String message, Diagnostic.Severity severity, String detailId, Object[] detailValues)
public Element getDiagnosedElement()
Diagnostic
getDiagnosedElement
in interface Diagnostic
public String getDiagnosticMessage()
Diagnostic
getDiagnosticMessage
in interface Diagnostic
public Diagnostic.Severity getDiagnosticSeverity()
Diagnostic
getDiagnosticSeverity
in interface Diagnostic
public String getDiagnosticDetailId()
Diagnostic
null
if no extra information
about this diagnostic is available.
Important: the returned string is tested against known
detail identifiers using ==
and
not using equals
.
getDiagnosticDetailId
in interface Diagnostic
Diagnostic.getDiagnosticDetailValues()
,
Diagnostic.BROKEN_IDREF
,
Diagnostic.DUPLICATE_ID
,
Diagnostic.ORIGINAL_ID
public Object[] getDiagnosticDetailValues()
Diagnostic
null
if no extra information
about this diagnostic is available.getDiagnosticDetailValues
in interface Diagnostic
Diagnostic.getDiagnosticDetailId()
public static String format(Diagnostic[] diagnostics)
public static String format(Diagnostic diagnostic)
public static void format(Diagnostic diagnostic, StringBuilder buffer)
public static final boolean equals(Diagnostic d1, Diagnostic d2)