public interface Reporter
用于报告诊断和其他消息的接口。
诊断由 diagnostic kind 和一条消息组成,还可能与 element 、文档注释中的 tree node 或给定 file 中的任意位置相关联。其他消息可以直接写入两个流之一,这两个流非正式地供“标准输出”和“诊断输出”使用,其中“标准输出”表示执行某些操作的预期结果输出,例如命令-使用 --help 选项时生成的行帮助,“诊断输出”是指任何错误、警告和其他作为执行操作副作用的输出。
诊断输出的确切方式是未指定的,取决于封闭的上下文。例如:
DocumentationToolAPI 允许客户端指定一个DiagnosticListener,诊断将是reported。如果未指定监听器,则诊断将写入给定流,或者如果未提供此类流,则写入System.err。ToolProviderAPI 允许客户端指定用于报告标准和诊断输出的流。
- 自从:
- 9
-
方法总结
修饰符和类型方法描述default PrintWriter返回可用于写入诊断输出的编写器,如果没有这样的编写器可用,则返回null。default PrintWriter返回可用于写入非诊断输出的编写器,如果没有这样的编写器可用,则返回null。default voidprint(Diagnostic.Kind kind, DocTreePath path, int start, int pos, int end, String message) 打印与树节点中字符范围内的位置相关的诊断消息。voidprint(Diagnostic.Kind kind, DocTreePath path, String message) 在文档注释中打印与树节点相关的诊断消息。voidprint(Diagnostic.Kind kind, String message) 打印诊断消息。voidprint(Diagnostic.Kind kind, Element element, String message) 打印与元素相关的诊断消息。default voidprint(Diagnostic.Kind kind, FileObject file, int start, int pos, int end, String message) 打印与文件中字符范围内的位置相关的诊断消息。
-
方法详情
-
print
打印诊断消息。- 参数:
kind- 诊断的种类message- 要打印的消息
-
print
在文档注释中打印与树节点相关的诊断消息。- 参数:
kind- 诊断的种类path- 树节点的路径message- 要打印的消息
-
print
default void print(Diagnostic.Kind kind, DocTreePath path, int start, int pos, int end, String message) 打印与树节点中字符范围内的位置相关的诊断消息。仅支持包含简单字符串值的DocTree作为给定路径的叶节点。目前包括CommentTree、DocTypeTree、ReferenceTree和TextTree。这些位置都是从字符串开头开始的基于 0 的字符偏移量。这些职位应满足关系start <= pos <= end。- 实现要求:
-
此实现忽略
(start, pos, end)值并简单地调用print(kind, path, message)。 - 参数:
kind- 诊断的种类path- 树节点的路径start- 封闭范围的开始pos- 位置end- 封闭范围的结尾message- 要打印的消息- 抛出:
IllegalArgumentException- 如果start、pos和end不构成有效范围。- 自从:
- 18
-
print
打印与元素相关的诊断消息。- 参数:
kind- 诊断的种类element- 元素message- 要打印的消息
-
print
default void print(Diagnostic.Kind kind, FileObject file, int start, int pos, int end, String message) 打印与文件中字符范围内的位置相关的诊断消息。这些位置都是从文件内容开始的基于 0 的字符偏移量。这些职位应满足关系start <= pos <= end。- 实现要求:
-
此实现始终抛出
UnsupportedOperationException。javadoc工具为initializedoclet 提供的实现会覆盖此实现。 - 参数:
kind- 诊断的种类file- 文件start- 封闭范围的开始pos- 位置end- 封闭范围的结尾message- 要打印的消息- 自从:
- 17
-
getStandardWriter
返回可用于写入非诊断输出的编写器,如果没有这样的编写器可用,则返回null。- API 注意:
-
该值可能与
getDiagnosticWriter()返回的值相同,也可能不同。 - 实现要求:
-
此实现返回
null。javadoc工具为initializedoclet 提供的实现始终返回非null值。 - 返回:
- writer
- 自从:
- 17
-
getDiagnosticWriter
返回可用于写入诊断输出的编写器,如果没有这样的编写器可用,则返回null。- API 注意:
-
该值可能与
getStandardWriter()返回的值相同,也可能不同。 - 实现要求:
-
此实现返回
null。javadoc工具为initializedoclet 提供的实现始终返回非null值。 - 返回:
- writer
- 自从:
- 17
-