View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.hadoop.hbase.classification.tools;
19  
20  import com.sun.javadoc.DocErrorReporter;
21  import com.sun.javadoc.LanguageVersion;
22  import com.sun.javadoc.RootDoc;
23  import com.sun.tools.doclets.standard.Standard;
24  
25  /**
26   * A <a href="http://java.sun.com/javase/6/docs/jdk/api/javadoc/doclet/">Doclet</a>
27   * that only includes class-level elements that are annotated with
28   * {@link org.apache.hadoop.hbase.classification.InterfaceAudience.Public}.
29   * Class-level elements with no annotation are excluded.
30   * In addition, all elements that are annotated with
31   * {@link org.apache.hadoop.hbase.classification.InterfaceAudience.Private} or
32   * {@link org.apache.hadoop.hbase.classification.InterfaceAudience.LimitedPrivate}
33   * are also excluded.
34   * It delegates to the Standard Doclet, and takes the same options.
35   */
36  public class IncludePublicAnnotationsStandardDoclet {
37  
38    public static LanguageVersion languageVersion() {
39      return LanguageVersion.JAVA_1_5;
40    }
41  
42    public static boolean start(RootDoc root) {
43      System.out.println(
44          IncludePublicAnnotationsStandardDoclet.class.getSimpleName());
45      RootDocProcessor.treatUnannotatedClassesAsPrivate = true;
46      return Standard.start(RootDocProcessor.process(root));
47    }
48  
49    public static int optionLength(String option) {
50      Integer length = StabilityOptions.optionLength(option);
51      if (length != null) {
52        return length;
53      }
54      return Standard.optionLength(option);
55    }
56  
57    public static boolean validOptions(String[][] options,
58        DocErrorReporter reporter) {
59      StabilityOptions.validOptions(options, reporter);
60      String[][] filteredOptions = StabilityOptions.filterOptions(options);
61      return Standard.validOptions(filteredOptions, reporter);
62    }
63  }