Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/src/share/classes/javax/tools/DocumentationTool.java
38900 views
/*1* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24package javax.tools;2526import java.io.Writer;27import java.nio.charset.Charset;28import java.util.Locale;29import java.util.concurrent.Callable;3031/**32* Interface to invoke Java™ programming language documentation tools from33* programs.34*/35public interface DocumentationTool extends Tool, OptionChecker {36/**37* Creates a future for a documentation task with the given38* components and arguments. The task might not have39* completed as described in the DocumentationTask interface.40*41* <p>If a file manager is provided, it must be able to handle all42* locations defined in {@link DocumentationTool.Location},43* as well as44* {@link StandardLocation#SOURCE_PATH},45* {@link StandardLocation#CLASS_PATH}, and46* {@link StandardLocation#PLATFORM_CLASS_PATH}.47*48* @param out a Writer for additional output from the tool;49* use {@code System.err} if {@code null}50*51* @param fileManager a file manager; if {@code null} use the52* tool's standard filemanager53*54* @param diagnosticListener a diagnostic listener; if {@code null}55* use the tool's default method for reporting diagnostics56*57* @param docletClass a class providing the necessary methods required58* of a doclet59*60* @param options documentation tool options and doclet options,61* {@code null} means no options62*63* @param compilationUnits the compilation units to compile, {@code64* null} means no compilation units65*66* @return an object representing the compilation67*68* @throws RuntimeException if an unrecoverable error69* occurred in a user supplied component. The70* {@linkplain Throwable#getCause() cause} will be the error in71* user code.72*73* @throws IllegalArgumentException if any of the given74* compilation units are of other kind than75* {@linkplain JavaFileObject.Kind#SOURCE source}76*/77DocumentationTask getTask(Writer out,78JavaFileManager fileManager,79DiagnosticListener<? super JavaFileObject> diagnosticListener,80Class<?> docletClass,81Iterable<String> options,82Iterable<? extends JavaFileObject> compilationUnits);8384/**85* Gets a new instance of the standard file manager implementation86* for this tool. The file manager will use the given diagnostic87* listener for producing any non-fatal diagnostics. Fatal errors88* will be signaled with the appropriate exceptions.89*90* <p>The standard file manager will be automatically reopened if91* it is accessed after calls to {@code flush} or {@code close}.92* The standard file manager must be usable with other tools.93*94* @param diagnosticListener a diagnostic listener for non-fatal95* diagnostics; if {@code null} use the compiler's default method96* for reporting diagnostics97*98* @param locale the locale to apply when formatting diagnostics;99* {@code null} means the {@linkplain Locale#getDefault() default locale}.100*101* @param charset the character set used for decoding bytes; if102* {@code null} use the platform default103*104* @return the standard file manager105*/106StandardJavaFileManager getStandardFileManager(107DiagnosticListener<? super JavaFileObject> diagnosticListener,108Locale locale,109Charset charset);110111/**112* Interface representing a future for a documentation task. The113* task has not yet started. To start the task, call114* the {@linkplain #call call} method.115*116* <p>Before calling the call method, additional aspects of the117* task can be configured, for example, by calling the118* {@linkplain #setLocale setLocale} method.119*/120interface DocumentationTask extends Callable<Boolean> {121/**122* Set the locale to be applied when formatting diagnostics and123* other localized data.124*125* @param locale the locale to apply; {@code null} means apply no126* locale127* @throws IllegalStateException if the task has started128*/129void setLocale(Locale locale);130131/**132* Performs this documentation task. The task may only133* be performed once. Subsequent calls to this method throw134* IllegalStateException.135*136* @return true if and only all the files were processed without errors;137* false otherwise138*139* @throws RuntimeException if an unrecoverable error occurred140* in a user-supplied component. The141* {@linkplain Throwable#getCause() cause} will be the error142* in user code.143*144* @throws IllegalStateException if called more than once145*/146Boolean call();147}148149/**150* Locations specific to {@link DocumentationTool}.151*152* @see StandardLocation153*/154enum Location implements JavaFileManager.Location {155/**156* Location of new documentation files.157*/158DOCUMENTATION_OUTPUT,159160/**161* Location to search for doclets.162*/163DOCLET_PATH,164165/**166* Location to search for taglets.167*/168TAGLET_PATH;169170public String getName() { return name(); }171172public boolean isOutputLocation() {173switch (this) {174case DOCUMENTATION_OUTPUT:175return true;176default:177return false;178}179}180}181182}183184185