< prev index next >

src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTool.java

Print this page




  33 import java.nio.charset.Charset;
  34 import java.util.Collections;
  35 import java.util.EnumSet;
  36 import java.util.Locale;
  37 import java.util.Objects;
  38 import java.util.Set;
  39 
  40 import javax.lang.model.SourceVersion;
  41 import javax.tools.DiagnosticListener;
  42 import javax.tools.DocumentationTool;
  43 import javax.tools.JavaFileManager;
  44 import javax.tools.JavaFileObject;
  45 import javax.tools.StandardJavaFileManager;
  46 
  47 import com.sun.tools.javac.api.ClientCodeWrapper;
  48 import com.sun.tools.javac.file.JavacFileManager;
  49 import com.sun.tools.javac.file.BaseFileManager;
  50 import com.sun.tools.javac.util.ClientCodeException;
  51 import com.sun.tools.javac.util.Context;
  52 import com.sun.tools.javac.util.Log;
  53 import jdk.javadoc.internal.tool.ToolOption;
  54 
  55 /**
  56  * Provides access to functionality specific to the JDK documentation tool,
  57  * javadoc.
  58  *
  59  * <p><b>This is NOT part of any supported API.
  60  * If you write code that depends on this, you do so at your own
  61  * risk.  This code and its internal interfaces are subject to change
  62  * or deletion without notice.</b></p>
  63  */
  64 public class JavadocTool implements DocumentationTool {
  65     // @Override // can't add @Override until bootstrap JDK provides Tool.name()
  66     public String name() {
  67         return "javadoc";
  68     }
  69 
  70     @Override
  71     public DocumentationTask getTask(
  72             Writer out,
  73             JavaFileManager fileManager,


 153         PrintWriter err_pw = new PrintWriter(err == null ? System.err : err, true);
 154         PrintWriter out_pw = new PrintWriter(out == null ? System.out : out);
 155         try {
 156             return jdk.javadoc.internal.tool.Main.execute(arguments, err_pw);
 157         } finally {
 158             err_pw.flush();
 159             out_pw.flush();
 160         }
 161     }
 162 
 163     @Override
 164     public Set<SourceVersion> getSourceVersions() {
 165         return Collections.unmodifiableSet(
 166                 EnumSet.range(SourceVersion.RELEASE_3, SourceVersion.latest()));
 167     }
 168 
 169     @Override
 170     public int isSupportedOption(String option) {
 171         if (option == null)
 172             throw new NullPointerException();
 173         for (ToolOption o : ToolOption.values()) {
 174             for (String name : o.names) {
 175                 if (name.equals(option))
 176                     return o.hasArg ? 1 : 0;
 177             }
 178         }
 179         return -1;
 180     }
 181 
 182 }


  33 import java.nio.charset.Charset;
  34 import java.util.Collections;
  35 import java.util.EnumSet;
  36 import java.util.Locale;
  37 import java.util.Objects;
  38 import java.util.Set;
  39 
  40 import javax.lang.model.SourceVersion;
  41 import javax.tools.DiagnosticListener;
  42 import javax.tools.DocumentationTool;
  43 import javax.tools.JavaFileManager;
  44 import javax.tools.JavaFileObject;
  45 import javax.tools.StandardJavaFileManager;
  46 
  47 import com.sun.tools.javac.api.ClientCodeWrapper;
  48 import com.sun.tools.javac.file.JavacFileManager;
  49 import com.sun.tools.javac.file.BaseFileManager;
  50 import com.sun.tools.javac.util.ClientCodeException;
  51 import com.sun.tools.javac.util.Context;
  52 import com.sun.tools.javac.util.Log;
  53 import jdk.javadoc.internal.tool.ToolOptions;
  54 
  55 /**
  56  * Provides access to functionality specific to the JDK documentation tool,
  57  * javadoc.
  58  *
  59  * <p><b>This is NOT part of any supported API.
  60  * If you write code that depends on this, you do so at your own
  61  * risk.  This code and its internal interfaces are subject to change
  62  * or deletion without notice.</b></p>
  63  */
  64 public class JavadocTool implements DocumentationTool {
  65     // @Override // can't add @Override until bootstrap JDK provides Tool.name()
  66     public String name() {
  67         return "javadoc";
  68     }
  69 
  70     @Override
  71     public DocumentationTask getTask(
  72             Writer out,
  73             JavaFileManager fileManager,


 153         PrintWriter err_pw = new PrintWriter(err == null ? System.err : err, true);
 154         PrintWriter out_pw = new PrintWriter(out == null ? System.out : out);
 155         try {
 156             return jdk.javadoc.internal.tool.Main.execute(arguments, err_pw);
 157         } finally {
 158             err_pw.flush();
 159             out_pw.flush();
 160         }
 161     }
 162 
 163     @Override
 164     public Set<SourceVersion> getSourceVersions() {
 165         return Collections.unmodifiableSet(
 166                 EnumSet.range(SourceVersion.RELEASE_3, SourceVersion.latest()));
 167     }
 168 
 169     @Override
 170     public int isSupportedOption(String option) {
 171         if (option == null)
 172             throw new NullPointerException();
 173         return ToolOptions.isSupportedOption(option);






 174     }
 175 
 176 }
< prev index next >