public interface Reporter
Diagnostics consist of a diagnostic kind
and a message, and may additionally be associated with an element
, a tree node
in a documentation comment, or an arbitrary position in a given file
. Other messages may be written directly to one of two streams that are informally for use by "standard output" and "diagnostic output", where "standard output" means the output that is the expected result of executing some operation, such as the command-line help that is generated when using a --help
option, and "diagnostic output" refers to any errors, warnings and other output that is a side effect of executing the operation.
The exact manner in which diagnostics are output is unspecified and depends on the enclosing context. For example:
DocumentationTool
API allows a client to specify a DiagnosticListener
to which diagnostics will be reported
. If no listener is specified, diagnostics will be written to a given stream, or to System.err
if no such stream is provided. ToolProvider
API allows a client to specify the streams to be used for reporting standard and diagnostic output. Modifier and Type | Method | Description |
---|---|---|
default PrintWriter |
getDiagnosticWriter() |
Returns a writer that can be used to write diagnostic output, or null if no such writer is available. |
default PrintWriter |
getStandardWriter() |
Returns a writer that can be used to write non-diagnostic output, or null if no such writer is available. |
default void |
print |
Prints a diagnostic message related to a position within a range of characters in a tree node. |
void |
print |
Prints a diagnostic message related to a tree node in a documentation comment. |
void |
print |
Prints a diagnostic message. |
void |
print |
Prints a diagnostic message related to an element. |
default void |
print |
Prints a diagnostic message related to a position within a range of characters in a file. |
void print(Diagnostic.Kind kind, String message)
kind
- the kind of diagnosticmessage
- the message to be printedvoid print(Diagnostic.Kind kind, DocTreePath path, String message)
kind
- the kind of diagnosticpath
- the path for the tree nodemessage
- the message to be printeddefault void print(Diagnostic.Kind kind, DocTreePath path, int start, int pos, int end, String message)
DocTree
that wrap a simple string value are supported as leaf nodes of the given path. This currently includes CommentTree
, DocTypeTree
, ReferenceTree
, and TextTree
. The positions are all 0-based character offsets from the beginning of string. The positions should satisfy the relation start <= pos <= end
.(start, pos, end)
values and simply calls print(kind, path, message)
.kind
- the kind of diagnosticpath
- the path for the tree nodestart
- the beginning of the enclosing rangepos
- the positionend
- the end of the enclosing rangemessage
- the message to be printedIllegalArgumentException
- if start
, pos
and end
do not form a valid range.void print(Diagnostic.Kind kind, Element element, String message)
kind
- the kind of diagnosticelement
- the elementmessage
- the message to be printeddefault void print(Diagnostic.Kind kind, FileObject file, int start, int pos, int end, String message)
start <= pos <= end
.UnsupportedOperationException
. The implementation provided by the javadoc
tool to initialize
a doclet overrides this implementation.kind
- the kind of diagnosticfile
- the filestart
- the beginning of the enclosing rangepos
- the positionend
- the end of the enclosing rangemessage
- the message to be printeddefault PrintWriter getStandardWriter()
null
if no such writer is available.getDiagnosticWriter()
.null
. The implementation provided by the javadoc
tool to initialize
a doclet always returns a non-null
value.default PrintWriter getDiagnosticWriter()
null
if no such writer is available.getStandardWriter()
.null
. The implementation provided by the javadoc
tool to initialize
a doclet always returns a non-null
value.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/jdk.javadoc/jdk/javadoc/doclet/Reporter.html