Top Description Inners Fields Methods
javax.tools

public Interface Diagnostic<S>

Type Parameters
<S>
the type of source object used by this diagnostic
Imports
java.util.Locale

Interface for diagnostics from tools. A diagnostic usually reports a problem at a specific position in a source file. However, not all diagnostics are associated with a position or a file.

A position is a zero-based character offset from the beginning of a file. Negative values (except NOPOS) are not valid positions.

Line and column numbers begin at 1. Negative values (except NOPOS) and 0 are not valid line or column numbers.

Since
1.6

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Diagnostic.Kind

Kinds of diagnostics, for example, error or warning.

Field Summary

Modifier and TypeField and Description
public static final long
NOPOS

Used to signal that no position is available.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

a diagnostic code
getCode
()

Returns a diagnostic code indicating the type of diagnostic.

public long

Returns:

a column number or NOPOS if and only if getPosition() returns NOPOS
getColumnNumber
()

Returns the column number of the character offset returned by getPosition().

public long

Returns:

offset from beginning of file; NOPOS if and only if getPosition() returns NOPOS
getEndPosition
()

Returns the character offset from the beginning of the file associated with this diagnostic that indicates the end of the problem.

public Diagnostic.Kind

Returns:

the kind of this diagnostic
getKind
()

Returns the kind of this diagnostic, for example, error or warning.

public long

Returns:

a line number or NOPOS if and only if getPosition() returns NOPOS
getLineNumber
()

Returns the line number of the character offset returned by getPosition().

public String

Returns:

a localized message
getMessage
(Locale
a locale; might be null
locale
)

Returns a localized message for the given locale.

public long

Returns:

character offset from beginning of source; NOPOS if getSource() would return null or if no location is suitable
getPosition
()

Returns a character offset from the beginning of the source object associated with this diagnostic that indicates the location of the problem.

public S

Returns:

the source object associated with this diagnostic. null if no source object is associated with the diagnostic.
getSource
()

Returns the source object associated with this diagnostic.

public long

Returns:

offset from beginning of file; NOPOS if and only if getPosition() returns NOPOS
getStartPosition
()

Returns the character offset from the beginning of the file associated with this diagnostic that indicates the start of the problem.

Field Detail

NOPOSback to summary
public static final long NOPOS

Used to signal that no position is available.

Method Detail

getCodeback to summary
public String getCode()

Returns a diagnostic code indicating the type of diagnostic. The code is implementation-dependent and might be null.

Returns:String

a diagnostic code

getColumnNumberback to summary
public long getColumnNumber()

Returns the column number of the character offset returned by getPosition().

Returns:long

a column number or NOPOS if and only if getPosition() returns NOPOS

getEndPositionback to summary
public long getEndPosition()

Returns the character offset from the beginning of the file associated with this diagnostic that indicates the end of the problem.

Returns:long

offset from beginning of file; NOPOS if and only if getPosition() returns NOPOS

getKindback to summary
public Diagnostic.Kind getKind()

Returns the kind of this diagnostic, for example, error or warning.

Returns:Diagnostic.Kind

the kind of this diagnostic

getLineNumberback to summary
public long getLineNumber()

Returns the line number of the character offset returned by getPosition().

Returns:long

a line number or NOPOS if and only if getPosition() returns NOPOS

getMessageback to summary
public String getMessage(Locale locale)

Returns a localized message for the given locale. The actual message is implementation-dependent. If the locale is null use the default locale.

Parameters
locale:Locale

a locale; might be null

Returns:String

a localized message

getPositionback to summary
public long getPosition()

Returns a character offset from the beginning of the source object associated with this diagnostic that indicates the location of the problem. In addition, the following must be true:

getStartPosition() <= getPosition()

getPosition() <= getEndPosition()

Returns:long

character offset from beginning of source; NOPOS if getSource() would return null or if no location is suitable

getSourceback to summary
public S getSource()

Returns the source object associated with this diagnostic.

Returns:S

the source object associated with this diagnostic. null if no source object is associated with the diagnostic.

getStartPositionback to summary
public long getStartPosition()

Returns the character offset from the beginning of the file associated with this diagnostic that indicates the start of the problem.

Returns:long

offset from beginning of file; NOPOS if and only if getPosition() returns NOPOS

javax.tools back to summary

public final Enum Diagnostic.Kind

extends Enum<Diagnostic.Kind>
Class Inheritance

Kinds of diagnostics, for example, error or warning. The kind of a diagnostic can be used to determine how the diagnostic should be presented to the user. For example, errors might be colored red or prefixed with the word "Error", while warnings might be colored yellow or prefixed with the word "Warning". There is no requirement that the Kind should imply any inherent semantic meaning to the message of the diagnostic: for example, a tool might provide an option to report all warnings as errors.

Field Summary

Modifier and TypeField and Description
public static final Diagnostic.Kind
ERROR

Problem which prevents the tool's normal completion.

public static final Diagnostic.Kind
MANDATORY_WARNING

Problem similar to a warning, but is mandated by the tool's specification.

public static final Diagnostic.Kind
NOTE

Informative message from the tool.

public static final Diagnostic.Kind
OTHER

Diagnostic which does not fit within the other kinds.

public static final Diagnostic.Kind
WARNING

Problem which does not usually prevent the tool from completing normally.

Constructor Summary

AccessConstructor and Description
private
Kind()

Method Summary

Modifier and TypeMethod and Description
public static Diagnostic.Kind
public static Diagnostic.Kind[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ERRORback to summary
public static final Diagnostic.Kind ERROR

Problem which prevents the tool's normal completion.

MANDATORY_WARNINGback to summary
public static final Diagnostic.Kind MANDATORY_WARNING

Problem similar to a warning, but is mandated by the tool's specification. For example, the Java Language Specification mandates warnings on certain unchecked operations and the use of deprecated methods.

NOTEback to summary
public static final Diagnostic.Kind NOTE

Informative message from the tool.

OTHERback to summary
public static final Diagnostic.Kind OTHER

Diagnostic which does not fit within the other kinds.

WARNINGback to summary
public static final Diagnostic.Kind WARNING

Problem which does not usually prevent the tool from completing normally.

Constructor Detail

Kindback to summary
private Kind()

Method Detail

valueOfback to summary
public static Diagnostic.Kind valueOf(String name)
valuesback to summary
public static Diagnostic.Kind[] values()