emptySet());
return ok ? 0 : 1;
}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/Doclet.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/Doclet.java
new file mode 100644
index 00000000000..9e7885675a6
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/Doclet.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.doclet;
+
+import java.util.ListIterator;
+import java.util.Locale;
+import java.util.Set;
+
+import javax.lang.model.SourceVersion;
+
+/**
+ * The user doclet must implement this interface, as described in the
+ * package description .
+ * Each implementation of a Doclet must provide a public no-argument constructor
+ * to be used by tools to instantiate the doclet. The tool infrastructure will
+ * interact with classes implementing this interface as follows:
+ *
+ * The tool will create an instance of a doclet using the no-arg constructor
+ * of the doclet class.
+ * Next, the tool calls the {@link #init init} method with an appropriate locale
+ * and reporter.
+ * Afterwards, the tool calls {@link #getSupportedOptions getSupportedOptions},
+ * and {@link #getSupportedSourceVersion getSupportedSourceVersion}.
+ * These methods are only called once.
+ * As appropriate, the tool calls the {@link #run run} method on the doclet
+ * object, giving it a DocletEnvironment object, from which the doclet can determine
+ * the elements to be included in the documentation.
+ *
+ *
+ * If a doclet object is created and used without the above protocol being followed,
+ * then the doclet's behavior is not defined by this interface specification.
+ *
To start the doclet, pass {@code -doclet} followed by the fully-qualified
+ * name of the entry point class (i.e. the implementation of this interface) on
+ * the javadoc tool command line.
+ *
+ * @since 9
+ */
+public interface Doclet {
+
+ /**
+ * Initializes this doclet with the given locale and error reporter.
+ * This locale will be used by the reporter and the doclet components.
+ * It is recommended to call this as early as possible, for a
+ * uniform localized user experience,
+ * @param locale the locale to be used
+ * @param reporter the reporter to be used
+ */
+ public void init(Locale locale, Reporter reporter);
+
+ /**
+ * Returns a name identifying the doclet. A name is a simple identifier
+ * without white spaces, as defined in The Java™ Language Specification ,
+ * section 6.2 "Names and Identifiers".
+ * @return name of the Doclet
+ */
+ public abstract String getName();
+
+ /**
+ * Returns all the supported options.
+ *
+ * @return a Set containing all the supported options, an empty set if none.
+ */
+ public Set getSupportedOptions();
+
+ /**
+ * Returns the version of the Java Programming Language supported
+ * by this doclet.
+ *
+ * @return the language version supported by this doclet, usually
+ * the latest version.
+ */
+ public SourceVersion getSupportedSourceVersion();
+
+ /**
+ * The entry point of the doclet. Further processing will commence as
+ * instructed by this method.
+ *
+ * @param environment from which essential information can be extracted
+ * @return true on success
+ */
+ public boolean run(DocletEnvironment environment);
+
+ /**
+ * An encapsulation of option name, aliases, parameters and descriptions
+ * as used by the Doclet.
+ */
+ interface Option {
+ /**
+ * Returns the number of arguments, this option will consume.
+ * @return number of consumed arguments
+ */
+ int getArgumentCount();
+
+ /**
+ * Returns the description of the option. For instance, the option "group", would
+ * return the synopsis of the option such as, "groups the documents".
+ * @return description if set, otherwise an empty String
+ */
+ String getDescription();
+
+ /**
+ * Returns the option kind.
+ * @return the kind of this option
+ */
+ Option.Kind getKind();
+
+ /**
+ * Returns the option name. For instance for option "-group", will return "group"
+ * @return name of the option, if set, otherwise an empty String
+ */
+ String getName();
+
+ /**
+ * Returns the parameters of the option. For instance "name <p1>:<p2>.."
+ * @return parameters if set, otherwise an empty String
+ */
+ String getParameters();
+
+ /**
+ * Checks if the given option name is handled by this option.
+ * @param option the option name with or without the leading "-"
+ * @return true if same
+ */
+ boolean matches(String option);
+
+ /**
+ * Processes the option and arguments as needed. This method will
+ * be invoked if the given option name matches the option.
+ * @param option the option
+ * @param arguments a ListIterator encapsulating the arguments
+ * @return true if operation succeeded, false otherwise
+ */
+ boolean process(String option, ListIterator arguments);
+
+ /**
+ * The kind of an option.
+ */
+ public static enum Kind {
+ /** an extended option, such as those prefixed with -X */
+ EXTENDED,
+ /** a standard option */
+ STANDARD,
+ /** an implementation reserved option */
+ OTHER;
+ }
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/DocletEnvironment.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/DocletEnvironment.java
new file mode 100644
index 00000000000..0cf4e565b26
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/DocletEnvironment.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.doclet;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.util.Elements;
+import javax.lang.model.util.Types;
+import javax.tools.JavaFileManager;
+
+import com.sun.source.util.DocTrees;
+
+/**
+ * Represents the operating environment of a single invocation
+ * of the doclet. This object can be used to access the program
+ * structures, various utilities and the user specified elements
+ * on the command line.
+ *
+ * @since 9
+ */
+public interface DocletEnvironment {
+ /**
+ * Returns the included
+ * classes, interfaces and enums in all packages.
+ *
+ * @return a Set containing {@link javax.lang.model.element.TypeElement TypeElements}.
+ */
+ Set getIncludedClasses();
+
+ /**
+ * Returns an instance of the {@code DocTrees} utility class.
+ * This class provides methods to access {@code TreePath}s, {@code DocCommentTree}s
+ * and so on.
+ * @return a utility class to operate on doc trees.
+ */
+ DocTrees getDocTrees();
+
+ /**
+ * Returns an instance of the {@code Elements} utility class.
+ * This class provides methods for operating on
+ * {@link javax.lang.model.element.Element elements}.
+ * @return a utility class to operate on elements
+ */
+ Elements getElementUtils();
+
+ /**
+ * Returns the selected elements that can be documented.
+ *
+ * @param elements those that need to be checked
+ * @return elements selected, an empty list if none.
+ */
+ List getSelectedElements(List extends Element> elements);
+
+ /**
+ * Returns the elements specified
+ * on the command line, usually PackageElements and TypeElements.
+ * If {@code -subpackages} and {@code -exclude} options
+ * are used, return all the non-excluded packages.
+ *
+ * @return elements specified on the command line.
+ */
+ Set getSpecifiedElements();
+
+ /**
+ * Returns an instance of the {@code Types} utility class.
+ * This class provides methods for operating on
+ * {@link javax.lang.model.type.TypeMirror type mirrors}.
+ * @return a utility class to operate on type mirrors
+ */
+ Types getTypeUtils();
+
+ /**
+ * Indicates if an element is included .
+ *
+ * @param e the Element in question
+ * @return true if included, false otherwise
+ */
+ boolean isIncluded(Element e);
+
+ /**
+ * Returns the file manager used to read and write files.
+ *
+ * @return the file manager used to read and write files
+ */
+ JavaFileManager getJavaFileManager();
+
+ /**
+ * Returns the source version of the source files that were read.
+ *
+ * @return the source version
+ */
+ SourceVersion getSourceVersion();
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/Reporter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/Reporter.java
new file mode 100644
index 00000000000..eb1b9453562
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/Reporter.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.doclet;
+
+import javax.lang.model.element.Element;
+import javax.tools.Diagnostic;
+
+import com.sun.source.util.DocTreePath;
+
+/**
+ * This interface provides error, warning and notice reporting.
+ *
+ * @since 9
+ */
+public interface Reporter {
+
+ /**
+ * Print error message and increment error count.
+ *
+ * @param kind specify the diagnostic kind
+ * @param msg message to print
+ */
+ void print(Diagnostic.Kind kind, String msg);
+
+ /**
+ * Print an error message and increment error count.
+ *
+ * @param kind specify the diagnostic kind
+ * @param path the DocTreePath of item where the error occurs
+ * @param msg message to print
+ */
+ void print(Diagnostic.Kind kind, DocTreePath path, String msg);
+
+ /**
+ * Print an error message and increment error count.
+ *
+ * @param kind specify the diagnostic kind
+ * @param e the Element for which the error occurs
+ * @param msg message to print
+ */
+ void print(Diagnostic.Kind kind, Element e, String msg);
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/package-info.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/package-info.java
new file mode 100644
index 00000000000..4043b68ee09
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/package-info.java
@@ -0,0 +1,251 @@
+/*
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * The Doclet API provides an environment which, in conjunction with
+ * the Language Model API and Compiler Tree API, allows clients
+ * to inspect the source-level structures of programs and
+ * libraries, including javadoc comments embedded in the source.
+ *
+ *
+ * Note: The declarations in this package supersede those
+ * in the older package {@code com.sun.javadoc}. For details on the
+ * mapping of old types to new types, see the
+ * Migration Guide .
+ *
+ *
+ *
+ * Doclets are invoked by javadoc and this API can be used to write out
+ * program information to files. For example, the standard doclet is
+ * invoked by default, to generate HTML documentation.
+ *
+
+ * The invocation is defined by the interface {@link jdk.javadoc.doclet.Doclet}
+ * -- the {@link jdk.javadoc.doclet.Doclet#run(DocletEnvironment) run} interface
+ * method, defines the entry point.
+ *
+ * public boolean run (DocletEnvironment environment)
+ *
+ * The {@link jdk.javadoc.doclet.DocletEnvironment} instance holds the environment that the
+ * doclet will be initialized with. From this environment all other information can be
+ * extracted, in the form of {@link javax.lang.model} elements. One can further use the
+ * APIs and utilities described by {@link javax.lang.model} to query Elements and Types.
+ *
+ *
+ *
+ *
Terminology
+ *
+ *
+ * When calling javadoc, one can pass in package names and source file names --
+ * these are called the specified PackageElements and TypeElements.
+ * Javadoc options are also passed in; the access control Javadoc options
+ * ({@code -public}, {@code -protected}, {@code -package},
+ * and {@code -private}) are used to filter program elements, producing a
+ * result set, called the included set, or "selected" set.
+ *
+
+ *
+ * A qualified element name is one that has its package
+ * name prepended to it, such as {@code java.lang.String}. A non-qualified
+ * name has no package name, such as {@code String}.
+ *
+ *
+ *
+ *
Example
+ *
+ * The following is an example doclet that displays information of a class
+ * and its members, supporting an option "someoption".
+ *
+ * import com.sun.source.doctree.DocCommentTree;
+ * import com.sun.source.util.DocTrees;
+ * import java.io.IOException;
+ * import java.util.Collections;
+ * import java.util.Set;
+ * import javax.lang.model.SourceVersion;
+ * import javax.lang.model.element.Element;
+ * import javax.lang.model.element.TypeElement;
+ * import jdk.javadoc.doclet.*;
+ *
+ * public class Example implements Doclet {
+ *
+ * @Override
+ * public void init(Locale locale, Reporter reporter) {
+ * return;
+ * }
+ *
+ * @Override
+ * public boolean run(RootDoc root) {
+ * // cache the DocTrees utility class to access DocComments
+ * DocTrees docTrees = root.getDocTrees();
+ *
+ * // location of an element in the same directory as overview.html
+ * try {
+ * Element barElement = null;
+ * for (Element e : root.getIncludedClasses()) {
+ * if (e.getSimpleName().toString().equals("FooBar")) {
+ * barElement = e;
+ * }
+ * }
+ * DocCommentTree docCommentTree =
+ * docTrees.getDocCommentTree(barElement, "overview.html");
+ * if (docCommentTree != null) {
+ * System.out.println("Overview html: " +
+ * docCommentTree.getFullBody());
+ * }
+ * } catch (IOException missing) {
+ * System.err.println("No overview.html found.");
+ * }
+ *
+ * for (TypeElement t : root.getIncludedClasses()) {
+ * System.out.println(t.getKind() + ":" + t);
+ * for (Element e : t.getEnclosedElements()) {
+ * DocCommentTree docCommentTree = docTrees.getDocCommentTree(e);
+ * if (docCommentTree != null) {
+ * System.out.println("Element (" + e.getKind() + ": " +
+ * e + ") has the following comments:");
+ * System.out.println("Entire body: " + docCommentTree.getFullBody());
+ * System.out.println("Block tags: " + docCommentTree.getBlockTags());
+ * } else {
+ * System.out.println("no comment.");
+ * }
+ * }
+ * }
+ * return true;
+ * }
+ *
+ * @Override
+ * public String getName() {
+ * return "Example";
+ * }
+ *
+ * private String someOption;
+ *
+ * @Override
+ * public Set<Option> getSupportedOptions() {
+ * Option[] options = {
+ * new Option() {
+ * public int getArgumentCount() {
+ * return 1;
+ * }
+ * public String getDescription() {
+ * return "someoption";
+ * }
+ * public Option.Kind getKind() {
+ * return Option.Kind.STANDARD;
+ * }
+ * public String getName() {
+ * return "someoption";
+ * }
+ * public String getParameters() {
+ * return "url";
+ * }
+ * public boolean matches(String option) {
+ * String opt = option.startsWith("-") ? option.substring(1) : option;
+ * return getName().equals(opt);
+ * }
+ * public boolean process(String option, ListIterator<String> arguments) {
+ * overviewpath = arguments.next();
+ * return true;
+ * }
+ * }
+ * };
+ * return new HashSet<Option>(Arrays.asList(options));
+ * }
+ *
+ * @Override
+ * public SourceVersion getSupportedSourceVersion() {
+ * // support the latest release
+ * return SourceVersion.latest();
+ * }
+ * }
+ *
+ *
+ * This doclet when invoked with a command line, such as:
+ *
+ * javadoc -doclet Example -sourcepath <source-location>
+ *
+ * will produce an output, such as:
+ *
+ * Overview.html: overview comments
+ * ...
+ * ...
+ * CLASS: SomeKlass
+ * .....
+ * Element (METHOD: main(java.lang.String...)) has the following comments:
+ * Entire body: The main entry point.
+ * Block tags: @param an array of Strings
+ * ...
+ *
+ *
+ *
+ *
+ * Many of the types in the old {@code com.sun.javadoc} API do not have equivalents in this
+ * package. Instead, types in the {@code javax.lang.model} and {@code com.sun.source} APIs
+ * are used instead.
+ *
+ *
The following table gives a guide to the mapping from old types to their replacements.
+ * In some cases, there is no direct equivalent.
+ *
+ *
+ Guide for mapping old types to new types
+ Old Type New Type
+ AnnotatedType javax.lang.model.type.Type
+ AnnotationDesc javax.lang.model.element.AnnotationMirror
+ AnnotationDesc.ElementValuePair javax.lang.model.element.AnnotationValue
+ AnnotationTypeDoc javax.lang.model.element.TypeElement
+ AnnotationTypeElementDoc javax.lang.model.element.ExecutableElement
+ AnnotationValue javax.lang.model.element.AnnotationValue
+ ClassDoc javax.lang.model.element.TypeElement
+ ConstructorDoc javax.lang.model.element.ExecutableElement
+ Doc javax.lang.model.element.Element
+ DocErrorReporter jdk.javadoc.doclet.Reporter
+ Doclet jdk.javadoc.doclet.Doclet
+ ExecutableMemberDoc javax.lang.model.element.ExecutableElement
+ FieldDoc javax.lang.model.element.VariableElement
+ LanguageVersion javax.lang.model.SourceVersion
+ MemberDoc javax.lang.model.element.Element
+ MethodDoc javax.lang.model.element.ExecutableElement
+ PackageDoc javax.lang.model.element.PackageElement
+ Parameter javax.lang.model.element.VariableElement
+ ParameterizedType javax.lang.model.type.DeclaredType
+ ParamTag com.sun.source.doctree.ParamTree
+ ProgramElementDoc javax.lang.model.element.Element
+ RootDoc jdk.javadoc.doclet.DocletEnvironment
+ SeeTag com.sun.source.doctree.LinkTree com.sun.source.doctree.SeeTree
+ SerialFieldTag com.sun.source.doctree.SerialFieldTree
+ SourcePosition com.sun.source.util.SourcePositions
+ Tag com.sun.source.doctree.DocTree
+ ThrowsTag com.sun.source.doctree.ThrowsTree
+ Type javax.lang.model.type.Type
+ TypeVariable javax.lang.model.type.TypeVariable
+ WildcardType javax.lang.model.type.WildcardType
+ *
+ *
+ * @see jdk.javadoc.doclet.Doclet
+ * @see jdk.javadoc.doclet.DocletEnvironment
+ * @since 9
+*/
+
+package jdk.javadoc.doclet;
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/taglet/Taglet.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/taglet/Taglet.java
new file mode 100644
index 00000000000..f102bd55314
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/taglet/Taglet.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.doclet.taglet;
+
+import java.util.List;
+import java.util.Set;
+
+import com.sun.source.doctree.DocTree;
+
+/**
+ * The interface for a custom tag used by Doclets. A custom
+ * tag must implement this interface, and must have a public
+ * default constructor (i.e. a public constructor with no
+ * parameters), by which, the doclet will instantiate and
+ * register the custom tag.
+ *
+ * @since 9
+ */
+
+public interface Taglet {
+
+ /**
+ * Returns the set of locations in which a taglet may be used.
+ * @return the set of locations in which a taglet may be used
+ * allowed in or an empty set.
+ */
+ Set getAllowedLocations();
+
+ /**
+ * Indicates the tag is an inline or a body tag.
+ * @return true if this Taglet
+ * is an inline tag, false otherwise.
+ */
+ public abstract boolean isInlineTag();
+
+ /**
+ * Returns the name of the tag.
+ * @return the name of this custom tag.
+ */
+ public abstract String getName();
+
+ /**
+ * Given the {@link DocTree DocTree} representation of this custom
+ * tag, return its string representation, which is output
+ * to the generated page.
+ * @param tag the Tag
representation of this custom tag.
+ * @return the string representation of this Tag
.
+ */
+ public abstract String toString(DocTree tag);
+
+ /**
+ * Given a List of {@link DocTree DocTrees} representing this custom
+ * tag, return its string representation, which is output
+ * to the generated page. This method should
+ * return null if this taglet represents an inline or body tag.
+ * @param tags the list of DocTree
s representing this custom tag.
+ * @return the string representation of this Tag
.
+ */
+ public abstract String toString(List extends DocTree> tags);
+
+ /**
+ * The kind of location.
+ */
+ public static enum Location {
+ /** In an Overview document. */
+ OVERVIEW,
+ /** In the documentation for a package. */
+ PACKAGE,
+ /** In the documentation for a class, interface or enum. */
+ TYPE,
+ /** In the documentation for a constructor. */
+ CONSTRUCTOR,
+ /** In the documentation for a method. */
+ METHOD,
+ /** In the documentation for a field. */
+ FIELD
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/taglet/package-info.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/taglet/package-info.java
new file mode 100644
index 00000000000..066f5e61472
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/taglet/package-info.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * The Taglet API provides a way to declare custom tags that can be
+ * used by the standard doclet.
+ *
+ *
+ * Note: The declarations in this package supersede those
+ * in the older package {@code com.sun.tools.doclets}.
+ *
+ *
+ * @since 9
+ */
+package jdk.javadoc.doclet.taglet;
diff --git a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/api/JavadocTaskImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTaskImpl.java
similarity index 95%
rename from langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/api/JavadocTaskImpl.java
rename to langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTaskImpl.java
index 18d24b1e6b5..97ec41633c9 100644
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/api/JavadocTaskImpl.java
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTaskImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,21 +23,20 @@
* questions.
*/
-package com.sun.tools.javadoc.api;
+package jdk.javadoc.internal.api;
-import com.sun.tools.javac.util.ClientCodeException;
+import java.util.Collections;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.tools.DocumentationTool.DocumentationTask;
import javax.tools.JavaFileObject;
+import com.sun.tools.javac.util.ClientCodeException;
import com.sun.tools.javac.util.Context;
-import com.sun.tools.javadoc.Start;
-import java.util.Collections;
-
import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api;
+import jdk.javadoc.internal.tool.Start;
/**
* Provides access to functionality specific to the JDK documentation tool,
diff --git a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/api/JavadocTool.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTool.java
similarity index 94%
rename from langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/api/JavadocTool.java
rename to langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTool.java
index 2aa5c1691dd..8b91c15df2e 100644
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/api/JavadocTool.java
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTool.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
* questions.
*/
-package com.sun.tools.javadoc.api;
+package jdk.javadoc.internal.api;
import java.io.InputStream;
import java.io.OutputStream;
@@ -52,7 +52,7 @@ import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api;
import com.sun.tools.javac.util.Log;
-import com.sun.tools.javadoc.ToolOption;
+import jdk.javadoc.internal.tool.ToolOption;
/**
* Provides access to functionality specific to the JDK documentation tool,
@@ -150,10 +150,7 @@ public class JavadocTool implements DocumentationTool {
PrintWriter err_pw = new PrintWriter(err == null ? System.err : err, true);
PrintWriter out_pw = new PrintWriter(out == null ? System.out : out);
try {
- String standardDocletName = "com.sun.tools.doclets.standard.Standard";
- ClassLoader cl = getClass().getClassLoader();
- return com.sun.tools.javadoc.Main.execute(
- "javadoc", err_pw, err_pw, out_pw, standardDocletName, cl, arguments);
+ return jdk.javadoc.internal.tool.Main.execute(arguments, err_pw);
} finally {
err_pw.flush();
out_pw.flush();
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java
new file mode 100644
index 00000000000..d82da4653cd
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java
@@ -0,0 +1,352 @@
+/*
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.util.List;
+
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
+import javax.lang.model.type.ArrayType;
+import javax.lang.model.type.DeclaredType;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.type.TypeVariable;
+import javax.lang.model.util.SimpleTypeVisitor9;
+
+import com.sun.tools.javac.util.DefinedBy;
+import com.sun.tools.javac.util.DefinedBy.Api;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
+
+import static jdk.javadoc.internal.doclets.formats.html.LinkInfoImpl.Kind.*;
+
+/**
+ * Print method and constructor info.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Robert Field
+ * @author Atul M Dambalkar
+ * @author Bhavesh Patel (Modified)
+ */
+public abstract class AbstractExecutableMemberWriter extends AbstractMemberWriter {
+
+ public AbstractExecutableMemberWriter(SubWriterHolderWriter writer, TypeElement typeElement) {
+ super(writer, typeElement);
+ }
+
+ public AbstractExecutableMemberWriter(SubWriterHolderWriter writer) {
+ super(writer);
+ }
+
+ /**
+ * Add the type parameters for the executable member.
+ *
+ * @param member the member to write type parameters for.
+ * @param htmltree the content tree to which the parameters will be added.
+ */
+ protected void addTypeParameters(ExecutableElement member, Content htmltree) {
+ Content typeParameters = getTypeParameters(member);
+ if (!typeParameters.isEmpty()) {
+ htmltree.addContent(typeParameters);
+ htmltree.addContent(writer.getSpace());
+ }
+ }
+
+ /**
+ * Get the type parameters for the executable member.
+ *
+ * @param member the member for which to get the type parameters.
+ * @return the type parameters.
+ */
+ protected Content getTypeParameters(ExecutableElement member) {
+ LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, MEMBER_TYPE_PARAMS, member);
+ return writer.getTypeParameterLinks(linkInfo);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Content getDeprecatedLink(Element member) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(utils.getFullyQualifiedName(member));
+ if (!utils.isConstructor(member)) {
+ sb.append(".");
+ sb.append(member.getSimpleName().toString());
+ }
+ sb.append(utils.flatSignature((ExecutableElement) member));
+
+ return writer.getDocLink(MEMBER, member, sb.toString());
+ }
+
+ /**
+ * Add the summary link for the member.
+ *
+ * @param context the id of the context where the link will be printed
+ * @param te the classDoc that we should link to
+ * @param member the member being linked to
+ * @param tdSummary the content tree to which the link will be added
+ */
+ @Override
+ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement te, Element member,
+ Content tdSummary) {
+ ExecutableElement ee = (ExecutableElement)member;
+ Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink,
+ writer.getDocLink(context, te, ee,
+ name(ee), false));
+ Content code = HtmlTree.CODE(memberLink);
+ addParameters(ee, false, code, name(ee).length() - 1);
+ tdSummary.addContent(code);
+ }
+
+ /**
+ * Add the inherited summary link for the member.
+ *
+ * @param te the type element that we should link to
+ * @param member the member being linked to
+ * @param linksTree the content tree to which the link will be added
+ */
+ @Override
+ protected void addInheritedSummaryLink(TypeElement te, Element member, Content linksTree) {
+ linksTree.addContent(writer.getDocLink(MEMBER, te, member, name(member), false));
+ }
+
+ /**
+ * Add the parameter for the executable member.
+ *
+ * @param member the member to write parameter for.
+ * @param param the parameter that needs to be written.
+ * @param isVarArg true if this is a link to var arg.
+ * @param tree the content tree to which the parameter information will be added.
+ */
+ protected void addParam(ExecutableElement member, VariableElement param,
+ boolean isVarArg, Content tree) {
+ Content link = writer.getLink(new LinkInfoImpl(configuration, EXECUTABLE_MEMBER_PARAM,
+ param.asType()).varargs(isVarArg));
+ tree.addContent(link);
+ if(name(param).length() > 0) {
+ tree.addContent(writer.getSpace());
+ tree.addContent(name(param));
+ }
+ }
+
+ /**
+ * Add the receiver annotations information.
+ *
+ * @param member the member to write receiver annotations for.
+ * @param rcvrType the receiver type.
+ * @param descList list of annotation description.
+ * @param tree the content tree to which the information will be added.
+ */
+ protected void addReceiverAnnotations(ExecutableElement member, TypeMirror rcvrType,
+ List extends AnnotationMirror> annotationMirrors, Content tree) {
+ writer.addReceiverAnnotationInfo(member, rcvrType, annotationMirrors, tree);
+ tree.addContent(writer.getSpace());
+ tree.addContent(utils.getTypeName(rcvrType, false));
+ LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, RECEIVER_TYPE, rcvrType);
+ tree.addContent(writer.getTypeParameterLinks(linkInfo));
+ tree.addContent(writer.getSpace());
+ tree.addContent("this");
+ }
+
+
+ /**
+ * Add all the parameters for the executable member.
+ *
+ * @param member the member to write parameters for.
+ * @param htmltree the content tree to which the parameters information will be added.
+ */
+ protected void addParameters(ExecutableElement member, Content htmltree, int indentSize) {
+ addParameters(member, true, htmltree, indentSize);
+ }
+
+ /**
+ * Add all the parameters for the executable member.
+ *
+ * @param member the member to write parameters for.
+ * @param includeAnnotations true if annotation information needs to be added.
+ * @param htmltree the content tree to which the parameters information will be added.
+ */
+ protected void addParameters(ExecutableElement member,
+ boolean includeAnnotations, Content htmltree, int indentSize) {
+ htmltree.addContent("(");
+ String sep = "";
+ List extends VariableElement> parameters = member.getParameters();
+ String indent = makeSpace(indentSize + 1);
+ TypeMirror rcvrType = member.getReceiverType();
+ if (includeAnnotations && rcvrType != null && utils.isAnnotated(rcvrType)) {
+ List extends AnnotationMirror> annotationMirrors = rcvrType.getAnnotationMirrors();
+ addReceiverAnnotations(member, rcvrType, annotationMirrors, htmltree);
+ sep = "," + DocletConstants.NL + indent;
+ }
+ int paramstart;
+ for (paramstart = 0; paramstart < parameters.size(); paramstart++) {
+ htmltree.addContent(sep);
+ VariableElement param = parameters.get(paramstart);
+
+ if (param.getKind() != ElementKind.INSTANCE_INIT) {
+ if (includeAnnotations) {
+ boolean foundAnnotations =
+ writer.addAnnotationInfo(indent.length(),
+ member, param, htmltree);
+ if (foundAnnotations) {
+ htmltree.addContent(DocletConstants.NL);
+ htmltree.addContent(indent);
+ }
+ }
+ addParam(member, param,
+ (paramstart == parameters.size() - 1) && member.isVarArgs(), htmltree);
+ break;
+ }
+ }
+
+ for (int i = paramstart + 1; i < parameters.size(); i++) {
+ htmltree.addContent(",");
+ htmltree.addContent(DocletConstants.NL);
+ htmltree.addContent(indent);
+ if (includeAnnotations) {
+ boolean foundAnnotations =
+ writer.addAnnotationInfo(indent.length(), member, parameters.get(i),
+ htmltree);
+ if (foundAnnotations) {
+ htmltree.addContent(DocletConstants.NL);
+ htmltree.addContent(indent);
+ }
+ }
+ addParam(member, parameters.get(i), (i == parameters.size() - 1) && member.isVarArgs(),
+ htmltree);
+ }
+ htmltree.addContent(")");
+ }
+
+ /**
+ * Add exceptions for the executable member.
+ *
+ * @param member the member to write exceptions for.
+ * @param htmltree the content tree to which the exceptions information will be added.
+ */
+ protected void addExceptions(ExecutableElement member, Content htmltree, int indentSize) {
+ List extends TypeMirror> exceptions = member.getThrownTypes();
+ if (!exceptions.isEmpty()) {
+ String indent = makeSpace(indentSize + 1 - 7);
+ htmltree.addContent(DocletConstants.NL);
+ htmltree.addContent(indent);
+ htmltree.addContent("throws ");
+ indent = makeSpace(indentSize + 1);
+ Content link = writer.getLink(new LinkInfoImpl(configuration, MEMBER, exceptions.get(0)));
+ htmltree.addContent(link);
+ for(int i = 1; i < exceptions.size(); i++) {
+ htmltree.addContent(",");
+ htmltree.addContent(DocletConstants.NL);
+ htmltree.addContent(indent);
+ Content exceptionLink = writer.getLink(new LinkInfoImpl(configuration, MEMBER,
+ exceptions.get(i)));
+ htmltree.addContent(exceptionLink);
+ }
+ }
+ }
+
+ protected TypeElement implementsMethodInIntfac(ExecutableElement method,
+ List intfacs) {
+ for (TypeElement intf : intfacs) {
+ List methods = utils.getMethods(intf);
+ if (!methods.isEmpty()) {
+ for (ExecutableElement md : methods) {
+ if (name(md).equals(name(method)) &&
+ md.toString().equals(method.toString())) {
+ return intf;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * For backward compatibility, include an anchor using the erasures of the
+ * parameters. NOTE: We won't need this method anymore after we fix
+ * see tags so that they use the type instead of the erasure.
+ *
+ * @param executableElement the ExecutableElement to anchor to.
+ * @return the 1.4.x style anchor for the executable element.
+ */
+ protected String getErasureAnchor(ExecutableElement executableElement) {
+ final StringBuilder buf = new StringBuilder(name(executableElement) + "(");
+ List extends VariableElement> parameters = executableElement.getParameters();
+ boolean foundTypeVariable = false;
+ for (int i = 0; i < parameters.size(); i++) {
+ if (i > 0) {
+ buf.append(",");
+ }
+ TypeMirror t = parameters.get(i).asType();
+ SimpleTypeVisitor9 stv = new SimpleTypeVisitor9() {
+ boolean foundTypeVariable = false;
+
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public Boolean visitArray(ArrayType t, Void p) {
+ visit(t.getComponentType());
+ buf.append(utils.getDimension(t));
+ return foundTypeVariable;
+ }
+
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public Boolean visitTypeVariable(TypeVariable t, Void p) {
+ buf.append(utils.asTypeElement(t).getQualifiedName());
+ foundTypeVariable = true;
+ return foundTypeVariable;
+ }
+
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public Boolean visitDeclared(DeclaredType t, Void p) {
+ buf.append(utils.getQualifiedTypeName(t));
+ return foundTypeVariable;
+ }
+
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ protected Boolean defaultAction(TypeMirror e, Void p) {
+ buf.append(e.toString());
+ return foundTypeVariable;
+ }
+ };
+
+ boolean isTypeVariable = stv.visit(t);
+ if (!foundTypeVariable) {
+ foundTypeVariable = isTypeVariable;
+ }
+ }
+ buf.append(")");
+ return foundTypeVariable ? writer.getName(buf.toString()) : null;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java
new file mode 100644
index 00000000000..b9d4d36c2a5
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java
@@ -0,0 +1,461 @@
+/*
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+import java.nio.file.*;
+import java.util.*;
+import java.util.zip.*;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.util.SimpleElementVisitor9;
+
+import com.sun.source.doctree.DocTree;
+import com.sun.tools.javac.util.DefinedBy;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder;
+
+/**
+ * Generate Index for all the Member Names with Indexing in
+ * Unicode Order. This class is a base class for {@link SingleIndexWriter} and
+ * {@link SplitIndexWriter}. It uses the functionality from
+ * {@link HtmlDocletWriter} to generate the Index Contents.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @see IndexBuilder
+ * @author Atul M Dambalkar
+ * @author Bhavesh Patel (Modified)
+ */
+public class AbstractIndexWriter extends HtmlDocletWriter {
+
+ /**
+ * The index of all the members with unicode character.
+ */
+ protected IndexBuilder indexbuilder;
+
+ /**
+ * This constructor will be used by {@link SplitIndexWriter}. Initializes
+ * path to this file and relative path from this file.
+ *
+ * @param configuration The current configuration
+ * @param path Path to the file which is getting generated.
+ * @param indexbuilder Unicode based Index from {@link IndexBuilder}
+ */
+ protected AbstractIndexWriter(ConfigurationImpl configuration,
+ DocPath path,
+ IndexBuilder indexbuilder)
+ throws IOException {
+ super(configuration, path);
+ this.indexbuilder = indexbuilder;
+ }
+
+ /**
+ * Get the index label for navigation bar.
+ *
+ * @return a content tree for the tree label
+ */
+ protected Content getNavLinkIndex() {
+ Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, indexLabel);
+ return li;
+ }
+
+ /**
+ * Add the member information for the unicode character along with the
+ * list of the members.
+ *
+ * @param uc Unicode for which member list information to be generated
+ * @param memberlist List of members for the unicode character
+ * @param contentTree the content tree to which the information will be added
+ */
+ protected void addContents(Character uc, Collection extends Element> memberlist,
+ Content contentTree) {
+ addHeading(uc, contentTree);
+ // Display the list only if there are elements to be displayed.
+ if (!memberlist.isEmpty()) {
+ Content dl = new HtmlTree(HtmlTag.DL);
+ for (Element element : memberlist) {
+ addDescription(dl, element);
+ }
+ contentTree.addContent(dl);
+ }
+ }
+
+ protected void addSearchContents(Character uc, List searchList,
+ Content contentTree) {
+ addHeading(uc, contentTree);
+ // Display the list only if there are elements to be displayed.
+ if (!searchList.isEmpty()) {
+ Content dl = new HtmlTree(HtmlTag.DL);
+ for (SearchIndexItem sii : searchList) {
+ addDescription(sii, dl);
+ }
+ contentTree.addContent(dl);
+ }
+ }
+
+ protected void addContents(Character uc, List extends Element> memberlist,
+ List searchList, Content contentTree) {
+ addHeading(uc, contentTree);
+ int memberListSize = memberlist.size();
+ int searchListSize = searchList.size();
+ int i = 0;
+ int j = 0;
+ Content dl = new HtmlTree(HtmlTag.DL);
+ while (i < memberListSize && j < searchListSize) {
+ String name = utils.getSimpleName(memberlist.get(i));
+ if (name.compareTo(searchList.get(j).getLabel()) < 0) {
+ addDescription(dl, memberlist.get(i));
+ i++;
+ } else if (name.compareTo(searchList.get(j).getLabel()) > 0) {
+ addDescription(searchList.get(j), dl);
+ j++;
+ } else {
+ addDescription(dl, memberlist.get(i));
+ addDescription(searchList.get(j), dl);
+ j++;
+ i++;
+ }
+ }
+ if (i >= memberListSize) {
+ while (j < searchListSize) {
+ addDescription(searchList.get(j), dl);
+ j++;
+ }
+ }
+ if (j >= searchListSize) {
+ while (i < memberListSize) {
+ addDescription(dl, memberlist.get(i));
+ i++;
+ }
+ }
+ contentTree.addContent(dl);
+ }
+
+ protected void addHeading(Character uc, Content contentTree) {
+ String unicode = uc.toString();
+ contentTree.addContent(getMarkerAnchorForIndex(unicode));
+ Content headContent = new StringContent(unicode);
+ Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, false,
+ HtmlStyle.title, headContent);
+ contentTree.addContent(heading);
+ }
+
+ protected void addDescription(Content dl, Element element) {
+ SearchIndexItem si = new SearchIndexItem();
+ new SimpleElementVisitor9() {
+
+ @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL)
+ public Void visitPackage(PackageElement e, Void p) {
+ addDescription(e, dl, si);
+ configuration.packageSearchIndex.add(si);
+ return null;
+ }
+
+ @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL)
+ public Void visitType(TypeElement e, Void p) {
+ addDescription(e, dl, si);
+ configuration.typeSearchIndex.add(si);
+ return null;
+ }
+
+ @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL)
+ protected Void defaultAction(Element e, Void p) {
+ addDescription(e, dl, si);
+ configuration.memberSearchIndex.add(si);
+ return null;
+ }
+
+ }.visit(element);
+ }
+
+ /**
+ * Add one line summary comment for the package.
+ *
+ * @param pkg the package to be documented
+ * @param dlTree the content tree to which the description will be added
+ */
+ protected void addDescription(PackageElement pkg, Content dlTree, SearchIndexItem si) {
+ Content link = getPackageLink(pkg, new StringContent(utils.getPackageName(pkg)));
+ si.setLabel(utils.getPackageName(pkg));
+ si.setCategory(getResource("doclet.Packages").toString());
+ Content dt = HtmlTree.DT(link);
+ dt.addContent(" - ");
+ dt.addContent(getResource("doclet.package"));
+ dt.addContent(" " + utils.getPackageName(pkg));
+ dlTree.addContent(dt);
+ Content dd = new HtmlTree(HtmlTag.DD);
+ addSummaryComment(pkg, dd);
+ dlTree.addContent(dd);
+ }
+
+ /**
+ * Add one line summary comment for the class.
+ *
+ * @param typeElement the class being documented
+ * @param dlTree the content tree to which the description will be added
+ */
+ protected void addDescription(TypeElement typeElement, Content dlTree, SearchIndexItem si) {
+ Content link = getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.INDEX, typeElement).strong(true));
+ si.setContainingPackage(utils.getPackageName(utils.containingPackage(typeElement)));
+ si.setLabel(utils.getSimpleName(typeElement));
+ si.setCategory(getResource("doclet.Types").toString());
+ Content dt = HtmlTree.DT(link);
+ dt.addContent(" - ");
+ addClassInfo(typeElement, dt);
+ dlTree.addContent(dt);
+ Content dd = new HtmlTree(HtmlTag.DD);
+ addComment(typeElement, dd);
+ dlTree.addContent(dd);
+ }
+
+ /**
+ * Add the classkind (class, interface, exception), error of the class
+ * passed.
+ *
+ * @param te the class being documented
+ * @param contentTree the content tree to which the class info will be added
+ */
+ protected void addClassInfo(TypeElement te, Content contentTree) {
+ contentTree.addContent(getResource("doclet.in",
+ utils.getTypeElementName(te, false),
+ getPackageLink(utils.containingPackage(te),
+ utils.getPackageName(utils.containingPackage(te)))
+ ));
+ }
+
+ /**
+ * Add description for Class, Field, Method or Constructor.
+ *
+ * @param member the member of the Class Kind
+ * @param dlTree the content tree to which the description will be added
+ * @param si search index item
+ */
+ protected void addDescription(Element member, Content dlTree, SearchIndexItem si) {
+
+ si.setContainingPackage(utils.getPackageName(utils.containingPackage(member)));
+ si.setContainingClass(utils.getSimpleName(utils.getEnclosingTypeElement(member)));
+ String name = utils.getSimpleName(member);
+ if (utils.isExecutableElement(member)) {
+ ExecutableElement ee = (ExecutableElement)member;
+ name = name + utils.flatSignature(ee);
+ si.setLabel(name);
+ if (!((utils.signature(ee)).equals(utils.flatSignature(ee)))) {
+ si.setUrl(getName(getAnchor(ee)));
+ }
+
+ } else {
+ si.setLabel(name);
+ }
+ si.setCategory(getResource("doclet.Members").toString());
+ Content span = HtmlTree.SPAN(HtmlStyle.memberNameLink,
+ getDocLink(LinkInfoImpl.Kind.INDEX, member, name));
+ Content dt = HtmlTree.DT(span);
+ dt.addContent(" - ");
+ addMemberDesc(member, dt);
+ dlTree.addContent(dt);
+ Content dd = new HtmlTree(HtmlTag.DD);
+ addComment(member, dd);
+ dlTree.addContent(dd);
+ }
+
+ protected void addDescription(SearchIndexItem sii, Content dlTree) {
+ String path = pathToRoot.isEmpty() ? "" : pathToRoot.getPath() + "/";
+ path += sii.getUrl();
+ HtmlTree labelLink = HtmlTree.A(path, new StringContent(sii.getLabel()));
+ Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.searchTagLink, labelLink));
+ dt.addContent(" - ");
+ dt.addContent(getResource("doclet.Search_tag_in", sii.getHolder()));
+ dlTree.addContent(dt);
+ Content dd = new HtmlTree(HtmlTag.DD);
+ if (sii.getDescription().isEmpty()) {
+ dd.addContent(getSpace());
+ } else {
+ dd.addContent(sii.getDescription());
+ }
+ dlTree.addContent(dd);
+ }
+
+ /**
+ * Add comment for each element in the index. If the element is deprecated
+ * and it has a @deprecated tag, use that comment. Else if the containing
+ * class for this element is deprecated, then add the word "Deprecated." at
+ * the start and then print the normal comment.
+ *
+ * @param element Index element
+ * @param contentTree the content tree to which the comment will be added
+ */
+ protected void addComment(Element element, Content contentTree) {
+ List extends DocTree> tags;
+ Content span = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
+ HtmlTree div = new HtmlTree(HtmlTag.DIV);
+ div.addStyle(HtmlStyle.block);
+ if (utils.isDeprecated(element)) {
+ div.addContent(span);
+ tags = utils.getBlockTags(element, DocTree.Kind.DEPRECATED);
+ if (!tags.isEmpty())
+ addInlineDeprecatedComment(element, tags.get(0), div);
+ contentTree.addContent(div);
+ } else {
+ TypeElement encl = utils.getEnclosingTypeElement(element);
+ while (encl != null) {
+ if (utils.isDeprecated(encl)) {
+ div.addContent(span);
+ contentTree.addContent(div);
+ break;
+ }
+ encl = utils.getEnclosingTypeElement(encl);
+ }
+ addSummaryComment(element, contentTree);
+ }
+ }
+
+ /**
+ * Add description about the Static Variable/Method/Constructor for a
+ * member.
+ *
+ * @param member MemberDoc for the member within the Class Kind
+ * @param contentTree the content tree to which the member description will be added
+ */
+ protected void addMemberDesc(Element member, Content contentTree) {
+ TypeElement containing = utils.getEnclosingTypeElement(member);
+ String classdesc = utils.getTypeElementName(containing, true) + " ";
+ if (utils.isField(member)) {
+ Content resource = getResource(utils.isStatic(member)
+ ? "doclet.Static_variable_in"
+ : "doclet.Variable_in", classdesc);
+ contentTree.addContent(resource);
+ } else if (utils.isConstructor(member)) {
+ contentTree.addContent(
+ getResource("doclet.Constructor_for", classdesc));
+ } else if (utils.isMethod(member)) {
+ Content resource = getResource(utils.isStatic(member)
+ ? "doclet.Static_method_in"
+ : "doclet.Method_in", classdesc);
+ contentTree.addContent(resource);
+ }
+ addPreQualifiedClassLink(LinkInfoImpl.Kind.INDEX, containing,
+ false, contentTree);
+ }
+
+ /**
+ * Get the marker anchor which will be added to the index documentation tree.
+ *
+ * @param anchorNameForIndex the anchor name attribute for index page
+ * @return a content tree for the marker anchor
+ */
+ public Content getMarkerAnchorForIndex(String anchorNameForIndex) {
+ return getMarkerAnchor(getNameForIndex(anchorNameForIndex), null);
+ }
+
+ /**
+ * Generate a valid HTML name for member index page.
+ *
+ * @param unicode the string that needs to be converted to valid HTML name.
+ * @return a valid HTML name string.
+ */
+ public String getNameForIndex(String unicode) {
+ return "I:" + getName(unicode);
+ }
+
+ protected void createSearchIndexFiles() {
+ createSearchIndexFile(DocPaths.PACKAGE_SEARCH_INDEX_JSON, DocPaths.PACKAGE_SEARCH_INDEX_ZIP,
+ configuration.packageSearchIndex);
+ createSearchIndexFile(DocPaths.TYPE_SEARCH_INDEX_JSON, DocPaths.TYPE_SEARCH_INDEX_ZIP,
+ configuration.typeSearchIndex);
+ createSearchIndexFile(DocPaths.MEMBER_SEARCH_INDEX_JSON, DocPaths.MEMBER_SEARCH_INDEX_ZIP,
+ configuration.memberSearchIndex);
+ createSearchIndexFile(DocPaths.TAG_SEARCH_INDEX_JSON, DocPaths.TAG_SEARCH_INDEX_ZIP,
+ configuration.tagSearchIndex);
+ }
+
+ protected void createSearchIndexFile(DocPath searchIndexFile, DocPath searchIndexZip,
+ List searchIndex) {
+ if (!searchIndex.isEmpty()) {
+ try {
+ StringBuilder searchVar = new StringBuilder("[");
+ boolean first = true;
+ DocFile searchFile = DocFile.createFileForOutput(configuration, searchIndexFile);
+ Path p = Paths.get(searchFile.getPath());
+ for (SearchIndexItem item : searchIndex) {
+ if (first) {
+ searchVar.append(item.toString());
+ first = false;
+ } else {
+ searchVar.append(",").append(item.toString());
+ }
+ }
+ searchVar.append("]");
+ Files.write(p, searchVar.toString().getBytes());
+ DocFile zipFile = DocFile.createFileForOutput(configuration, searchIndexZip);
+ try (FileOutputStream fos = new FileOutputStream(zipFile.getPath());
+ ZipOutputStream zos = new ZipOutputStream(fos)) {
+ zipFile(searchFile.getPath(), searchIndexFile, zos);
+ }
+ Files.delete(p);
+ } catch (IOException ie) {
+ throw new DocletAbortException(ie);
+ }
+ }
+ }
+
+ protected void zipFile(String inputFile, DocPath file, ZipOutputStream zos) {
+ try {
+ try {
+ ZipEntry ze = new ZipEntry(file.getPath());
+ zos.putNextEntry(ze);
+ try (FileInputStream fis = new FileInputStream(new File(inputFile))) {
+ byte[] buf = new byte[2048];
+ int len = fis.read(buf);
+ while (len > 0) {
+ zos.write(buf, 0, len);
+ len = fis.read(buf);
+ }
+ }
+ } finally {
+ zos.closeEntry();
+ }
+ } catch (IOException e) {
+ throw new DocletAbortException(e);
+ }
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java
new file mode 100644
index 00000000000..c963b909a52
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java
@@ -0,0 +1,708 @@
+/*
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.TypeParameterElement;
+import javax.lang.model.element.VariableElement;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.SimpleElementVisitor9;
+
+import com.sun.source.doctree.DocTree;
+import com.sun.tools.javac.util.DefinedBy;
+import com.sun.tools.javac.util.DefinedBy.Api;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.taglets.DeprecatedTaglet;
+import jdk.javadoc.internal.doclets.toolkit.util.MethodTypes;
+import jdk.javadoc.internal.doclets.toolkit.util.Utils;
+import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
+
+import static javax.lang.model.element.Modifier.*;
+
+/**
+ * The base class for member writers.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Robert Field
+ * @author Atul M Dambalkar
+ * @author Jamie Ho (Re-write)
+ * @author Bhavesh Patel (Modified)
+ */
+public abstract class AbstractMemberWriter {
+
+ protected final ConfigurationImpl configuration;
+ protected final Utils utils;
+ protected final SubWriterHolderWriter writer;
+ protected final TypeElement typeElement;
+ protected Map typeMap = new LinkedHashMap<>();
+ protected Set methodTypes = EnumSet.noneOf(MethodTypes.class);
+ private int methodTypesOr = 0;
+ public final boolean nodepr;
+
+ protected boolean printedSummaryHeader = false;
+
+ public AbstractMemberWriter(SubWriterHolderWriter writer, TypeElement typeElement) {
+ this.configuration = writer.configuration;
+ this.writer = writer;
+ this.nodepr = configuration.nodeprecated;
+ this.typeElement = typeElement;
+ this.utils = writer.configuration.utils;
+ }
+
+ public AbstractMemberWriter(SubWriterHolderWriter writer) {
+ this(writer, null);
+ }
+
+ /*** abstracts ***/
+
+ /**
+ * Add the summary label for the member.
+ *
+ * @param memberTree the content tree to which the label will be added
+ */
+ public abstract void addSummaryLabel(Content memberTree);
+
+ /**
+ * Get the summary for the member summary table.
+ *
+ * @return a string for the table summary
+ */
+ public abstract String getTableSummary();
+
+ /**
+ * Get the caption for the member summary table.
+ *
+ * @return a string for the table caption
+ */
+ public abstract Content getCaption();
+
+ /**
+ * Get the summary table header for the member.
+ *
+ * @param member the member to be documented
+ * @return the summary table header
+ */
+ public abstract List getSummaryTableHeader(Element member);
+
+ /**
+ * Add inherited summary label for the member.
+ *
+ * @param typeElement the TypeElement to which to link to
+ * @param inheritedTree the content tree to which the inherited summary label will be added
+ */
+ public abstract void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree);
+
+ /**
+ * Add the anchor for the summary section of the member.
+ *
+ * @param typeElement the TypeElement to be documented
+ * @param memberTree the content tree to which the summary anchor will be added
+ */
+ public abstract void addSummaryAnchor(TypeElement typeElement, Content memberTree);
+
+ /**
+ * Add the anchor for the inherited summary section of the member.
+ *
+ * @param typeElement the TypeElement to be documented
+ * @param inheritedTree the content tree to which the inherited summary anchor will be added
+ */
+ public abstract void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree);
+
+ /**
+ * Add the summary type for the member.
+ *
+ * @param member the member to be documented
+ * @param tdSummaryType the content tree to which the type will be added
+ */
+ protected abstract void addSummaryType(Element member, Content tdSummaryType);
+
+ /**
+ * Add the summary link for the member.
+ *
+ * @param typeElement the TypeElement to be documented
+ * @param member the member to be documented
+ * @param tdSummary the content tree to which the link will be added
+ */
+ protected void addSummaryLink(TypeElement typeElement, Element member, Content tdSummary) {
+ addSummaryLink(LinkInfoImpl.Kind.MEMBER, typeElement, member, tdSummary);
+ }
+
+ /**
+ * Add the summary link for the member.
+ *
+ * @param context the id of the context where the link will be printed
+ * @param typeElement the TypeElement to be documented
+ * @param member the member to be documented
+ * @param tdSummary the content tree to which the summary link will be added
+ */
+ protected abstract void addSummaryLink(LinkInfoImpl.Kind context,
+ TypeElement typeElement, Element member, Content tdSummary);
+
+ /**
+ * Add the inherited summary link for the member.
+ *
+ * @param typeElement the TypeElement to be documented
+ * @param member the member to be documented
+ * @param linksTree the content tree to which the inherited summary link will be added
+ */
+ protected abstract void addInheritedSummaryLink(TypeElement typeElement,
+ Element member, Content linksTree);
+
+ /**
+ * Get the deprecated link.
+ *
+ * @param member the member being linked to
+ * @return a content tree representing the link
+ */
+ protected abstract Content getDeprecatedLink(Element member);
+
+ /**
+ * Get the navigation summary link.
+ *
+ * @param typeElement the TypeElement to be documented
+ * @param link true if its a link else the label to be printed
+ * @return a content tree for the navigation summary link.
+ */
+ protected abstract Content getNavSummaryLink(TypeElement typeElement, boolean link);
+
+ /**
+ * Add the navigation detail link.
+ *
+ * @param link true if its a link else the label to be printed
+ * @param liNav the content tree to which the navigation detail link will be added
+ */
+ protected abstract void addNavDetailLink(boolean link, Content liNav);
+
+ /**
+ * Add the member name to the content tree.
+ *
+ * @param name the member name to be added to the content tree.
+ * @param htmltree the content tree to which the name will be added.
+ */
+ protected void addName(String name, Content htmltree) {
+ htmltree.addContent(name);
+ }
+
+ protected String typeString(Element member) {
+ return new SimpleElementVisitor9() {
+
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public String visitExecutable(ExecutableElement e, Void p) {
+ return utils.isMethod(e) ? e.getReturnType().toString() : "";
+ }
+
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public String visitVariable(VariableElement e, Void p) {
+ return e.toString();
+ }
+
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ protected String defaultAction(Element e, Void p) {
+ return "";
+ }
+ }.visit(member);
+ }
+
+ /**
+ * Add the modifier for the member. The modifiers are ordered as specified
+ * by The Java Language Specification .
+ *
+ * @param member the member for which teh modifier will be added.
+ * @param htmltree the content tree to which the modifier information will be added.
+ */
+ protected void addModifiers(Element member, Content htmltree) {
+ Set set = new TreeSet<>(member.getModifiers());
+
+ // remove the ones we really don't need
+ set.remove(NATIVE);
+ set.remove(SYNCHRONIZED);
+ set.remove(STRICTFP);
+
+ // According to JLS, we should not be showing public modifier for
+ // interface methods.
+ if ((utils.isField(member) || utils.isMethod(member))
+ && writer instanceof ClassWriterImpl
+ && utils.isInterface(((ClassWriterImpl) writer).getTypeElement())) {
+ // Remove the implicit abstract and public modifiers
+ if (utils.isMethod(member) && utils.isInterface(member.getEnclosingElement())) {
+ set.remove(ABSTRACT);
+ set.remove(PUBLIC);
+ }
+ if (!utils.isMethod(member)) {
+ set.remove(PUBLIC);
+ }
+ }
+ if (!set.isEmpty()) {
+ String mods = set.stream().map(m -> m.toString()).collect(Collectors.joining(" "));
+ htmltree.addContent(mods);
+ htmltree.addContent(writer.getSpace());
+ }
+ }
+
+ protected String makeSpace(int len) {
+ if (len <= 0) {
+ return "";
+ }
+ StringBuilder sb = new StringBuilder(len);
+ for (int i = 0; i < len; i++) {
+ sb.append(' ');
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Add the modifier and type for the member in the member summary.
+ *
+ * @param member the member to add the type for
+ * @param type the type to add
+ * @param tdSummaryType the content tree to which the modified and type will be added
+ */
+ protected void addModifierAndType(Element member, TypeMirror type,
+ Content tdSummaryType) {
+ HtmlTree code = new HtmlTree(HtmlTag.CODE);
+ addModifier(member, code);
+ if (type == null) {
+ code.addContent(utils.isClass(member) ? "class" : "interface");
+ code.addContent(writer.getSpace());
+ } else {
+ List extends TypeParameterElement> list = utils.isExecutableElement(member)
+ ? ((ExecutableElement)member).getTypeParameters()
+ : null;
+ if (list != null && !list.isEmpty()) {
+ Content typeParameters = ((AbstractExecutableMemberWriter) this)
+ .getTypeParameters((ExecutableElement)member);
+ code.addContent(typeParameters);
+ //Code to avoid ugly wrapping in member summary table.
+ if (typeParameters.charCount() > 10) {
+ code.addContent(new HtmlTree(HtmlTag.BR));
+ } else {
+ code.addContent(writer.getSpace());
+ }
+ code.addContent(
+ writer.getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
+ } else {
+ code.addContent(
+ writer.getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
+ }
+
+ }
+ tdSummaryType.addContent(code);
+ }
+
+ /**
+ * Add the modifier for the member.
+ *
+ * @param member the member to add the type for
+ * @param code the content tree to which the modified will be added
+ */
+ private void addModifier(Element member, Content code) {
+ if (utils.isProtected(member)) {
+ code.addContent("protected ");
+ } else if (utils.isPrivate(member)) {
+ code.addContent("private ");
+ } else if (!utils.isPublic(member)) { // Package private
+ code.addContent(configuration.getText("doclet.Package_private"));
+ code.addContent(" ");
+ }
+ boolean isAnnotatedTypeElement = utils.isAnnotationType(member.getEnclosingElement());
+ if (!isAnnotatedTypeElement && utils.isMethod(member)) {
+ if (!utils.isInterface(member.getEnclosingElement()) && utils.isAbstract(member)) {
+ code.addContent("abstract ");
+ }
+ if (utils.isDefault(member)) {
+ code.addContent("default ");
+ }
+ }
+ if (utils.isStatic(member)) {
+ code.addContent("static ");
+ }
+ }
+
+ /**
+ * Add the deprecated information for the given member.
+ *
+ * @param member the member being documented.
+ * @param contentTree the content tree to which the deprecated information will be added.
+ */
+ protected void addDeprecatedInfo(Element member, Content contentTree) {
+ Content output = (new DeprecatedTaglet()).getTagletOutput(member,
+ writer.getTagletWriterInstance(false));
+ if (!output.isEmpty()) {
+ Content deprecatedContent = output;
+ Content div = HtmlTree.DIV(HtmlStyle.block, deprecatedContent);
+ contentTree.addContent(div);
+ }
+ }
+
+ /**
+ * Add the comment for the given member.
+ *
+ * @param member the member being documented.
+ * @param htmltree the content tree to which the comment will be added.
+ */
+ protected void addComment(Element member, Content htmltree) {
+ if (!utils.getBody(member).isEmpty()) {
+ writer.addInlineComment(member, htmltree);
+ }
+ }
+
+ protected String name(Element member) {
+ return utils.getSimpleName(member);
+ }
+
+ /**
+ * Get the header for the section.
+ *
+ * @param member the member being documented.
+ * @return a header content for the section.
+ */
+ protected Content getHead(Element member) {
+ Content memberContent = new StringContent(name(member));
+ Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, memberContent);
+ return heading;
+ }
+
+ /**
+ * Return true if the given ProgramElement
is inherited
+ * by the class that is being documented.
+ *
+ * @param ped The ProgramElement
being checked.
+ * return true if the ProgramElement
is being inherited and
+ * false otherwise.
+ */
+ protected boolean isInherited(Element ped){
+ return (!utils.isPrivate(ped) &&
+ (!utils.isPackagePrivate(ped) ||
+ ped.getEnclosingElement().equals(ped.getEnclosingElement())));
+ }
+
+ /**
+ * Add deprecated information to the documentation tree
+ *
+ * @param deprmembers list of deprecated members
+ * @param headingKey the caption for the deprecated members table
+ * @param tableSummary the summary for the deprecated members table
+ * @param tableHeader table headers for the deprecated members table
+ * @param contentTree the content tree to which the deprecated members table will be added
+ */
+ protected void addDeprecatedAPI(Collection deprmembers, String headingKey,
+ String tableSummary, List tableHeader, Content contentTree) {
+ if (deprmembers.size() > 0) {
+ Content caption = writer.getTableCaption(configuration.getResource(headingKey));
+ Content table = (configuration.isOutputHtml5())
+ ? HtmlTree.TABLE(HtmlStyle.deprecatedSummary, caption)
+ : HtmlTree.TABLE(HtmlStyle.deprecatedSummary, tableSummary, caption);
+ table.addContent(writer.getSummaryTableHeader(tableHeader, "col"));
+ Content tbody = new HtmlTree(HtmlTag.TBODY);
+ boolean altColor = true;
+ for (Element member : deprmembers) {
+ HtmlTree td = HtmlTree.TD(HtmlStyle.colOne, getDeprecatedLink(member));
+ List extends DocTree> deprTrees = utils.getBlockTags(member, DocTree.Kind.DEPRECATED);
+ if (!deprTrees.isEmpty()) {
+ writer.addInlineDeprecatedComment(member, deprTrees.get(0), td);
+ }
+ HtmlTree tr = HtmlTree.TR(td);
+ tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
+ altColor = !altColor;
+ tbody.addContent(tr);
+ }
+ table.addContent(tbody);
+ Content li = HtmlTree.LI(HtmlStyle.blockList, table);
+ Content ul = HtmlTree.UL(HtmlStyle.blockList, li);
+ contentTree.addContent(ul);
+ }
+ }
+
+ /**
+ * Add use information to the documentation tree.
+ *
+ * @param mems list of program elements for which the use information will be added
+ * @param heading the section heading
+ * @param tableSummary the summary for the use table
+ * @param contentTree the content tree to which the use information will be added
+ */
+ protected void addUseInfo(List extends Element> mems,
+ Content heading, String tableSummary, Content contentTree) {
+ if (mems == null || mems.isEmpty()) {
+ return;
+ }
+ List extends Element> members = mems;
+ boolean printedUseTableHeader = false;
+ if (members.size() > 0) {
+ Content caption = writer.getTableCaption(heading);
+ Content table = (configuration.isOutputHtml5())
+ ? HtmlTree.TABLE(HtmlStyle.useSummary, caption)
+ : HtmlTree.TABLE(HtmlStyle.useSummary, tableSummary, caption);
+ Content tbody = new HtmlTree(HtmlTag.TBODY);
+ boolean altColor = true;
+ for (Element element : members) {
+ TypeElement te = utils.getEnclosingTypeElement(element);
+ if (!printedUseTableHeader) {
+ table.addContent(writer.getSummaryTableHeader(
+ this.getSummaryTableHeader(element), "col"));
+ printedUseTableHeader = true;
+ }
+ HtmlTree tr = new HtmlTree(HtmlTag.TR);
+ tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
+ altColor = !altColor;
+ HtmlTree tdFirst = new HtmlTree(HtmlTag.TD);
+ tdFirst.addStyle(HtmlStyle.colFirst);
+ writer.addSummaryType(this, element, tdFirst);
+ tr.addContent(tdFirst);
+ HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
+ tdLast.addStyle(HtmlStyle.colLast);
+ if (te != null
+ && !utils.isConstructor(element)
+ && !utils.isClass(element)
+ && !utils.isInterface(element)
+ && !utils.isAnnotationType(element)) {
+ HtmlTree name = new HtmlTree(HtmlTag.SPAN);
+ name.addStyle(HtmlStyle.typeNameLabel);
+ name.addContent(name(te) + ".");
+ tdLast.addContent(name);
+ }
+ addSummaryLink(utils.isClass(element) || utils.isInterface(element)
+ ? LinkInfoImpl.Kind.CLASS_USE
+ : LinkInfoImpl.Kind.MEMBER,
+ te, element, tdLast);
+ writer.addSummaryLinkComment(this, element, tdLast);
+ tr.addContent(tdLast);
+ tbody.addContent(tr);
+ }
+ table.addContent(tbody);
+ contentTree.addContent(table);
+ }
+ }
+
+ /**
+ * Add the navigation detail link.
+ *
+ * @param members the members to be linked
+ * @param liNav the content tree to which the navigation detail link will be added
+ */
+ protected void addNavDetailLink(SortedSet members, Content liNav) {
+ addNavDetailLink(!members.isEmpty(), liNav);
+ }
+
+ /**
+ * Add the navigation summary link.
+ *
+ * @param members members to be linked
+ * @param visibleMemberMap the visible inherited members map
+ * @param liNav the content tree to which the navigation summary link will be added
+ */
+ protected void addNavSummaryLink(SortedSet extends Element> members,
+ VisibleMemberMap visibleMemberMap, Content liNav) {
+ if (!members.isEmpty()) {
+ liNav.addContent(getNavSummaryLink(null, true));
+ return;
+ }
+
+ TypeElement superClass = utils.getSuperClass(typeElement);
+ while (superClass != null) {
+ if (visibleMemberMap.hasMembersFor(superClass)) {
+ liNav.addContent(getNavSummaryLink(superClass, true));
+ return;
+ }
+ superClass = utils.getSuperClass(superClass);
+ }
+ liNav.addContent(getNavSummaryLink(null, false));
+ }
+
+ protected void serialWarning(Element e, String key, String a1, String a2) {
+ if (configuration.serialwarn) {
+ configuration.getDocletSpecificMsg().warning(e, key, a1, a2);
+ }
+ }
+
+ /**
+ * Add the member summary for the given class.
+ *
+ * @param tElement the class that is being documented
+ * @param member the member being documented
+ * @param firstSentenceTags the first sentence tags to be added to the summary
+ * @param tableContents the list of contents to which the documentation will be added
+ * @param counter the counter for determining id and style for the table row
+ */
+ public void addMemberSummary(TypeElement tElement, Element member,
+ List extends DocTree> firstSentenceTags, List tableContents, int counter) {
+ HtmlTree tdSummaryType = new HtmlTree(HtmlTag.TD);
+ tdSummaryType.addStyle(HtmlStyle.colFirst);
+ writer.addSummaryType(this, member, tdSummaryType);
+ HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
+ setSummaryColumnStyle(tdSummary);
+ addSummaryLink(tElement, member, tdSummary);
+ writer.addSummaryLinkComment(this, member, firstSentenceTags, tdSummary);
+ HtmlTree tr = HtmlTree.TR(tdSummaryType);
+ tr.addContent(tdSummary);
+ if (utils.isMethod(member) && !utils.isAnnotationType(member)) {
+ int methodType = utils.isStatic(member) ? MethodTypes.STATIC.value() :
+ MethodTypes.INSTANCE.value();
+ if (utils.isInterface(member.getEnclosingElement())) {
+ methodType = utils.isAbstract(member)
+ ? methodType | MethodTypes.ABSTRACT.value()
+ : methodType | MethodTypes.DEFAULT.value();
+ } else {
+ methodType = utils.isAbstract(member)
+ ? methodType | MethodTypes.ABSTRACT.value()
+ : methodType | MethodTypes.CONCRETE.value();
+ }
+ if (utils.isDeprecated(member) || utils.isDeprecated(typeElement)) {
+ methodType = methodType | MethodTypes.DEPRECATED.value();
+ }
+ methodTypesOr = methodTypesOr | methodType;
+ String tableId = "i" + counter;
+ typeMap.put(tableId, methodType);
+ tr.addAttr(HtmlAttr.ID, tableId);
+ }
+ if (counter%2 == 0)
+ tr.addStyle(HtmlStyle.altColor);
+ else
+ tr.addStyle(HtmlStyle.rowColor);
+ tableContents.add(tr);
+ }
+
+ /**
+ * Generate the method types set and return true if the method summary table
+ * needs to show tabs.
+ *
+ * @return true if the table should show tabs
+ */
+ public boolean showTabs() {
+ int value;
+ for (MethodTypes type : EnumSet.allOf(MethodTypes.class)) {
+ value = type.value();
+ if ((value & methodTypesOr) == value) {
+ methodTypes.add(type);
+ }
+ }
+ boolean showTabs = methodTypes.size() > 1;
+ if (showTabs) {
+ methodTypes.add(MethodTypes.ALL);
+ }
+ return showTabs;
+ }
+
+ /**
+ * Set the style for the summary column.
+ *
+ * @param tdTree the column for which the style will be set
+ */
+ public void setSummaryColumnStyle(HtmlTree tdTree) {
+ tdTree.addStyle(HtmlStyle.colLast);
+ }
+
+ /**
+ * Add inherited member summary for the given class and member.
+ *
+ * @param tElement the class the inherited member belongs to
+ * @param nestedClass the inherited member that is summarized
+ * @param isFirst true if this is the first member in the list
+ * @param isLast true if this is the last member in the list
+ * @param linksTree the content tree to which the summary will be added
+ */
+ public void addInheritedMemberSummary(TypeElement tElement,
+ Element nestedClass, boolean isFirst, boolean isLast,
+ Content linksTree) {
+ writer.addInheritedMemberSummary(this, tElement, nestedClass, isFirst,
+ linksTree);
+ }
+
+ /**
+ * Get the inherited summary header for the given class.
+ *
+ * @param tElement the class the inherited member belongs to
+ * @return a content tree for the inherited summary header
+ */
+ public Content getInheritedSummaryHeader(TypeElement tElement) {
+ Content inheritedTree = writer.getMemberTreeHeader();
+ writer.addInheritedSummaryHeader(this, tElement, inheritedTree);
+ return inheritedTree;
+ }
+
+ /**
+ * Get the inherited summary links tree.
+ *
+ * @return a content tree for the inherited summary links
+ */
+ public Content getInheritedSummaryLinksTree() {
+ return new HtmlTree(HtmlTag.CODE);
+ }
+
+ /**
+ * Get the summary table tree for the given class.
+ *
+ * @param tElement the class for which the summary table is generated
+ * @param tableContents list of contents to be displayed in the summary table
+ * @return a content tree for the summary table
+ */
+ public Content getSummaryTableTree(TypeElement tElement, List tableContents) {
+ return writer.getSummaryTableTree(this, tElement, tableContents, showTabs());
+ }
+
+ /**
+ * Get the member tree to be documented.
+ *
+ * @param memberTree the content tree of member to be documented
+ * @return a content tree that will be added to the class documentation
+ */
+ public Content getMemberTree(Content memberTree) {
+ return writer.getMemberTree(memberTree);
+ }
+
+ /**
+ * Get the member tree to be documented.
+ *
+ * @param memberTree the content tree of member to be documented
+ * @param isLastContent true if the content to be added is the last content
+ * @return a content tree that will be added to the class documentation
+ */
+ public Content getMemberTree(Content memberTree, boolean isLastContent) {
+ if (isLastContent)
+ return HtmlTree.UL(HtmlStyle.blockListLast, memberTree);
+ else
+ return HtmlTree.UL(HtmlStyle.blockList, memberTree);
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java
new file mode 100644
index 00000000000..26061a83b8d
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+import java.util.*;
+
+import javax.lang.model.element.PackageElement;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+
+/**
+ * Abstract class to generate the overview files in
+ * Frame and Non-Frame format. This will be sub-classed by to
+ * generate overview-frame.html as well as overview-summary.html.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Atul M Dambalkar
+ * @author Bhavesh Patel (Modified)
+ */
+public abstract class AbstractPackageIndexWriter extends HtmlDocletWriter {
+
+ /**
+ * A Set of Packages to be documented.
+ */
+ protected SortedSet packages;
+
+ /**
+ * Constructor. Also initializes the packages variable.
+ *
+ * @param configuration The current configuration
+ * @param filename Name of the package index file to be generated.
+ */
+ public AbstractPackageIndexWriter(ConfigurationImpl configuration,
+ DocPath filename) throws IOException {
+ super(configuration, filename);
+ packages = configuration.packages;
+ }
+
+ /**
+ * Adds the navigation bar header to the documentation tree.
+ *
+ * @param body the document tree to which the navigation bar header will be added
+ */
+ protected abstract void addNavigationBarHeader(Content body);
+
+ /**
+ * Adds the navigation bar footer to the documentation tree.
+ *
+ * @param body the document tree to which the navigation bar footer will be added
+ */
+ protected abstract void addNavigationBarFooter(Content body);
+
+ /**
+ * Adds the overview header to the documentation tree.
+ *
+ * @param body the document tree to which the overview header will be added
+ */
+ protected abstract void addOverviewHeader(Content body);
+
+ /**
+ * Adds the packages list to the documentation tree.
+ *
+ * @param packages a collection of packagedoc objects
+ * @param text caption for the table
+ * @param tableSummary summary for the table
+ * @param body the document tree to which the packages list will be added
+ */
+ protected abstract void addPackagesList(Collection packages, String text,
+ String tableSummary, Content body);
+
+ /**
+ * Generate and prints the contents in the package index file. Call appropriate
+ * methods from the sub-class in order to generate Frame or Non
+ * Frame format.
+ *
+ * @param title the title of the window.
+ * @param includeScript boolean set true if windowtitle script is to be included
+ */
+ protected void buildPackageIndexFile(String title, boolean includeScript) throws IOException {
+ String windowOverview = configuration.getText(title);
+ Content body = getBody(includeScript, getWindowTitle(windowOverview));
+ addNavigationBarHeader(body);
+ addOverviewHeader(body);
+ addIndex(body);
+ addOverview(body);
+ addNavigationBarFooter(body);
+ printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
+ configuration.doctitle), includeScript, body);
+ }
+
+ /**
+ * Default to no overview, override to add overview.
+ *
+ * @param body the document tree to which the overview will be added
+ */
+ protected void addOverview(Content body) throws IOException {
+ }
+
+ /**
+ * Adds the frame or non-frame package index to the documentation tree.
+ *
+ * @param body the document tree to which the index will be added
+ */
+ protected void addIndex(Content body) {
+ addIndexContents(packages, "doclet.Package_Summary",
+ configuration.getText("doclet.Member_Table_Summary",
+ configuration.getText("doclet.Package_Summary"),
+ configuration.getText("doclet.packages")), body);
+ }
+
+ /**
+ * Adds package index contents. Call appropriate methods from
+ * the sub-classes. Adds it to the body HtmlTree
+ *
+ * @param packages a collection of packages to be documented
+ * @param text string which will be used as the heading
+ * @param tableSummary summary for the table
+ * @param body the document tree to which the index contents will be added
+ */
+ protected void addIndexContents(Collection packages, String text,
+ String tableSummary, Content body) {
+ if (!packages.isEmpty()) {
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.NAV))
+ ? HtmlTree.NAV()
+ : new HtmlTree(HtmlTag.DIV);
+ htmlTree.addStyle(HtmlStyle.indexNav);
+ HtmlTree ul = new HtmlTree(HtmlTag.UL);
+ addAllClassesLink(ul);
+ htmlTree.addContent(ul);
+ body.addContent(htmlTree);
+ addPackagesList(packages, text, tableSummary, body);
+ }
+ }
+
+ /**
+ * Adds the doctitle to the documentation tree, if it is specified on the command line.
+ *
+ * @param body the document tree to which the title will be added
+ */
+ protected void addConfigurationTitle(Content body) {
+ if (configuration.doctitle.length() > 0) {
+ Content title = new RawHtml(configuration.doctitle);
+ Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
+ HtmlStyle.title, title);
+ Content div = HtmlTree.DIV(HtmlStyle.header, heading);
+ body.addContent(div);
+ }
+ }
+
+ /**
+ * Returns highlighted "Overview", in the navigation bar as this is the
+ * overview page.
+ *
+ * @return a Content object to be added to the documentation tree
+ */
+ protected Content getNavLinkContents() {
+ Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, overviewLabel);
+ return li;
+ }
+
+ /**
+ * Do nothing. This will be overridden.
+ *
+ * @param div the document tree to which the all classes link will be added
+ */
+ protected void addAllClassesLink(Content div) {
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java
new file mode 100644
index 00000000000..68ede24c0cf
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+import java.util.*;
+
+import javax.lang.model.element.TypeElement;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+
+
+/**
+ * Abstract class to print the class hierarchy page for all the Classes. This
+ * is sub-classed by {@link PackageTreeWriter} and {@link TreeWriter} to
+ * generate the Package Tree and global Tree(for all the classes and packages)
+ * pages.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Atul M Dambalkar
+ */
+public abstract class AbstractTreeWriter extends HtmlDocletWriter {
+
+ /**
+ * The class and interface tree built by using {@link ClassTree}
+ */
+ protected final ClassTree classtree;
+
+ /**
+ * Constructor initializes classtree variable. This constructor will be used
+ * while generating global tree file "overview-tree.html".
+ *
+ * @param configuration The current configuration
+ * @param filename File to be generated.
+ * @param classtree Tree built by {@link ClassTree}.
+ * @throws IOException
+ * @throws DocletAbortException
+ */
+ protected AbstractTreeWriter(ConfigurationImpl configuration,
+ DocPath filename, ClassTree classtree)
+ throws IOException {
+ super(configuration, filename);
+ this.classtree = classtree;
+ }
+
+ /**
+ * Add each level of the class tree. For each sub-class or
+ * sub-interface indents the next level information.
+ * Recurses itself to add sub-classes info.
+ *
+ * @param parent the superclass or superinterface of the sset
+ * @param collection a collection of the sub-classes at this level
+ * @param isEnum true if we are generating a tree for enums
+ * @param contentTree the content tree to which the level information will be added
+ */
+ protected void addLevelInfo(TypeElement parent, Collection collection,
+ boolean isEnum, Content contentTree) {
+ if (!collection.isEmpty()) {
+ Content ul = new HtmlTree(HtmlTag.UL);
+ for (TypeElement local : collection) {
+ HtmlTree li = new HtmlTree(HtmlTag.LI);
+ li.addStyle(HtmlStyle.circle);
+ addPartialInfo(local, li);
+ addExtendsImplements(parent, local, li);
+ addLevelInfo(local, classtree.directSubClasses(local, isEnum),
+ isEnum, li); // Recurse
+ ul.addContent(li);
+ }
+ contentTree.addContent(ul);
+ }
+ }
+
+ /**
+ * Add the heading for the tree depending upon tree type if it's a
+ * Class Tree or Interface tree.
+ *
+ * @param sset classes which are at the most base level, all the
+ * other classes in this run will derive from these classes
+ * @param heading heading for the tree
+ * @param div the content tree to which the tree will be added
+ */
+ protected void addTree(SortedSet sset, String heading, HtmlTree div) {
+ addTree(sset, heading, div, false);
+ }
+
+ protected void addTree(SortedSet sset, String heading,
+ HtmlTree div, boolean isEnums) {
+ if (!sset.isEmpty()) {
+ TypeElement firstTypeElement = sset.first();
+ Content headingContent = getResource(heading);
+ Content sectionHeading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
+ headingContent);
+ HtmlTree htmlTree;
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ htmlTree = HtmlTree.SECTION(sectionHeading);
+ } else {
+ div.addContent(sectionHeading);
+ htmlTree = div;
+ }
+ addLevelInfo(!utils.isInterface(firstTypeElement) ? firstTypeElement : null,
+ sset, isEnums, htmlTree);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ div.addContent(htmlTree);
+ }
+ }
+ }
+
+ /**
+ * Add information regarding the classes which this class extends or
+ * implements.
+ *
+ * @param parent the parent class of the class being documented
+ * @param typeElement the TypeElement under consideration
+ * @param contentTree the content tree to which the information will be added
+ */
+ protected void addExtendsImplements(TypeElement parent, TypeElement typeElement,
+ Content contentTree) {
+ SortedSet interfaces = new TreeSet<>(utils.makeGeneralPurposeComparator());
+ typeElement.getInterfaces().stream().forEach((t) -> {
+ interfaces.add(utils.asTypeElement(t));
+ });
+ if (interfaces.size() > (utils.isInterface(typeElement) ? 1 : 0)) {
+ boolean isFirst = true;
+ for (TypeElement intf : interfaces) {
+ if (parent != intf) {
+ if (utils.isPublic(intf) || utils.isLinkable(intf)) {
+ if (isFirst) {
+ isFirst = false;
+ if (utils.isInterface(typeElement)) {
+ contentTree.addContent(" (");
+ contentTree.addContent(getResource("doclet.also"));
+ contentTree.addContent(" extends ");
+ } else {
+ contentTree.addContent(" (implements ");
+ }
+ } else {
+ contentTree.addContent(", ");
+ }
+ addPreQualifiedClassLink(LinkInfoImpl.Kind.TREE, intf, contentTree);
+ }
+ }
+ }
+ if (!isFirst) {
+ contentTree.addContent(")");
+ }
+ }
+ }
+
+ /**
+ * Add information about the class kind, if it's a "class" or "interface".
+ *
+ * @param typeElement the class being documented
+ * @param contentTree the content tree to which the information will be added
+ */
+ protected void addPartialInfo(TypeElement typeElement, Content contentTree) {
+ addPreQualifiedStrongClassLink(LinkInfoImpl.Kind.TREE, typeElement, contentTree);
+ }
+
+ /**
+ * Get the tree label for the navigation bar.
+ *
+ * @return a content tree for the tree label
+ */
+ protected Content getNavLinkTree() {
+ Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, treeLabel);
+ return li;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java
new file mode 100644
index 00000000000..6ba6f0afc4c
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder;
+
+
+/**
+ * Generate the file with list of all the classes in this run. This page will be
+ * used in the left-hand bottom frame, when "All Classes" link is clicked in
+ * the left-hand top frame. The name of the generated file is
+ * "allclasses-frame.html".
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Atul M Dambalkar
+ * @author Doug Kramer
+ * @author Bhavesh Patel (Modified)
+ */
+public class AllClassesFrameWriter extends HtmlDocletWriter {
+
+ /**
+ * Index of all the classes.
+ */
+ protected IndexBuilder indexbuilder;
+
+ /**
+ * BR tag to be used within a document tree.
+ */
+ final HtmlTree BR = new HtmlTree(HtmlTag.BR);
+
+ /**
+ * Construct AllClassesFrameWriter object. Also initializes the indexbuilder
+ * variable in this class.
+ * @param configuration The current configuration
+ * @param filename Path to the file which is getting generated.
+ * @param indexbuilder Unicode based Index from {@link IndexBuilder}
+ * @throws IOException
+ * @throws DocletAbortException
+ */
+ public AllClassesFrameWriter(ConfigurationImpl configuration,
+ DocPath filename, IndexBuilder indexbuilder)
+ throws IOException {
+ super(configuration, filename);
+ this.indexbuilder = indexbuilder;
+ }
+
+ /**
+ * Create AllClassesFrameWriter object. Then use it to generate the
+ * "allclasses-frame.html" file. Generate the file in the current or the
+ * destination directory.
+ *
+ * @param indexbuilder IndexBuilder object for all classes index.
+ * @throws DocletAbortException
+ */
+ public static void generate(ConfigurationImpl configuration,
+ IndexBuilder indexbuilder) {
+ AllClassesFrameWriter allclassgen;
+ DocPath filename = DocPaths.ALLCLASSES_FRAME;
+ try {
+ allclassgen = new AllClassesFrameWriter(configuration,
+ filename, indexbuilder);
+ allclassgen.buildAllClassesFile(true);
+ allclassgen.close();
+ filename = DocPaths.ALLCLASSES_NOFRAME;
+ allclassgen = new AllClassesFrameWriter(configuration,
+ filename, indexbuilder);
+ allclassgen.buildAllClassesFile(false);
+ allclassgen.close();
+ } catch (IOException exc) {
+ configuration.standardmessage.
+ error("doclet.exception_encountered",
+ exc.toString(), filename);
+ throw new DocletAbortException(exc);
+ }
+ }
+
+ /**
+ * Print all the classes in the file.
+ * @param wantFrames True if we want frames.
+ */
+ protected void buildAllClassesFile(boolean wantFrames) throws IOException {
+ String label = configuration.getText("doclet.All_Classes");
+ Content body = getBody(false, getWindowTitle(label));
+ Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
+ HtmlStyle.bar, allclassesLabel);
+ body.addContent(heading);
+ Content ul = new HtmlTree(HtmlTag.UL);
+ // Generate the class links and add it to the tdFont tree.
+ addAllClasses(ul, wantFrames);
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
+ ? HtmlTree.MAIN(HtmlStyle.indexContainer, ul)
+ : HtmlTree.DIV(HtmlStyle.indexContainer, ul);
+ body.addContent(htmlTree);
+ printHtmlDocument(null, false, body);
+ }
+
+ /**
+ * Use the sorted index of all the classes and add all the classes to the
+ * content list.
+ *
+ * @param content HtmlTree content to which all classes information will be added
+ * @param wantFrames True if we want frames.
+ */
+ protected void addAllClasses(Content content, boolean wantFrames) {
+ for (Character unicode : indexbuilder.index()) {
+ addContents(indexbuilder.getMemberList(unicode), wantFrames, content);
+ }
+ }
+
+ /**
+ * Given a list of classes, generate links for each class or interface.
+ * If the class kind is interface, print it in the italics font. Also all
+ * links should target the right-hand frame. If clicked on any class name
+ * in this page, appropriate class page should get opened in the right-hand
+ * frame.
+ *
+ * @param classlist Sorted list of classes.
+ * @param wantFrames True if we want frames.
+ * @param content HtmlTree content to which the links will be added
+ */
+ protected void addContents(Iterable extends Element> classlist, boolean wantFrames,
+ Content content) {
+ for (Element element : classlist) {
+ TypeElement typeElement = (TypeElement)element;
+ if (!utils.isCoreClass(typeElement)) {
+ continue;
+ }
+ Content label = interfaceName(typeElement, false);
+ Content linkContent;
+ if (wantFrames) {
+ linkContent = getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.ALL_CLASSES_FRAME, typeElement).label(label).target("classFrame"));
+ } else {
+ linkContent = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.DEFAULT, typeElement).label(label));
+ }
+ Content li = HtmlTree.LI(linkContent);
+ content.addContent(li);
+ }
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java
new file mode 100644
index 00000000000..0bb63a68f93
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java
@@ -0,0 +1,324 @@
+/*
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.TypeMirror;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeFieldWriter;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
+
+
+/**
+ * Writes annotation type field documentation in HTML format.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Bhavesh Patel
+ */
+public class AnnotationTypeFieldWriterImpl extends AbstractMemberWriter
+ implements AnnotationTypeFieldWriter, MemberSummaryWriter {
+
+ /**
+ * Construct a new AnnotationTypeFieldWriterImpl.
+ *
+ * @param writer the writer that will write the output.
+ * @param annotationType the AnnotationType that holds this member.
+ */
+ public AnnotationTypeFieldWriterImpl(SubWriterHolderWriter writer,
+ TypeElement annotationType) {
+ super(writer, annotationType);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getMemberSummaryHeader(TypeElement typeElement,
+ Content memberSummaryTree) {
+ memberSummaryTree.addContent(
+ HtmlConstants.START_OF_ANNOTATION_TYPE_FIELD_SUMMARY);
+ Content memberTree = writer.getMemberTreeHeader();
+ writer.addSummaryHeader(this, typeElement, memberTree);
+ return memberTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getMemberTreeHeader() {
+ return writer.getMemberTreeHeader();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addMemberTree(Content memberSummaryTree, Content memberTree) {
+ writer.addMemberTree(memberSummaryTree, memberTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addAnnotationFieldDetailsMarker(Content memberDetails) {
+ memberDetails.addContent(HtmlConstants.START_OF_ANNOTATION_TYPE_FIELD_DETAILS);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addAnnotationDetailsTreeHeader(TypeElement typeElement,
+ Content memberDetailsTree) {
+ if (!writer.printedAnnotationFieldHeading) {
+ memberDetailsTree.addContent(writer.getMarkerAnchor(
+ SectionName.ANNOTATION_TYPE_FIELD_DETAIL));
+ Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+ writer.fieldDetailsLabel);
+ memberDetailsTree.addContent(heading);
+ writer.printedAnnotationFieldHeading = true;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getAnnotationDocTreeHeader(Element member,
+ Content annotationDetailsTree) {
+ annotationDetailsTree.addContent(
+ writer.getMarkerAnchor(name(member)));
+ Content annotationDocTree = writer.getMemberTreeHeader();
+ Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+ heading.addContent(name(member));
+ annotationDocTree.addContent(heading);
+ return annotationDocTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getSignature(Element member) {
+ Content pre = new HtmlTree(HtmlTag.PRE);
+ writer.addAnnotationInfo(member, pre);
+ addModifiers(member, pre);
+ Content link =
+ writer.getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.MEMBER, getType(member)));
+ pre.addContent(link);
+ pre.addContent(writer.getSpace());
+ if (configuration.linksource) {
+ Content memberName = new StringContent(name(member));
+ writer.addSrcLink(member, memberName, pre);
+ } else {
+ addName(name(member), pre);
+ }
+ return pre;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addDeprecated(Element member, Content annotationDocTree) {
+ addDeprecatedInfo(member, annotationDocTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addComments(Element member, Content annotationDocTree) {
+ addComment(member, annotationDocTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addTags(Element member, Content annotationDocTree) {
+ writer.addTagsInfo(member, annotationDocTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getAnnotationDetails(Content annotationDetailsTree) {
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ HtmlTree htmlTree = HtmlTree.SECTION(getMemberTree(annotationDetailsTree));
+ return htmlTree;
+ }
+ return getMemberTree(annotationDetailsTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getAnnotationDoc(Content annotationDocTree,
+ boolean isLastContent) {
+ return getMemberTree(annotationDocTree, isLastContent);
+ }
+
+ /**
+ * Close the writer.
+ */
+ public void close() throws IOException {
+ writer.close();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addSummaryLabel(Content memberTree) {
+ Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+ writer.getResource("doclet.Field_Summary"));
+ memberTree.addContent(label);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getTableSummary() {
+ return configuration.getText("doclet.Member_Table_Summary",
+ configuration.getText("doclet.Field_Summary"),
+ configuration.getText("doclet.fields"));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getCaption() {
+ return configuration.getResource("doclet.Fields");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getSummaryTableHeader(Element member) {
+ List header = Arrays.asList(writer.getModifierTypeHeader(),
+ configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Fields"),
+ configuration.getText("doclet.Description")));
+ return header;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addSummaryAnchor(TypeElement typeElement, Content memberTree) {
+ memberTree.addContent(writer.getMarkerAnchor(
+ SectionName.ANNOTATION_TYPE_FIELD_SUMMARY));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element member,
+ Content tdSummary) {
+ Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink,
+ writer.getDocLink(context, member, name(member), false));
+ Content code = HtmlTree.CODE(memberLink);
+ tdSummary.addContent(code);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void addInheritedSummaryLink(TypeElement typeElement,
+ Element member, Content linksTree) {
+ //Not applicable.
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void addSummaryType(Element member, Content tdSummaryType) {
+ addModifierAndType(member, getType(member), tdSummaryType);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Content getDeprecatedLink(Element member) {
+ return writer.getDocLink(LinkInfoImpl.Kind.MEMBER,
+ member, utils.getFullyQualifiedName(member));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
+ if (link) {
+ return writer.getHyperLink(
+ SectionName.ANNOTATION_TYPE_FIELD_SUMMARY,
+ writer.getResource("doclet.navField"));
+ } else {
+ return writer.getResource("doclet.navField");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void addNavDetailLink(boolean link, Content liNav) {
+ if (link) {
+ liNav.addContent(writer.getHyperLink(
+ SectionName.ANNOTATION_TYPE_FIELD_DETAIL,
+ writer.getResource("doclet.navField")));
+ } else {
+ liNav.addContent(writer.getResource("doclet.navField"));
+ }
+ }
+ private TypeMirror getType(Element member) {
+ if (utils.isConstructor(member))
+ return null;
+ if (utils.isExecutableElement(member))
+ return utils.getReturnType((ExecutableElement)member);
+ return member.asType();
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
new file mode 100644
index 00000000000..221e467101b
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.lang.model.element.AnnotationValue;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeOptionalMemberWriter;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
+
+
+/**
+ * Writes annotation type optional member documentation in HTML format.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Jamie Ho
+ * @author Bhavesh Patel (Modified)
+ */
+public class AnnotationTypeOptionalMemberWriterImpl extends
+ AnnotationTypeRequiredMemberWriterImpl
+ implements AnnotationTypeOptionalMemberWriter, MemberSummaryWriter {
+
+ /**
+ * Construct a new AnnotationTypeOptionalMemberWriterImpl.
+ *
+ * @param writer the writer that will write the output.
+ * @param annotationType the AnnotationType that holds this member.
+ */
+ public AnnotationTypeOptionalMemberWriterImpl(SubWriterHolderWriter writer,
+ TypeElement annotationType) {
+ super(writer, annotationType);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getMemberSummaryHeader(TypeElement typeElement,
+ Content memberSummaryTree) {
+ memberSummaryTree.addContent(
+ HtmlConstants.START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY);
+ Content memberTree = writer.getMemberTreeHeader();
+ writer.addSummaryHeader(this, typeElement, memberTree);
+ return memberTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addMemberTree(Content memberSummaryTree, Content memberTree) {
+ writer.addMemberTree(memberSummaryTree, memberTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addDefaultValueInfo(Element member, Content annotationDocTree) {
+ if (utils.isAnnotationType(member)) {
+ ExecutableElement ee = (ExecutableElement)member;
+ AnnotationValue value = ee.getDefaultValue();
+ if (value != null) {
+ Content dt = HtmlTree.DT(writer.getResource("doclet.Default"));
+ Content dl = HtmlTree.DL(dt);
+ Content dd = HtmlTree.DD(new StringContent(value.toString()));
+ dl.addContent(dd);
+ annotationDocTree.addContent(dl);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void close() throws IOException {
+ writer.close();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addSummaryLabel(Content memberTree) {
+ Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+ writer.getResource("doclet.Annotation_Type_Optional_Member_Summary"));
+ memberTree.addContent(label);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getTableSummary() {
+ return configuration.getText("doclet.Member_Table_Summary",
+ configuration.getText("doclet.Annotation_Type_Optional_Member_Summary"),
+ configuration.getText("doclet.annotation_type_optional_members"));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getCaption() {
+ return configuration.getResource("doclet.Annotation_Type_Optional_Members");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getSummaryTableHeader(Element member) {
+ List header = Arrays.asList(writer.getModifierTypeHeader(),
+ configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Annotation_Type_Optional_Member"),
+ configuration.getText("doclet.Description")));
+ return header;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addSummaryAnchor(TypeElement typeElement, Content memberTree) {
+ memberTree.addContent(writer.getMarkerAnchor(
+ SectionName.ANNOTATION_TYPE_OPTIONAL_ELEMENT_SUMMARY));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
+ if (link) {
+ return writer.getHyperLink(
+ SectionName.ANNOTATION_TYPE_OPTIONAL_ELEMENT_SUMMARY,
+ writer.getResource("doclet.navAnnotationTypeOptionalMember"));
+ } else {
+ return writer.getResource("doclet.navAnnotationTypeOptionalMember");
+ }
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
new file mode 100644
index 00000000000..531d0a033f5
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
@@ -0,0 +1,324 @@
+/*
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.TypeMirror;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeRequiredMemberWriter;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
+
+
+/**
+ * Writes annotation type required member documentation in HTML format.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Jamie Ho
+ * @author Bhavesh Patel (Modified)
+ */
+public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
+ implements AnnotationTypeRequiredMemberWriter, MemberSummaryWriter {
+
+ /**
+ * Construct a new AnnotationTypeRequiredMemberWriterImpl.
+ *
+ * @param writer the writer that will write the output.
+ * @param annotationType the AnnotationType that holds this member.
+ */
+ public AnnotationTypeRequiredMemberWriterImpl(SubWriterHolderWriter writer,
+ TypeElement annotationType) {
+ super(writer, annotationType);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getMemberSummaryHeader(TypeElement typeElement,
+ Content memberSummaryTree) {
+ memberSummaryTree.addContent(
+ HtmlConstants.START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY);
+ Content memberTree = writer.getMemberTreeHeader();
+ writer.addSummaryHeader(this, typeElement, memberTree);
+ return memberTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getMemberTreeHeader() {
+ return writer.getMemberTreeHeader();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addMemberTree(Content memberSummaryTree, Content memberTree) {
+ writer.addMemberTree(memberSummaryTree, memberTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addAnnotationDetailsMarker(Content memberDetails) {
+ memberDetails.addContent(HtmlConstants.START_OF_ANNOTATION_TYPE_DETAILS);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addAnnotationDetailsTreeHeader(TypeElement classDoc,
+ Content memberDetailsTree) {
+ if (!writer.printedAnnotationHeading) {
+ memberDetailsTree.addContent(writer.getMarkerAnchor(
+ SectionName.ANNOTATION_TYPE_ELEMENT_DETAIL));
+ Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+ writer.annotationTypeDetailsLabel);
+ memberDetailsTree.addContent(heading);
+ writer.printedAnnotationHeading = true;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getAnnotationDocTreeHeader(Element member,
+ Content annotationDetailsTree) {
+ String simpleName = name(member);
+ annotationDetailsTree.addContent(writer.getMarkerAnchor(simpleName +
+ utils.signature((ExecutableElement) member)));
+ Content annotationDocTree = writer.getMemberTreeHeader();
+ Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+ heading.addContent(simpleName);
+ annotationDocTree.addContent(heading);
+ return annotationDocTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getSignature(Element member) {
+ Content pre = new HtmlTree(HtmlTag.PRE);
+ writer.addAnnotationInfo(member, pre);
+ addModifiers(member, pre);
+ Content link =
+ writer.getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.MEMBER, getType(member)));
+ pre.addContent(link);
+ pre.addContent(writer.getSpace());
+ if (configuration.linksource) {
+ Content memberName = new StringContent(name(member));
+ writer.addSrcLink(member, memberName, pre);
+ } else {
+ addName(name(member), pre);
+ }
+ return pre;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addDeprecated(Element member, Content annotationDocTree) {
+ addDeprecatedInfo(member, annotationDocTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addComments(Element member, Content annotationDocTree) {
+ addComment(member, annotationDocTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addTags(Element member, Content annotationDocTree) {
+ writer.addTagsInfo(member, annotationDocTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getAnnotationDetails(Content annotationDetailsTree) {
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ HtmlTree htmlTree = HtmlTree.SECTION(getMemberTree(annotationDetailsTree));
+ return htmlTree;
+ }
+ return getMemberTree(annotationDetailsTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getAnnotationDoc(Content annotationDocTree,
+ boolean isLastContent) {
+ return getMemberTree(annotationDocTree, isLastContent);
+ }
+
+ /**
+ * Close the writer.
+ */
+ public void close() throws IOException {
+ writer.close();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addSummaryLabel(Content memberTree) {
+ Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+ writer.getResource("doclet.Annotation_Type_Required_Member_Summary"));
+ memberTree.addContent(label);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getTableSummary() {
+ return configuration.getText("doclet.Member_Table_Summary",
+ configuration.getText("doclet.Annotation_Type_Required_Member_Summary"),
+ configuration.getText("doclet.annotation_type_required_members"));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getCaption() {
+ return configuration.getResource("doclet.Annotation_Type_Required_Members");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getSummaryTableHeader(Element member) {
+ List header = Arrays.asList(writer.getModifierTypeHeader(),
+ configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Annotation_Type_Required_Member"),
+ configuration.getText("doclet.Description")));
+ return header;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addSummaryAnchor(TypeElement typeElement, Content memberTree) {
+ memberTree.addContent(writer.getMarkerAnchor(
+ SectionName.ANNOTATION_TYPE_REQUIRED_ELEMENT_SUMMARY));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element member,
+ Content tdSummary) {
+ Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink,
+ writer.getDocLink(context, member, name(member), false));
+ Content code = HtmlTree.CODE(memberLink);
+ tdSummary.addContent(code);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void addInheritedSummaryLink(TypeElement typeElement,
+ Element member, Content linksTree) {
+ //Not applicable.
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void addSummaryType(Element member, Content tdSummaryType) {
+ addModifierAndType(member, getType(member), tdSummaryType);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Content getDeprecatedLink(Element member) {
+ String name = utils.getFullyQualifiedName(member) + "." + member.getSimpleName();
+ return writer.getDocLink(LinkInfoImpl.Kind.MEMBER, member, name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
+ if (link) {
+ return writer.getHyperLink(
+ SectionName.ANNOTATION_TYPE_REQUIRED_ELEMENT_SUMMARY,
+ writer.getResource("doclet.navAnnotationTypeRequiredMember"));
+ } else {
+ return writer.getResource("doclet.navAnnotationTypeRequiredMember");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void addNavDetailLink(boolean link, Content liNav) {
+ if (link) {
+ liNav.addContent(writer.getHyperLink(
+ SectionName.ANNOTATION_TYPE_ELEMENT_DETAIL,
+ writer.getResource("doclet.navAnnotationTypeMember")));
+ } else {
+ liNav.addContent(writer.getResource("doclet.navAnnotationTypeMember"));
+ }
+ }
+
+ private TypeMirror getType(Element member) {
+ return utils.isExecutableElement(member)
+ ? utils.getReturnType((ExecutableElement) member)
+ : member.asType();
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java
new file mode 100644
index 00000000000..3d6a248da57
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java
@@ -0,0 +1,465 @@
+/*
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.TypeMirror;
+
+import com.sun.source.doctree.DocTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.builders.MemberSummaryBuilder;
+import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
+
+/**
+ * Generate the Class Information Page.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @see java.util.Collections
+ * @see java.util.List
+ * @see java.util.ArrayList
+ * @see java.util.HashMap
+ *
+ * @author Atul M Dambalkar
+ * @author Robert Field
+ * @author Bhavesh Patel (Modified)
+ */
+public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
+ implements AnnotationTypeWriter {
+
+ protected TypeElement annotationType;
+
+ protected TypeMirror prev;
+
+ protected TypeMirror next;
+
+ /**
+ * @param configuration the configuration
+ * @param annotationType the annotation type being documented.
+ * @param prevType the previous class that was documented.
+ * @param nextType the next class being documented.
+ * @throws java.lang.Exception
+ */
+ public AnnotationTypeWriterImpl(ConfigurationImpl configuration,
+ TypeElement annotationType, TypeMirror prevType, TypeMirror nextType)
+ throws Exception {
+ super(configuration, DocPath.forClass(configuration.utils, annotationType));
+ this.annotationType = annotationType;
+ configuration.currentTypeElement = annotationType;
+ this.prev = prevType;
+ this.next = nextType;
+ }
+
+ /**
+ * Get this package link.
+ *
+ * @return a content tree for the package link
+ */
+ @Override
+ protected Content getNavLinkPackage() {
+ Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
+ packageLabel);
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+
+ /**
+ * Get the class link.
+ *
+ * @return a content tree for the class link
+ */
+ @Override
+ protected Content getNavLinkClass() {
+ Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel);
+ return li;
+ }
+
+ /**
+ * Get the class use link.
+ *
+ * @return a content tree for the class use link
+ */
+ @Override
+ protected Content getNavLinkClassUse() {
+ Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), useLabel);
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+
+ /**
+ * Get link to previous class.
+ *
+ * @return a content tree for the previous class link
+ */
+ @Override
+ public Content getNavLinkPrevious() {
+ Content li;
+ if (prev != null) {
+ Content prevLink = getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.CLASS, utils.asTypeElement(prev))
+ .label(prevclassLabel).strong(true));
+ li = HtmlTree.LI(prevLink);
+ }
+ else
+ li = HtmlTree.LI(prevclassLabel);
+ return li;
+ }
+
+ /**
+ * Get link to next class.
+ *
+ * @return a content tree for the next class link
+ */
+ @Override
+ public Content getNavLinkNext() {
+ Content li;
+ if (next != null) {
+ Content nextLink = getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.CLASS, utils.asTypeElement(next))
+ .label(nextclassLabel).strong(true));
+ li = HtmlTree.LI(nextLink);
+ }
+ else
+ li = HtmlTree.LI(nextclassLabel);
+ return li;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getHeader(String header) {
+ HtmlTree bodyTree = getBody(true, getWindowTitle(utils.getSimpleName(annotationType)));
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
+ ? HtmlTree.HEADER()
+ : bodyTree;
+ addTop(htmlTree);
+ addNavLinks(true, htmlTree);
+ if (configuration.allowTag(HtmlTag.HEADER)) {
+ bodyTree.addContent(htmlTree);
+ }
+ bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA);
+ HtmlTree div = new HtmlTree(HtmlTag.DIV);
+ div.addStyle(HtmlStyle.header);
+ PackageElement pkg = utils.containingPackage(annotationType);
+ if (!pkg.isUnnamed()) {
+ Content pkgNameContent = new StringContent(utils.getPackageName(pkg));
+ Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent);
+ div.addContent(pkgNameDiv);
+ }
+ LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.CLASS_HEADER, annotationType);
+ Content headerContent = new StringContent(header);
+ Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
+ HtmlStyle.title, headerContent);
+ heading.addContent(getTypeParameterLinks(linkInfo));
+ div.addContent(heading);
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ mainTree.addContent(div);
+ } else {
+ bodyTree.addContent(div);
+ }
+ return bodyTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getAnnotationContentHeader() {
+ return getContentHeader();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addFooter(Content contentTree) {
+ contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA);
+ Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
+ ? HtmlTree.FOOTER()
+ : contentTree;
+ addNavLinks(false, htmlTree);
+ addBottom(htmlTree);
+ if (configuration.allowTag(HtmlTag.FOOTER)) {
+ contentTree.addContent(htmlTree);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void printDocument(Content contentTree) throws IOException {
+ printHtmlDocument(configuration.metakeywords.getMetaKeywords(annotationType),
+ true, contentTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getAnnotationInfoTreeHeader() {
+ return getMemberTreeHeader();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getAnnotationInfo(Content annotationInfoTree) {
+ return getMemberTree(HtmlStyle.description, annotationInfoTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addAnnotationTypeSignature(String modifiers, Content annotationInfoTree) {
+ annotationInfoTree.addContent(new HtmlTree(HtmlTag.BR));
+ Content pre = new HtmlTree(HtmlTag.PRE);
+ addAnnotationInfo(annotationType, pre);
+ pre.addContent(modifiers);
+ LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.CLASS_SIGNATURE, annotationType);
+ Content annotationName = new StringContent(utils.getSimpleName(annotationType));
+ Content parameterLinks = getTypeParameterLinks(linkInfo);
+ if (configuration.linksource) {
+ addSrcLink(annotationType, annotationName, pre);
+ pre.addContent(parameterLinks);
+ } else {
+ Content span = HtmlTree.SPAN(HtmlStyle.memberNameLabel, annotationName);
+ span.addContent(parameterLinks);
+ pre.addContent(span);
+ }
+ annotationInfoTree.addContent(pre);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addAnnotationTypeDescription(Content annotationInfoTree) {
+ if(!configuration.nocomment) {
+ if (!utils.getBody(annotationType).isEmpty()) {
+ addInlineComment(annotationType, annotationInfoTree);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addAnnotationTypeTagInfo(Content annotationInfoTree) {
+ if(!configuration.nocomment) {
+ addTagsInfo(annotationType, annotationInfoTree);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addAnnotationTypeDeprecationInfo(Content annotationInfoTree) {
+ Content hr = new HtmlTree(HtmlTag.HR);
+ annotationInfoTree.addContent(hr);
+ List extends DocTree> deprs = utils.getBlockTags(annotationType, DocTree.Kind.DEPRECATED);
+ if (utils.isDeprecated(annotationType)) {
+ CommentHelper ch = utils.getCommentHelper(annotationType);
+ Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
+ Content div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
+ if (!deprs.isEmpty()) {
+
+ List extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0));
+ if (!commentTags.isEmpty()) {
+ div.addContent(getSpace());
+ addInlineDeprecatedComment(annotationType, deprs.get(0), div);
+ }
+ }
+ annotationInfoTree.addContent(div);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Content getNavLinkTree() {
+ Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE,
+ treeLabel, "", "");
+ Content li = HtmlTree.LI(treeLinkContent);
+ return li;
+ }
+
+ /**
+ * Add summary details to the navigation bar.
+ *
+ * @param subDiv the content tree to which the summary detail links will be added
+ */
+ @Override
+ protected void addSummaryDetailLinks(Content subDiv) {
+ try {
+ Content div = HtmlTree.DIV(getNavSummaryLinks());
+ div.addContent(getNavDetailLinks());
+ subDiv.addContent(div);
+ } catch (Exception e) {
+ throw new DocletAbortException(e);
+ }
+ }
+
+ /**
+ * Get summary links for navigation bar.
+ *
+ * @return the content tree for the navigation summary links
+ * @throws java.lang.Exception
+ */
+ protected Content getNavSummaryLinks() throws Exception {
+ Content li = HtmlTree.LI(summaryLabel);
+ li.addContent(getSpace());
+ Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
+ MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
+ configuration.getBuilderFactory().getMemberSummaryBuilder(this);
+ Content liNavField = new HtmlTree(HtmlTag.LI);
+ addNavSummaryLink(memberSummaryBuilder,
+ "doclet.navField",
+ VisibleMemberMap.Kind.ANNOTATION_TYPE_FIELDS, liNavField);
+ addNavGap(liNavField);
+ ulNav.addContent(liNavField);
+ Content liNavReq = new HtmlTree(HtmlTag.LI);
+ addNavSummaryLink(memberSummaryBuilder,
+ "doclet.navAnnotationTypeRequiredMember",
+ VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_REQUIRED, liNavReq);
+ addNavGap(liNavReq);
+ ulNav.addContent(liNavReq);
+ Content liNavOpt = new HtmlTree(HtmlTag.LI);
+ addNavSummaryLink(memberSummaryBuilder,
+ "doclet.navAnnotationTypeOptionalMember",
+ VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL, liNavOpt);
+ ulNav.addContent(liNavOpt);
+ return ulNav;
+ }
+
+ /**
+ * Add the navigation summary link.
+ *
+ * @param builder builder for the member to be documented
+ * @param label the label for the navigation
+ * @param type type to be documented
+ * @param liNav the content tree to which the navigation summary link will be added
+ */
+ protected void addNavSummaryLink(MemberSummaryBuilder builder,
+ String label, VisibleMemberMap.Kind type, Content liNav) {
+ AbstractMemberWriter writer = ((AbstractMemberWriter) builder.
+ getMemberSummaryWriter(type));
+ if (writer == null) {
+ liNav.addContent(getResource(label));
+ } else {
+ liNav.addContent(writer.getNavSummaryLink(null,
+ ! builder.getVisibleMemberMap(type).noVisibleMembers()));
+ }
+ }
+
+ /**
+ * Get detail links for the navigation bar.
+ *
+ * @return the content tree for the detail links
+ * @throws java.lang.Exception
+ */
+ protected Content getNavDetailLinks() throws Exception {
+ Content li = HtmlTree.LI(detailLabel);
+ li.addContent(getSpace());
+ Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
+ MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
+ configuration.getBuilderFactory().getMemberSummaryBuilder(this);
+ AbstractMemberWriter writerField =
+ ((AbstractMemberWriter) memberSummaryBuilder.
+ getMemberSummaryWriter(VisibleMemberMap.Kind.ANNOTATION_TYPE_FIELDS));
+ AbstractMemberWriter writerOptional =
+ ((AbstractMemberWriter) memberSummaryBuilder.
+ getMemberSummaryWriter(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL));
+ AbstractMemberWriter writerRequired =
+ ((AbstractMemberWriter) memberSummaryBuilder.
+ getMemberSummaryWriter(VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_REQUIRED));
+ Content liNavField = new HtmlTree(HtmlTag.LI);
+ if (writerField != null) {
+ writerField.addNavDetailLink(!utils.getAnnotationFields(annotationType).isEmpty(), liNavField);
+ } else {
+ liNavField.addContent(getResource("doclet.navField"));
+ }
+ addNavGap(liNavField);
+ ulNav.addContent(liNavField);
+ if (writerOptional != null){
+ Content liNavOpt = new HtmlTree(HtmlTag.LI);
+ writerOptional.addNavDetailLink(!annotationType.getAnnotationMirrors().isEmpty(), liNavOpt);
+ ulNav.addContent(liNavOpt);
+ } else if (writerRequired != null){
+ Content liNavReq = new HtmlTree(HtmlTag.LI);
+ writerRequired.addNavDetailLink(!annotationType.getAnnotationMirrors().isEmpty(), liNavReq);
+ ulNav.addContent(liNavReq);
+ } else {
+ Content liNav = HtmlTree.LI(getResource("doclet.navAnnotationTypeMember"));
+ ulNav.addContent(liNav);
+ }
+ return ulNav;
+ }
+
+ /**
+ * Add gap between navigation bar elements.
+ *
+ * @param liNav the content tree to which the gap will be added
+ */
+ protected void addNavGap(Content liNav) {
+ liNav.addContent(getSpace());
+ liNav.addContent("|");
+ liNav.addContent(getSpace());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public TypeElement getAnnotationTypeElement() {
+ return annotationType;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java
new file mode 100644
index 00000000000..9e3834dffba
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java
@@ -0,0 +1,554 @@
+/*
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
+import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+
+/**
+ * Generate class usage information.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Robert G. Field
+ * @author Bhavesh Patel (Modified)
+ */
+public class ClassUseWriter extends SubWriterHolderWriter {
+
+ final TypeElement typeElement;
+ Set pkgToPackageAnnotations = null;
+ final Map> pkgToClassTypeParameter;
+ final Map> pkgToClassAnnotations;
+ final Map> pkgToMethodTypeParameter;
+ final Map> pkgToMethodArgTypeParameter;
+ final Map> pkgToMethodReturnTypeParameter;
+ final Map> pkgToMethodAnnotations;
+ final Map> pkgToMethodParameterAnnotations;
+ final Map> pkgToFieldTypeParameter;
+ final Map> pkgToFieldAnnotations;
+ final Map> pkgToSubclass;
+ final Map> pkgToSubinterface;
+ final Map> pkgToImplementingClass;
+ final Map> pkgToField;
+ final Map> pkgToMethodReturn;
+ final Map> pkgToMethodArgs;
+ final Map> pkgToMethodThrows;
+ final Map> pkgToConstructorAnnotations;
+ final Map> pkgToConstructorParameterAnnotations;
+ final Map> pkgToConstructorArgs;
+ final Map> pkgToConstructorArgTypeParameter;
+ final Map> pkgToConstructorThrows;
+ final SortedSet pkgSet;
+ final MethodWriterImpl methodSubWriter;
+ final ConstructorWriterImpl constrSubWriter;
+ final FieldWriterImpl fieldSubWriter;
+ final NestedClassWriterImpl classSubWriter;
+ // Summary for various use tables.
+ final String classUseTableSummary;
+ final String subclassUseTableSummary;
+ final String subinterfaceUseTableSummary;
+ final String fieldUseTableSummary;
+ final String methodUseTableSummary;
+ final String constructorUseTableSummary;
+
+ /**
+ * The HTML tree for main tag.
+ */
+ protected HtmlTree mainTree = HtmlTree.MAIN();
+
+ /**
+ * Constructor.
+ *
+ * @param filename the file to be generated.
+ * @throws IOException
+ * @throws DocletAbortException
+ */
+ public ClassUseWriter(ConfigurationImpl configuration,
+ ClassUseMapper mapper, DocPath filename,
+ TypeElement typeElement) throws IOException {
+ super(configuration, filename);
+ this.typeElement = typeElement;
+ if (mapper.classToPackageAnnotations.containsKey(typeElement)) {
+ pkgToPackageAnnotations = new TreeSet<>(utils.makeClassUseComparator());
+ pkgToPackageAnnotations.addAll(mapper.classToPackageAnnotations.get(typeElement));
+ }
+ configuration.currentTypeElement = typeElement;
+ this.pkgSet = new TreeSet<>(utils.makePackageComparator());
+ this.pkgToClassTypeParameter = pkgDivide(mapper.classToClassTypeParam);
+ this.pkgToClassAnnotations = pkgDivide(mapper.classToClassAnnotations);
+ this.pkgToMethodTypeParameter = pkgDivide(mapper.classToMethodTypeParam);
+ this.pkgToMethodArgTypeParameter = pkgDivide(mapper.classToMethodArgTypeParam);
+ this.pkgToFieldTypeParameter = pkgDivide(mapper.classToFieldTypeParam);
+ this.pkgToFieldAnnotations = pkgDivide(mapper.annotationToField);
+ this.pkgToMethodReturnTypeParameter = pkgDivide(mapper.classToMethodReturnTypeParam);
+ this.pkgToMethodAnnotations = pkgDivide(mapper.classToMethodAnnotations);
+ this.pkgToMethodParameterAnnotations = pkgDivide(mapper.classToMethodParamAnnotation);
+ this.pkgToSubclass = pkgDivide(mapper.classToSubclass);
+ this.pkgToSubinterface = pkgDivide(mapper.classToSubinterface);
+ this.pkgToImplementingClass = pkgDivide(mapper.classToImplementingClass);
+ this.pkgToField = pkgDivide(mapper.classToField);
+ this.pkgToMethodReturn = pkgDivide(mapper.classToMethodReturn);
+ this.pkgToMethodArgs = pkgDivide(mapper.classToMethodArgs);
+ this.pkgToMethodThrows = pkgDivide(mapper.classToMethodThrows);
+ this.pkgToConstructorAnnotations = pkgDivide(mapper.classToConstructorAnnotations);
+ this.pkgToConstructorParameterAnnotations = pkgDivide(mapper.classToConstructorParamAnnotation);
+ this.pkgToConstructorArgs = pkgDivide(mapper.classToConstructorArgs);
+ this.pkgToConstructorArgTypeParameter = pkgDivide(mapper.classToConstructorArgTypeParam);
+ this.pkgToConstructorThrows = pkgDivide(mapper.classToConstructorThrows);
+ //tmp test
+ if (pkgSet.size() > 0 &&
+ mapper.classToPackage.containsKey(this.typeElement) &&
+ !pkgSet.equals(mapper.classToPackage.get(this.typeElement))) {
+ configuration.reporter.print(Diagnostic.Kind.WARNING,
+ "Internal error: package sets don't match: "
+ + pkgSet + " with: " + mapper.classToPackage.get(this.typeElement));
+ }
+ methodSubWriter = new MethodWriterImpl(this);
+ constrSubWriter = new ConstructorWriterImpl(this);
+ fieldSubWriter = new FieldWriterImpl(this);
+ classSubWriter = new NestedClassWriterImpl(this);
+ classUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
+ configuration.getText("doclet.classes"));
+ subclassUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
+ configuration.getText("doclet.subclasses"));
+ subinterfaceUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
+ configuration.getText("doclet.subinterfaces"));
+ fieldUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
+ configuration.getText("doclet.fields"));
+ methodUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
+ configuration.getText("doclet.methods"));
+ constructorUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
+ configuration.getText("doclet.constructors"));
+ }
+
+ /**
+ * Write out class use pages.
+ * @throws DocletAbortException
+ */
+ public static void generate(ConfigurationImpl configuration, ClassTree classtree) {
+ ClassUseMapper mapper = new ClassUseMapper(configuration, classtree);
+ for (TypeElement aClass : configuration.root.getIncludedClasses()) {
+ // If -nodeprecated option is set and the containing package is marked
+ // as deprecated, do not generate the class-use page. We will still generate
+ // the class-use page if the class is marked as deprecated but the containing
+ // package is not since it could still be linked from that package-use page.
+ if (!(configuration.nodeprecated &&
+ configuration.utils.isDeprecated(configuration.utils.containingPackage(aClass))))
+ ClassUseWriter.generate(configuration, mapper, aClass);
+ }
+ for (PackageElement pkg : configuration.packages) {
+ // If -nodeprecated option is set and the package is marked
+ // as deprecated, do not generate the package-use page.
+ if (!(configuration.nodeprecated && configuration.utils.isDeprecated(pkg)))
+ PackageUseWriter.generate(configuration, mapper, pkg);
+ }
+ }
+
+ private Map> pkgDivide(Map> classMap) {
+ Map> map = new HashMap<>();
+ List extends Element> elements = (List extends Element>) classMap.get(typeElement);
+ if (elements != null) {
+ Collections.sort(elements, utils.makeClassUseComparator());
+ for (Element e : elements) {
+ PackageElement pkg = utils.containingPackage(e);
+ pkgSet.add(pkg);
+ List inPkg = map.get(pkg);
+ if (inPkg == null) {
+ inPkg = new ArrayList<>();
+ map.put(pkg, inPkg);
+ }
+ inPkg.add(e);
+ }
+ }
+ return map;
+ }
+
+ /**
+ * Generate a class page.
+ */
+ public static void generate(ConfigurationImpl configuration, ClassUseMapper mapper,
+ TypeElement typeElement) {
+ ClassUseWriter clsgen;
+ DocPath path = DocPath.forPackage(configuration.utils, typeElement)
+ .resolve(DocPaths.CLASS_USE)
+ .resolve(DocPath.forName(configuration.utils, typeElement));
+ try {
+ clsgen = new ClassUseWriter(configuration, mapper, path, typeElement);
+ clsgen.generateClassUseFile();
+ clsgen.close();
+ } catch (IOException exc) {
+ configuration.standardmessage.
+ error("doclet.exception_encountered",
+ exc.toString(), path.getPath());
+ throw new DocletAbortException(exc);
+ }
+ }
+
+ /**
+ * Generate the class use elements.
+ */
+ protected void generateClassUseFile() throws IOException {
+ HtmlTree body = getClassUseHeader();
+ HtmlTree div = new HtmlTree(HtmlTag.DIV);
+ div.addStyle(HtmlStyle.classUseContainer);
+ if (pkgSet.size() > 0) {
+ addClassUse(div);
+ } else {
+ div.addContent(getResource("doclet.ClassUse_No.usage.of.0",
+ utils.getFullyQualifiedName(typeElement)));
+ }
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ mainTree.addContent(div);
+ body.addContent(mainTree);
+ } else {
+ body.addContent(div);
+ }
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
+ ? HtmlTree.FOOTER()
+ : body;
+ addNavLinks(false, htmlTree);
+ addBottom(htmlTree);
+ if (configuration.allowTag(HtmlTag.FOOTER)) {
+ body.addContent(htmlTree);
+ }
+ printHtmlDocument(null, true, body);
+ }
+
+ /**
+ * Add the class use documentation.
+ *
+ * @param contentTree the content tree to which the class use information will be added
+ */
+ protected void addClassUse(Content contentTree) throws IOException {
+ HtmlTree ul = new HtmlTree(HtmlTag.UL);
+ ul.addStyle(HtmlStyle.blockList);
+ if (configuration.packages.size() > 1) {
+ addPackageList(ul);
+ addPackageAnnotationList(ul);
+ }
+ addClassList(ul);
+ contentTree.addContent(ul);
+ }
+
+ /**
+ * Add the packages elements that use the given class.
+ *
+ * @param contentTree the content tree to which the packages elements will be added
+ */
+ protected void addPackageList(Content contentTree) throws IOException {
+ Content caption = getTableCaption(configuration.getResource(
+ "doclet.ClassUse_Packages.that.use.0",
+ getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement))));
+ Content table = (configuration.isOutputHtml5())
+ ? HtmlTree.TABLE(HtmlStyle.useSummary, caption)
+ : HtmlTree.TABLE(HtmlStyle.useSummary, useTableSummary, caption);
+ table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
+ Content tbody = new HtmlTree(HtmlTag.TBODY);
+ boolean altColor = true;
+ for (PackageElement pkg : pkgSet) {
+ HtmlTree tr = new HtmlTree(HtmlTag.TR);
+ tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
+ altColor = !altColor;
+ addPackageUse(pkg, tr);
+ tbody.addContent(tr);
+ }
+ table.addContent(tbody);
+ Content li = HtmlTree.LI(HtmlStyle.blockList, table);
+ contentTree.addContent(li);
+ }
+
+ /**
+ * Add the package annotation elements.
+ *
+ * @param contentTree the content tree to which the package annotation elements will be added
+ */
+ protected void addPackageAnnotationList(Content contentTree) throws IOException {
+ if (!utils.isAnnotationType(typeElement) ||
+ pkgToPackageAnnotations == null ||
+ pkgToPackageAnnotations.isEmpty()) {
+ return;
+ }
+ Content caption = getTableCaption(configuration.getResource(
+ "doclet.ClassUse_PackageAnnotation",
+ getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement))));
+ Content table = (configuration.isOutputHtml5())
+ ? HtmlTree.TABLE(HtmlStyle.useSummary, caption)
+ : HtmlTree.TABLE(HtmlStyle.useSummary, useTableSummary, caption);
+ table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
+ Content tbody = new HtmlTree(HtmlTag.TBODY);
+ boolean altColor = true;
+ for (PackageElement pkg : pkgToPackageAnnotations) {
+ HtmlTree tr = new HtmlTree(HtmlTag.TR);
+ tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
+ altColor = !altColor;
+ Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst, getPackageLink(pkg));
+ tr.addContent(tdFirst);
+ HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
+ tdLast.addStyle(HtmlStyle.colLast);
+ addSummaryComment(pkg, tdLast);
+ tr.addContent(tdLast);
+ tbody.addContent(tr);
+ }
+ table.addContent(tbody);
+ Content li = HtmlTree.LI(HtmlStyle.blockList, table);
+ contentTree.addContent(li);
+ }
+
+ /**
+ * Add the class elements that use the given class.
+ *
+ * @param contentTree the content tree to which the class elements will be added
+ */
+ protected void addClassList(Content contentTree) throws IOException {
+ HtmlTree ul = new HtmlTree(HtmlTag.UL);
+ ul.addStyle(HtmlStyle.blockList);
+ for (PackageElement pkg : pkgSet) {
+ Content markerAnchor = getMarkerAnchor(getPackageAnchorName(pkg));
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.SECTION))
+ ? HtmlTree.SECTION(markerAnchor)
+ : HtmlTree.LI(HtmlStyle.blockList, markerAnchor);
+ Content link = getResource("doclet.ClassUse_Uses.of.0.in.1",
+ getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER,
+ typeElement)),
+ getPackageLink(pkg, utils.getPackageName(pkg)));
+ Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link);
+ htmlTree.addContent(heading);
+ addClassUse(pkg, htmlTree);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
+ } else {
+ ul.addContent(htmlTree);
+ }
+ }
+ Content li = HtmlTree.LI(HtmlStyle.blockList, ul);
+ contentTree.addContent(li);
+ }
+
+ /**
+ * Add the package use information.
+ *
+ * @param pkg the package that uses the given class
+ * @param contentTree the content tree to which the package use information will be added
+ */
+ protected void addPackageUse(PackageElement pkg, Content contentTree) throws IOException {
+ Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst,
+ getHyperLink(getPackageAnchorName(pkg), new StringContent(utils.getPackageName(pkg))));
+ contentTree.addContent(tdFirst);
+ HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
+ tdLast.addStyle(HtmlStyle.colLast);
+ addSummaryComment(pkg, tdLast);
+ contentTree.addContent(tdLast);
+ }
+
+ /**
+ * Add the class use information.
+ *
+ * @param pkg the package that uses the given class
+ * @param contentTree the content tree to which the class use information will be added
+ */
+ protected void addClassUse(PackageElement pkg, Content contentTree) throws IOException {
+ Content classLink = getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement));
+ Content pkgLink = getPackageLink(pkg, utils.getPackageName(pkg));
+ classSubWriter.addUseInfo(pkgToClassAnnotations.get(pkg),
+ configuration.getResource("doclet.ClassUse_Annotation", classLink,
+ pkgLink), classUseTableSummary, contentTree);
+ classSubWriter.addUseInfo(pkgToClassTypeParameter.get(pkg),
+ configuration.getResource("doclet.ClassUse_TypeParameter", classLink,
+ pkgLink), classUseTableSummary, contentTree);
+ classSubWriter.addUseInfo(pkgToSubclass.get(pkg),
+ configuration.getResource("doclet.ClassUse_Subclass", classLink,
+ pkgLink), subclassUseTableSummary, contentTree);
+ classSubWriter.addUseInfo(pkgToSubinterface.get(pkg),
+ configuration.getResource("doclet.ClassUse_Subinterface", classLink,
+ pkgLink), subinterfaceUseTableSummary, contentTree);
+ classSubWriter.addUseInfo(pkgToImplementingClass.get(pkg),
+ configuration.getResource("doclet.ClassUse_ImplementingClass", classLink,
+ pkgLink), classUseTableSummary, contentTree);
+ fieldSubWriter.addUseInfo(pkgToField.get(pkg),
+ configuration.getResource("doclet.ClassUse_Field", classLink,
+ pkgLink), fieldUseTableSummary, contentTree);
+ fieldSubWriter.addUseInfo(pkgToFieldAnnotations.get(pkg),
+ configuration.getResource("doclet.ClassUse_FieldAnnotations", classLink,
+ pkgLink), fieldUseTableSummary, contentTree);
+ fieldSubWriter.addUseInfo(pkgToFieldTypeParameter.get(pkg),
+ configuration.getResource("doclet.ClassUse_FieldTypeParameter", classLink,
+ pkgLink), fieldUseTableSummary, contentTree);
+ methodSubWriter.addUseInfo(pkgToMethodAnnotations.get(pkg),
+ configuration.getResource("doclet.ClassUse_MethodAnnotations", classLink,
+ pkgLink), methodUseTableSummary, contentTree);
+ methodSubWriter.addUseInfo(pkgToMethodParameterAnnotations.get(pkg),
+ configuration.getResource("doclet.ClassUse_MethodParameterAnnotations", classLink,
+ pkgLink), methodUseTableSummary, contentTree);
+ methodSubWriter.addUseInfo(pkgToMethodTypeParameter.get(pkg),
+ configuration.getResource("doclet.ClassUse_MethodTypeParameter", classLink,
+ pkgLink), methodUseTableSummary, contentTree);
+ methodSubWriter.addUseInfo(pkgToMethodReturn.get(pkg),
+ configuration.getResource("doclet.ClassUse_MethodReturn", classLink,
+ pkgLink), methodUseTableSummary, contentTree);
+ methodSubWriter.addUseInfo(pkgToMethodReturnTypeParameter.get(pkg),
+ configuration.getResource("doclet.ClassUse_MethodReturnTypeParameter", classLink,
+ pkgLink), methodUseTableSummary, contentTree);
+ methodSubWriter.addUseInfo(pkgToMethodArgs.get(pkg),
+ configuration.getResource("doclet.ClassUse_MethodArgs", classLink,
+ pkgLink), methodUseTableSummary, contentTree);
+ methodSubWriter.addUseInfo(pkgToMethodArgTypeParameter.get(pkg),
+ configuration.getResource("doclet.ClassUse_MethodArgsTypeParameters", classLink,
+ pkgLink), methodUseTableSummary, contentTree);
+ methodSubWriter.addUseInfo(pkgToMethodThrows.get(pkg),
+ configuration.getResource("doclet.ClassUse_MethodThrows", classLink,
+ pkgLink), methodUseTableSummary, contentTree);
+ constrSubWriter.addUseInfo(pkgToConstructorAnnotations.get(pkg),
+ configuration.getResource("doclet.ClassUse_ConstructorAnnotations", classLink,
+ pkgLink), constructorUseTableSummary, contentTree);
+ constrSubWriter.addUseInfo(pkgToConstructorParameterAnnotations.get(pkg),
+ configuration.getResource("doclet.ClassUse_ConstructorParameterAnnotations", classLink,
+ pkgLink), constructorUseTableSummary, contentTree);
+ constrSubWriter.addUseInfo(pkgToConstructorArgs.get(pkg),
+ configuration.getResource("doclet.ClassUse_ConstructorArgs", classLink,
+ pkgLink), constructorUseTableSummary, contentTree);
+ constrSubWriter.addUseInfo(pkgToConstructorArgTypeParameter.get(pkg),
+ configuration.getResource("doclet.ClassUse_ConstructorArgsTypeParameters", classLink,
+ pkgLink), constructorUseTableSummary, contentTree);
+ constrSubWriter.addUseInfo(pkgToConstructorThrows.get(pkg),
+ configuration.getResource("doclet.ClassUse_ConstructorThrows", classLink,
+ pkgLink), constructorUseTableSummary, contentTree);
+ }
+
+ /**
+ * Get the header for the class use Listing.
+ *
+ * @return a content tree representing the class use header
+ */
+ protected HtmlTree getClassUseHeader() {
+ String cltype = configuration.getText(utils.isInterface(typeElement)
+ ? "doclet.Interface"
+ : "doclet.Class");
+ String clname = utils.getFullyQualifiedName(typeElement);
+ String title = configuration.getText("doclet.Window_ClassUse_Header",
+ cltype, clname);
+ HtmlTree bodyTree = getBody(true, getWindowTitle(title));
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
+ ? HtmlTree.HEADER()
+ : bodyTree;
+ addTop(htmlTree);
+ addNavLinks(true, htmlTree);
+ if (configuration.allowTag(HtmlTag.HEADER)) {
+ bodyTree.addContent(htmlTree);
+ }
+ ContentBuilder headContent = new ContentBuilder();
+ headContent.addContent(getResource("doclet.ClassUse_Title", cltype));
+ headContent.addContent(new HtmlTree(HtmlTag.BR));
+ headContent.addContent(clname);
+ Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING,
+ true, HtmlStyle.title, headContent);
+ Content div = HtmlTree.DIV(HtmlStyle.header, heading);
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ mainTree.addContent(div);
+ } else {
+ bodyTree.addContent(div);
+ }
+ return bodyTree;
+ }
+
+ /**
+ * Get this package link.
+ *
+ * @return a content tree for the package link
+ */
+ protected Content getNavLinkPackage() {
+ Content linkContent =
+ getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY), packageLabel);
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+
+ /**
+ * Get class page link.
+ *
+ * @return a content tree for the class page link
+ */
+ protected Content getNavLinkClass() {
+ Content linkContent = getLink(new LinkInfoImpl(
+ configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)
+ .label(configuration.getText("doclet.Class")));
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+
+ /**
+ * Get the use link.
+ *
+ * @return a content tree for the use link
+ */
+ protected Content getNavLinkClassUse() {
+ Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, useLabel);
+ return li;
+ }
+
+ /**
+ * Get the tree link.
+ *
+ * @return a content tree for the tree link
+ */
+ protected Content getNavLinkTree() {
+ Content linkContent = utils.isEnclosingPackageIncluded(typeElement)
+ ? getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), treeLabel)
+ : getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), treeLabel);
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java
new file mode 100644
index 00000000000..37bc63c57e6
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java
@@ -0,0 +1,759 @@
+/*
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.IOException;
+import java.util.*;
+
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.SimpleElementVisitor8;
+
+import com.sun.source.doctree.DocTree;
+import com.sun.tools.javac.util.DefinedBy;
+import com.sun.tools.javac.util.DefinedBy.Api;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.ClassWriter;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.builders.MemberSummaryBuilder;
+import jdk.javadoc.internal.doclets.toolkit.taglets.ParamTaglet;
+import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
+import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
+import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
+import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap.Kind;
+
+/**
+ * Generate the Class Information Page.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @see javax.lang.model.element.TypeElement
+ * @see java.util.Collections
+ * @see java.util.List
+ * @see java.util.ArrayList
+ * @see java.util.HashMap
+ *
+ * @author Atul M Dambalkar
+ * @author Robert Field
+ * @author Bhavesh Patel (Modified)
+ */
+public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWriter {
+
+ protected final TypeElement typeElement;
+
+ protected final ClassTree classtree;
+
+ protected final TypeElement prev;
+
+ protected final TypeElement next;
+
+ /**
+ * @param configuration the configuration data for the doclet
+ * @param typeElement the class being documented.
+ * @param prevClass the previous class that was documented.
+ * @param nextClass the next class being documented.
+ * @param classTree the class tree for the given class.
+ * @throws java.io.IOException
+ */
+ public ClassWriterImpl(ConfigurationImpl configuration, TypeElement typeElement,
+ TypeElement prevClass, TypeElement nextClass, ClassTree classTree)
+ throws IOException {
+ super(configuration, DocPath.forClass(configuration.utils, typeElement));
+ this.typeElement = typeElement;
+ configuration.currentTypeElement = typeElement;
+ this.classtree = classTree;
+ this.prev = prevClass;
+ this.next = nextClass;
+ }
+
+ /**
+ * Get this package link.
+ *
+ * @return a content tree for the package link
+ */
+ @Override
+ protected Content getNavLinkPackage() {
+ Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
+ packageLabel);
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+
+ /**
+ * Get the class link.
+ *
+ * @return a content tree for the class link
+ */
+ @Override
+ protected Content getNavLinkClass() {
+ Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel);
+ return li;
+ }
+
+ /**
+ * Get the class use link.
+ *
+ * @return a content tree for the class use link
+ */
+ @Override
+ protected Content getNavLinkClassUse() {
+ Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), useLabel);
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+
+ /**
+ * Get link to previous class.
+ *
+ * @return a content tree for the previous class link
+ */
+ @Override
+ public Content getNavLinkPrevious() {
+ Content li;
+ if (prev != null) {
+ Content prevLink = getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.CLASS, prev)
+ .label(prevclassLabel).strong(true));
+ li = HtmlTree.LI(prevLink);
+ }
+ else
+ li = HtmlTree.LI(prevclassLabel);
+ return li;
+ }
+
+ /**
+ * Get link to next class.
+ *
+ * @return a content tree for the next class link
+ */
+ @Override
+ public Content getNavLinkNext() {
+ Content li;
+ if (next != null) {
+ Content nextLink = getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.CLASS, next)
+ .label(nextclassLabel).strong(true));
+ li = HtmlTree.LI(nextLink);
+ }
+ else
+ li = HtmlTree.LI(nextclassLabel);
+ return li;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getHeader(String header) {
+ HtmlTree bodyTree = getBody(true, getWindowTitle(utils.getSimpleName(typeElement)));
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
+ ? HtmlTree.HEADER()
+ : bodyTree;
+ addTop(htmlTree);
+ addNavLinks(true, htmlTree);
+ if (configuration.allowTag(HtmlTag.HEADER)) {
+ bodyTree.addContent(htmlTree);
+ }
+ bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA);
+ HtmlTree div = new HtmlTree(HtmlTag.DIV);
+ div.addStyle(HtmlStyle.header);
+ PackageElement pkg = utils.containingPackage(typeElement);
+ if (!pkg.isUnnamed()) {
+ Content pkgNameContent = new StringContent(utils.getPackageName(pkg));
+ Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent);
+ div.addContent(pkgNameDiv);
+ }
+ LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.CLASS_HEADER, typeElement);
+ //Let's not link to ourselves in the header.
+ linkInfo.linkToSelf = false;
+ Content headerContent = new StringContent(header);
+ Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
+ HtmlStyle.title, headerContent);
+ heading.addContent(getTypeParameterLinks(linkInfo));
+ div.addContent(heading);
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ mainTree.addContent(div);
+ } else {
+ bodyTree.addContent(div);
+ }
+ return bodyTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getClassContentHeader() {
+ return getContentHeader();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addFooter(Content contentTree) {
+ contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA);
+ Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
+ ? HtmlTree.FOOTER()
+ : contentTree;
+ addNavLinks(false, htmlTree);
+ addBottom(htmlTree);
+ if (configuration.allowTag(HtmlTag.FOOTER)) {
+ contentTree.addContent(htmlTree);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void printDocument(Content contentTree) throws IOException {
+ printHtmlDocument(configuration.metakeywords.getMetaKeywords(typeElement),
+ true, contentTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getClassInfoTreeHeader() {
+ return getMemberTreeHeader();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getClassInfo(Content classInfoTree) {
+ return getMemberTree(HtmlStyle.description, classInfoTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addClassSignature(String modifiers, Content classInfoTree) {
+ classInfoTree.addContent(new HtmlTree(HtmlTag.BR));
+ Content pre = new HtmlTree(HtmlTag.PRE);
+ addAnnotationInfo(typeElement, pre);
+ pre.addContent(modifiers);
+ LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.CLASS_SIGNATURE, typeElement);
+ //Let's not link to ourselves in the signature.
+ linkInfo.linkToSelf = false;
+ Content className = new StringContent(utils.getSimpleName(typeElement));
+ Content parameterLinks = getTypeParameterLinks(linkInfo);
+ if (configuration.linksource) {
+ addSrcLink(typeElement, className, pre);
+ pre.addContent(parameterLinks);
+ } else {
+ Content span = HtmlTree.SPAN(HtmlStyle.typeNameLabel, className);
+ span.addContent(parameterLinks);
+ pre.addContent(span);
+ }
+ if (!utils.isInterface(typeElement)) {
+ TypeMirror superclass = utils.getFirstVisibleSuperClass(typeElement);
+ if (superclass != null) {
+ pre.addContent(DocletConstants.NL);
+ pre.addContent("extends ");
+ Content link = getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.CLASS_SIGNATURE_PARENT_NAME,
+ superclass));
+ pre.addContent(link);
+ }
+ }
+ List extends TypeMirror> interfaces = typeElement.getInterfaces();
+ if (!interfaces.isEmpty()) {
+ boolean isFirst = true;
+ for (TypeMirror type : interfaces) {
+ TypeElement tDoc = utils.asTypeElement(type);
+ if (!(utils.isPublic(tDoc) || utils.isLinkable(tDoc))) {
+ continue;
+ }
+ if (isFirst) {
+ pre.addContent(DocletConstants.NL);
+ pre.addContent(utils.isInterface(typeElement) ? "extends " : "implements ");
+ isFirst = false;
+ } else {
+ pre.addContent(", ");
+ }
+ Content link = getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.CLASS_SIGNATURE_PARENT_NAME,
+ type));
+ pre.addContent(link);
+ }
+ }
+ classInfoTree.addContent(pre);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addClassDescription(Content classInfoTree) {
+ if(!configuration.nocomment) {
+ // generate documentation for the class.
+ if (!utils.getBody(typeElement).isEmpty()) {
+ addInlineComment(typeElement, classInfoTree);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addClassTagInfo(Content classInfoTree) {
+ if(!configuration.nocomment) {
+ // Print Information about all the tags here
+ addTagsInfo(typeElement, classInfoTree);
+ }
+ }
+
+ /**
+ * Get the class hierarchy tree for the given class.
+ *
+ * @param type the class to print the hierarchy for
+ * @return a content tree for class inheritence
+ */
+ private Content getClassInheritenceTree(TypeMirror type) {
+ TypeMirror sup;
+ HtmlTree classTreeUl = new HtmlTree(HtmlTag.UL);
+ classTreeUl.addStyle(HtmlStyle.inheritance);
+ Content liTree = null;
+ do {
+ sup = utils.getFirstVisibleSuperClass(type);
+ if (sup != null) {
+ HtmlTree ul = new HtmlTree(HtmlTag.UL);
+ ul.addStyle(HtmlStyle.inheritance);
+ ul.addContent(getTreeForClassHelper(type));
+ if (liTree != null)
+ ul.addContent(liTree);
+ Content li = HtmlTree.LI(ul);
+ liTree = li;
+ type = sup;
+ } else
+ classTreeUl.addContent(getTreeForClassHelper(type));
+ } while (sup != null);
+ if (liTree != null)
+ classTreeUl.addContent(liTree);
+ return classTreeUl;
+ }
+
+ /**
+ * Get the class helper tree for the given class.
+ *
+ * @param type the class to print the helper for
+ * @return a content tree for class helper
+ */
+ private Content getTreeForClassHelper(TypeMirror type) {
+ Content li = new HtmlTree(HtmlTag.LI);
+ if (type.equals(typeElement.asType())) {
+ Content typeParameters = getTypeParameterLinks(
+ new LinkInfoImpl(configuration, LinkInfoImpl.Kind.TREE,
+ typeElement));
+ if (configuration.shouldExcludeQualifier(utils.containingPackage(typeElement).toString())) {
+ li.addContent(utils.asTypeElement(type).getSimpleName().toString());
+ li.addContent(typeParameters);
+ } else {
+ li.addContent(utils.asTypeElement(type).getQualifiedName().toString());
+ li.addContent(typeParameters);
+ }
+ } else {
+ Content link = getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.CLASS_TREE_PARENT, type)
+ .label(configuration.getClassName(utils.asTypeElement(type))));
+ li.addContent(link);
+ }
+ return li;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addClassTree(Content classContentTree) {
+ if (!utils.isClass(typeElement)) {
+ return;
+ }
+ classContentTree.addContent(getClassInheritenceTree(typeElement.asType()));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addTypeParamInfo(Content classInfoTree) {
+ if (!utils.getTypeParamTrees(typeElement).isEmpty()) {
+ Content typeParam = (new ParamTaglet()).getTagletOutput(typeElement,
+ getTagletWriterInstance(false));
+ Content dl = HtmlTree.DL(typeParam);
+ classInfoTree.addContent(dl);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addSubClassInfo(Content classInfoTree) {
+ if (utils.isClass(typeElement)) {
+ if (typeElement.getQualifiedName().toString().equals("java.lang.Object") ||
+ typeElement.getQualifiedName().toString().equals("org.omg.CORBA.Object")) {
+ return; // Don't generate the list, too huge
+ }
+ Set subclasses = classtree.directSubClasses(typeElement, false);
+ if (!subclasses.isEmpty()) {
+ Content label = getResource(
+ "doclet.Subclasses");
+ Content dt = HtmlTree.DT(label);
+ Content dl = HtmlTree.DL(dt);
+ dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUBCLASSES,
+ subclasses));
+ classInfoTree.addContent(dl);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addSubInterfacesInfo(Content classInfoTree) {
+ if (utils.isInterface(typeElement)) {
+ Set subInterfaces = classtree.allSubClasses(typeElement, false);
+ if (!subInterfaces.isEmpty()) {
+ Content label = getResource(
+ "doclet.Subinterfaces");
+ Content dt = HtmlTree.DT(label);
+ Content dl = HtmlTree.DL(dt);
+ dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUBINTERFACES,
+ subInterfaces));
+ classInfoTree.addContent(dl);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addInterfaceUsageInfo (Content classInfoTree) {
+ if (!utils.isInterface(typeElement)) {
+ return;
+ }
+ if (typeElement.getQualifiedName().toString().equals("java.lang.Cloneable") ||
+ typeElement.getQualifiedName().toString().equals("java.io.Serializable")) {
+ return; // Don't generate the list, too big
+ }
+ Set implcl = classtree.implementingClasses(typeElement);
+ if (!implcl.isEmpty()) {
+ Content label = getResource(
+ "doclet.Implementing_Classes");
+ Content dt = HtmlTree.DT(label);
+ Content dl = HtmlTree.DL(dt);
+ dl.addContent(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_CLASSES,
+ implcl));
+ classInfoTree.addContent(dl);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addImplementedInterfacesInfo(Content classInfoTree) {
+ SortedSet interfaces = new TreeSet<>(utils.makeTypeMirrorClassUseComparator());
+ interfaces.addAll(utils.getAllInterfaces(typeElement));
+ if (utils.isClass(typeElement) && !interfaces.isEmpty()) {
+ Content label = getResource(
+ "doclet.All_Implemented_Interfaces");
+ Content dt = HtmlTree.DT(label);
+ Content dl = HtmlTree.DL(dt);
+ dl.addContent(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_INTERFACES, interfaces));
+ classInfoTree.addContent(dl);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addSuperInterfacesInfo(Content classInfoTree) {
+ SortedSet interfaces =
+ new TreeSet<>(utils.makeTypeMirrorIndexUseComparator());
+ interfaces.addAll(utils.getAllInterfaces(typeElement));
+
+ if (utils.isInterface(typeElement) && !interfaces.isEmpty()) {
+ Content label = getResource("doclet.All_Superinterfaces");
+ Content dt = HtmlTree.DT(label);
+ Content dl = HtmlTree.DL(dt);
+ dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUPER_INTERFACES, interfaces));
+ classInfoTree.addContent(dl);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addNestedClassInfo(final Content classInfoTree) {
+ Element outerClass = typeElement.getEnclosingElement();
+ if (outerClass == null)
+ return;
+ new SimpleElementVisitor8() {
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public Void visitType(TypeElement e, Void p) {
+ String label = utils.isInterface(e)
+ ? "doclet.Enclosing_Interface"
+ : "doclet.Enclosing_Class";
+ Content dt = HtmlTree.DT(getResource(label));
+ Content dl = HtmlTree.DL(dt);
+ Content dd = new HtmlTree(HtmlTag.DD);
+ dd.addContent(getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.CLASS, e)));
+ dl.addContent(dd);
+ classInfoTree.addContent(dl);
+ return null;
+ }
+ }.visit(outerClass);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addFunctionalInterfaceInfo (Content classInfoTree) {
+ if (isFunctionalInterface()) {
+ Content dt = HtmlTree.DT(getResource("doclet.Functional_Interface"));
+ Content dl = HtmlTree.DL(dt);
+ Content dd = new HtmlTree(HtmlTag.DD);
+ dd.addContent(getResource("doclet.Functional_Interface_Message"));
+ dl.addContent(dd);
+ classInfoTree.addContent(dl);
+ }
+ }
+
+ public boolean isFunctionalInterface() {
+ List extends AnnotationMirror> annotationMirrors = ((Element) typeElement).getAnnotationMirrors();
+ for (AnnotationMirror anno : annotationMirrors) {
+ if (utils.isFunctionalInterface(anno)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addClassDeprecationInfo(Content classInfoTree) {
+ Content hr = new HtmlTree(HtmlTag.HR);
+ classInfoTree.addContent(hr);
+ List extends DocTree> deprs = utils.getBlockTags(typeElement, DocTree.Kind.DEPRECATED);
+ if (utils.isDeprecated(typeElement)) {
+ Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
+ Content div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
+ if (!deprs.isEmpty()) {
+ CommentHelper ch = utils.getCommentHelper(typeElement);
+ DocTree dt = deprs.get(0);
+ List extends DocTree> commentTags = ch.getBody(configuration, dt);
+ if (!commentTags.isEmpty()) {
+ div.addContent(getSpace());
+ addInlineDeprecatedComment(typeElement, deprs.get(0), div);
+ }
+ }
+ classInfoTree.addContent(div);
+ }
+ }
+
+ /**
+ * Get links to the given classes.
+ *
+ * @param context the id of the context where the link will be printed
+ * @param list the list of classes
+ * @return a content tree for the class list
+ */
+ private Content getClassLinks(LinkInfoImpl.Kind context, Collection> list) {
+ Content dd = new HtmlTree(HtmlTag.DD);
+ boolean isFirst = true;
+ for (Object type : list) {
+ if (!isFirst) {
+ Content separator = new StringContent(", ");
+ dd.addContent(separator);
+ } else {
+ isFirst = false;
+ }
+ // TODO: should we simply split this method up to avoid instanceof ?
+ if (type instanceof TypeElement) {
+ Content link = getLink(
+ new LinkInfoImpl(configuration, context, (TypeElement)(type)));
+ dd.addContent(link);
+ } else {
+ Content link = getLink(
+ new LinkInfoImpl(configuration, context, ((TypeMirror)type)));
+ dd.addContent(link);
+ }
+ }
+ return dd;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Content getNavLinkTree() {
+ Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE,
+ treeLabel, "", "");
+ Content li = HtmlTree.LI(treeLinkContent);
+ return li;
+ }
+
+ /**
+ * Add summary details to the navigation bar.
+ *
+ * @param subDiv the content tree to which the summary detail links will be added
+ */
+ protected void addSummaryDetailLinks(Content subDiv) {
+ try {
+ Content div = HtmlTree.DIV(getNavSummaryLinks());
+ div.addContent(getNavDetailLinks());
+ subDiv.addContent(div);
+ } catch (Exception e) {
+ throw new DocletAbortException(e);
+ }
+ }
+
+ /**
+ * Get summary links for navigation bar.
+ *
+ * @return the content tree for the navigation summary links
+ */
+ protected Content getNavSummaryLinks() throws Exception {
+ Content li = HtmlTree.LI(summaryLabel);
+ li.addContent(getSpace());
+ Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
+ MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
+ configuration.getBuilderFactory().getMemberSummaryBuilder(this);
+ for (VisibleMemberMap.Kind kind : VisibleMemberMap.Kind.summarySet) {
+ Content liNav = new HtmlTree(HtmlTag.LI);
+ if (kind == VisibleMemberMap.Kind.ENUM_CONSTANTS && !utils.isEnum(typeElement)) {
+ continue;
+ }
+ if (kind == VisibleMemberMap.Kind.CONSTRUCTORS && utils.isEnum(typeElement)) {
+ continue;
+ }
+ AbstractMemberWriter writer =
+ ((AbstractMemberWriter) memberSummaryBuilder.getMemberSummaryWriter(kind));
+ if (writer == null) {
+ liNav.addContent(getResource(VisibleMemberMap.Kind.getNavLinkLabels(kind)));
+ } else {
+ writer.addNavSummaryLink(
+ memberSummaryBuilder.members(kind),
+ memberSummaryBuilder.getVisibleMemberMap(kind), liNav);
+ }
+ if (kind != Kind.METHODS) {
+ addNavGap(liNav);
+ }
+ ulNav.addContent(liNav);
+ }
+ return ulNav;
+ }
+
+ /**
+ * Get detail links for the navigation bar.
+ *
+ * @return the content tree for the detail links
+ * @throws java.lang.Exception
+ */
+ protected Content getNavDetailLinks() throws Exception {
+ Content li = HtmlTree.LI(detailLabel);
+ li.addContent(getSpace());
+ Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
+ MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
+ configuration.getBuilderFactory().getMemberSummaryBuilder(this);
+ for (VisibleMemberMap.Kind kind : VisibleMemberMap.Kind.detailSet) {
+ Content liNav = new HtmlTree(HtmlTag.LI);
+ AbstractMemberWriter writer =
+ ((AbstractMemberWriter) memberSummaryBuilder.
+ getMemberSummaryWriter(kind));
+ if (kind == VisibleMemberMap.Kind.ENUM_CONSTANTS && !utils.isEnum(typeElement)) {
+ continue;
+ }
+ if (kind == VisibleMemberMap.Kind.CONSTRUCTORS && utils.isEnum(typeElement)) {
+ continue;
+ }
+ if (writer == null) {
+ liNav.addContent(getResource(VisibleMemberMap.Kind.getNavLinkLabels(kind)));
+ } else {
+ writer.addNavDetailLink(memberSummaryBuilder.members(kind), liNav);
+ }
+ if (kind != Kind.METHODS) {
+ addNavGap(liNav);
+ }
+ ulNav.addContent(liNav);
+ }
+ return ulNav;
+ }
+
+ /**
+ * Add gap between navigation bar elements.
+ *
+ * @param liNav the content tree to which the gap will be added
+ */
+ protected void addNavGap(Content liNav) {
+ liNav.addContent(getSpace());
+ liNav.addContent("|");
+ liNav.addContent(getSpace());
+ }
+
+ /**
+ * Return the TypeElement being documented.
+ *
+ * @return the TypeElement being documented.
+ */
+ @Override
+ public TypeElement getTypeElement() {
+ return typeElement;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java
new file mode 100644
index 00000000000..0b7aa5ec023
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java
@@ -0,0 +1,747 @@
+/*
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.net.*;
+import java.util.*;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+
+import com.sun.source.util.DocTreePath;
+import com.sun.tools.doclint.DocLint;
+
+import jdk.javadoc.doclet.Doclet;
+import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlVersion;
+import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.WriterFactory;
+import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.MessageRetriever;
+import jdk.javadoc.internal.doclets.toolkit.util.Utils;
+
+import static javax.tools.Diagnostic.Kind.*;
+
+/**
+ * Configure the output based on the command line options.
+ *
+ * Also determine the length of the command line option. For example,
+ * for a option "-header" there will be a string argument associated, then the
+ * the length of option "-header" is two. But for option "-nohelp" no argument
+ * is needed so it's length is 1.
+ *
+ *
+ * Also do the error checking on the options used. For example it is illegal to
+ * use "-helpfile" option when already "-nohelp" option is used.
+ *
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Robert Field.
+ * @author Atul Dambalkar.
+ * @author Jamie Ho
+ * @author Bhavesh Patel (Modified)
+ */
+public class ConfigurationImpl extends Configuration {
+
+ /**
+ * The build date. Note: For now, we will use
+ * a version number instead of a date.
+ */
+ public static final String BUILD_DATE = System.getProperty("java.version");
+
+ /**
+ * Argument for command line option "-header".
+ */
+ public String header = "";
+
+ /**
+ * Argument for command line option "-packagesheader".
+ */
+ public String packagesheader = "";
+
+ /**
+ * Argument for command line option "-footer".
+ */
+ public String footer = "";
+
+ /**
+ * Argument for command line option "-doctitle".
+ */
+ public String doctitle = "";
+
+ /**
+ * Argument for command line option "-windowtitle".
+ */
+ public String windowtitle = "";
+
+ /**
+ * Argument for command line option "-top".
+ */
+ public String top = "";
+
+ /**
+ * Argument for command line option "-bottom".
+ */
+ public String bottom = "";
+
+ /**
+ * Argument for command line option "-helpfile".
+ */
+ public String helpfile = "";
+
+ /**
+ * Argument for command line option "-stylesheetfile".
+ */
+ public String stylesheetfile = "";
+
+ /**
+ * Argument for command line option "-Xdocrootparent".
+ */
+ public String docrootparent = "";
+
+ public boolean sortedMethodDetails = false;
+
+ /**
+ * True if command line option "-nohelp" is used. Default value is false.
+ */
+ public boolean nohelp = false;
+
+ /**
+ * True if command line option "-splitindex" is used. Default value is
+ * false.
+ */
+ public boolean splitindex = false;
+
+ /**
+ * False if command line option "-noindex" is used. Default value is true.
+ */
+ public boolean createindex = true;
+
+ /**
+ * True if command line option "-use" is used. Default value is false.
+ */
+ public boolean classuse = false;
+
+ /**
+ * False if command line option "-notree" is used. Default value is true.
+ */
+ public boolean createtree = true;
+
+ /**
+ * True if command line option "-nodeprecated" is used. Default value is
+ * false.
+ */
+ public boolean nodeprecatedlist = false;
+
+ /**
+ * True if command line option "-nonavbar" is used. Default value is false.
+ */
+ public boolean nonavbar = false;
+
+ /**
+ * True if command line option "-nooverview" is used. Default value is
+ * false
+ */
+ private boolean nooverview = false;
+
+ /**
+ * The overview path specified with "-overview" flag.
+ */
+ public String overviewpath = null;
+
+ /**
+ * This is true if option "-overview" is used or option "-overview" is not
+ * used and number of packages is more than one.
+ */
+ public boolean createoverview = false;
+
+ /**
+ * This is the HTML version of the generated pages. HTML 4.01 is the default output version.
+ */
+ public HtmlVersion htmlVersion = HtmlVersion.HTML4;
+
+ /**
+ * Collected set of doclint options
+ */
+ public Map doclintOpts = new LinkedHashMap<>();
+
+ /**
+ * Unique Resource Handler for this package.
+ */
+ public final MessageRetriever standardmessage;
+
+ /**
+ * First file to appear in the right-hand frame in the generated
+ * documentation.
+ */
+ public DocPath topFile = DocPath.empty;
+
+ /**
+ * The TypeElement for the class file getting generated.
+ */
+ public TypeElement currentTypeElement = null; // Set this TypeElement in the ClassWriter.
+
+ protected List memberSearchIndex = new ArrayList<>();
+
+ protected List packageSearchIndex = new ArrayList<>();
+
+ protected List tagSearchIndex = new ArrayList<>();
+
+ protected List typeSearchIndex = new ArrayList<>();
+
+ protected Map> tagSearchIndexMap = new HashMap<>();
+
+ protected Set tagSearchIndexKeys;
+
+ /**
+ * Constructor. Initializes resource for the
+ * {@link com.sun.tools.doclets.internal.toolkit.util.MessageRetriever MessageRetriever}.
+ */
+ public ConfigurationImpl() {
+ standardmessage = new MessageRetriever(this,
+ "jdk.javadoc.internal.doclets.formats.html.resources.standard");
+ }
+
+ private final String versionRBName = "jdk.javadoc.internal.tool.resources.version";
+ private ResourceBundle versionRB;
+
+ /**
+ * Return the build date for the doclet.
+ * @return the build date
+ */
+ @Override
+ public String getDocletSpecificBuildDate() {
+ if (versionRB == null) {
+ try {
+ versionRB = ResourceBundle.getBundle(versionRBName, getLocale());
+ } catch (MissingResourceException e) {
+ return BUILD_DATE;
+ }
+ }
+
+ try {
+ return versionRB.getString("release");
+ } catch (MissingResourceException e) {
+ return BUILD_DATE;
+ }
+ }
+
+ protected boolean validateOptions() {
+ // check shared options
+ if (!generalValidOptions()) {
+ return false;
+ }
+ boolean helpfileSeen = false;
+ // otherwise look at our options
+ for (Doclet.Option opt : optionsProcessed) {
+ if (opt.matches("-helpfile")) {
+ if (nohelp == true) {
+ reporter.print(ERROR, getText("doclet.Option_conflict",
+ "-helpfile", "-nohelp"));
+ return false;
+ }
+ if (helpfileSeen) {
+ reporter.print(ERROR, getText("doclet.Option_reuse",
+ "-helpfile"));
+ return false;
+ }
+ helpfileSeen = true;
+ DocFile help = DocFile.createFileForInput(this, helpfile);
+ if (!help.exists()) {
+ reporter.print(ERROR, getText("doclet.File_not_found", helpfile));
+ return false;
+ }
+ } else if (opt.matches("-nohelp")) {
+ if (helpfileSeen) {
+ reporter.print(ERROR, getText("doclet.Option_conflict",
+ "-nohelp", "-helpfile"));
+ return false;
+ }
+ } else if (opt.matches("-xdocrootparent")) {
+ try {
+ URL ignored = new URL(docrootparent);
+ } catch (MalformedURLException e) {
+ reporter.print(ERROR, getText("doclet.MalformedURL", docrootparent));
+ return false;
+ }
+ } else if (opt.matches("-overview")) {
+ if (nooverview == true) {
+ reporter.print(ERROR, getText("doclet.Option_conflict",
+ "-overview", "-nooverview"));
+ return false;
+ }
+ } else if (opt.matches("-nooverview")) {
+ if (overviewpath != null) {
+ reporter.print(ERROR, getText("doclet.Option_conflict",
+ "-nooverview", "-overview"));
+ return false;
+ }
+ } else if (opt.matches("-splitindex")) {
+ if (createindex == false) {
+ reporter.print(ERROR, getText("doclet.Option_conflict",
+ "-splitindex", "-noindex"));
+ return false;
+ }
+ } else if (opt.matches("-noindex")) {
+ if (splitindex == true) {
+ reporter.print(ERROR, getText("doclet.Option_conflict",
+ "-noindex", "-splitindex"));
+ return false;
+ }
+ } else if (opt.matches("-xdoclint:")) {
+ String dopt = doclintOpts.get(opt);
+ if (dopt == null) {
+ continue;
+ }
+ if (dopt.contains("/")) {
+ reporter.print(ERROR, getText("doclet.Option_doclint_no_qualifiers"));
+ return false;
+ }
+ if (!DocLint.isValidOption(dopt)) {
+ reporter.print(ERROR, getText("doclet.Option_doclint_invalid_arg"));
+ return false;
+ }
+ } else if (opt.matches("-xdoclint/package:")) {
+ String dopt = doclintOpts.get(opt);
+ if (!DocLint.isValidOption(dopt)) {
+ reporter.print(ERROR, getText("doclet.Option_doclint_package_invalid_arg"));
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public boolean finishOptionSettings() {
+ if (!validateOptions()) {
+ return false;
+ }
+ if (!root.getSpecifiedElements().isEmpty()) {
+ Map map = new HashMap<>();
+ PackageElement pkg;
+ List classes = new ArrayList<>(root.getIncludedClasses());
+ for (TypeElement aClass : classes) {
+ pkg = utils.containingPackage(aClass);
+ if (!map.containsKey(utils.getPackageName(pkg))) {
+ map.put(utils.getPackageName(pkg), pkg);
+ }
+ }
+ }
+ setCreateOverview();
+ setTopFile(root);
+ workArounds.initDocLint(doclintOpts.values(), tagletManager.getCustomTagNames(),
+ Utils.toLowerCase(htmlVersion.name()));
+ return true;
+ }
+
+ /**
+ * Return true if the generated output is HTML5.
+ */
+ public boolean isOutputHtml5() {
+ return htmlVersion == HtmlVersion.HTML5;
+ }
+
+ /**
+ * Return true if the tag is allowed for this specific version of HTML.
+ */
+ public boolean allowTag(HtmlTag htmlTag) {
+ return htmlTag.allowTag(this.htmlVersion);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public MessageRetriever getDocletSpecificMsg() {
+ return standardmessage;
+ }
+
+ /**
+ * Decide the page which will appear first in the right-hand frame. It will
+ * be "overview-summary.html" if "-overview" option is used or no
+ * "-overview" but the number of packages is more than one. It will be
+ * "package-summary.html" of the respective package if there is only one
+ * package to document. It will be a class page(first in the sorted order),
+ * if only classes are provided on the command line.
+ *
+ * @param root Root of the program structure.
+ */
+ protected void setTopFile(DocletEnvironment root) {
+ if (!checkForDeprecation(root)) {
+ return;
+ }
+ if (createoverview) {
+ topFile = DocPaths.OVERVIEW_SUMMARY;
+ } else {
+ if (packages.size() == 1 && packages.first().isUnnamed()) {
+ if (!root.getIncludedClasses().isEmpty()) {
+ List classes = new ArrayList<>(root.getIncludedClasses());
+ TypeElement te = getValidClass(classes);
+ topFile = DocPath.forClass(utils, te);
+ }
+ } else if (!packages.isEmpty()) {
+ topFile = DocPath.forPackage(packages.first()).resolve(DocPaths.PACKAGE_SUMMARY);
+ }
+ }
+ }
+
+ protected TypeElement getValidClass(List classes) {
+ if (!nodeprecated) {
+ return classes.get(0);
+ }
+ for (TypeElement te : classes) {
+ if (!utils.isDeprecated(te)) {
+ return te;
+ }
+ }
+ return null;
+ }
+
+ protected boolean checkForDeprecation(DocletEnvironment root) {
+ for (TypeElement te : root.getIncludedClasses()) {
+ if (isGeneratedDoc(te)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Generate "overview.html" page if option "-overview" is used or number of
+ * packages is more than one. Sets {@link #createoverview} field to true.
+ */
+ protected void setCreateOverview() {
+ if ((overviewpath != null || packages.size() > 1) && !nooverview) {
+ createoverview = true;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public WriterFactory getWriterFactory() {
+ return new WriterFactoryImpl(this);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Locale getLocale() {
+ if (locale == null)
+ return Locale.getDefault();
+ return locale;
+ }
+
+ /**
+ * Return the path of the overview file and null if it does not exist.
+ *
+ * @return the path of the overview file and null if it does not exist.
+ */
+ public JavaFileObject getOverviewPath() {
+ if (overviewpath != null && getFileManager() instanceof StandardJavaFileManager) {
+ StandardJavaFileManager fm = (StandardJavaFileManager) getFileManager();
+ return fm.getJavaFileObjects(overviewpath).iterator().next();
+ }
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public JavaFileManager getFileManager() {
+ return root.getJavaFileManager();
+ }
+
+ @Override
+ public boolean showMessage(DocTreePath path, String key) {
+ return (path == null || workArounds.haveDocLint());
+ }
+
+ @Override
+ public boolean showMessage(Element e, String key) {
+ return (e == null || workArounds.haveDocLint());
+ }
+
+ @Override
+ public Content newContent() {
+ return new ContentBuilder();
+ }
+
+ protected void buildSearchTagIndex() {
+ for (SearchIndexItem sii : tagSearchIndex) {
+ String tagLabel = sii.getLabel();
+ Character unicode = (tagLabel.length() == 0)
+ ? '*'
+ : Character.toUpperCase(tagLabel.charAt(0));
+ List list = tagSearchIndexMap.get(unicode);
+ if (list == null) {
+ list = new ArrayList<>();
+ tagSearchIndexMap.put(unicode, list);
+ }
+ list.add(sii);
+ }
+ tagSearchIndexKeys = tagSearchIndexMap.keySet();
+ }
+
+ @Override
+ public Set getSupportedOptions() {
+ Doclet.Option[] options = {
+ new Option(this, "bottom", 1) {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ bottom = args.next();
+ return true;
+ }
+ },
+ new Option(this, "charset", 1) {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ charset = args.next();
+ return true;
+ }
+ },
+ new Option(this, "doctitle", 1) {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ doctitle = args.next();
+ return true;
+ }
+ },
+ new Option(this, "footer", 1) {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ footer = args.next();
+ return true;
+ }
+ },
+ new Option(this, "header", 1) {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ header = args.next();
+ return true;
+ }
+ },
+ new Option(this, "helpfile", 1) {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ helpfile = args.next();
+ return true;
+ }
+ },
+ new Option(this, "html4") {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ htmlVersion = HtmlVersion.HTML4;
+ return true;
+ }
+ },
+ new Option(this, "html5") {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ htmlVersion = HtmlVersion.HTML5;
+ return true;
+ }
+ },
+ new Option(this, "nohelp") {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ nohelp = true;
+ return true;
+ }
+ },
+ new Option(this, "nodeprecatedlist") {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ nodeprecatedlist = true;
+ return true;
+ }
+ },
+ new Option(this, "noindex") {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ createindex = false;
+ return true;
+ }
+ },
+ new Option(this, "nonavbar") {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ nonavbar = true;
+ return true;
+ }
+ },
+ new Hidden(this, "nooverview") {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ nooverview = true;
+ return true;
+ }
+ },
+ new Option(this, "notree") {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ createtree = false;
+ return true;
+ }
+ },
+ new Hidden(this, "overview", 1) {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ overviewpath = args.next();
+ return true;
+ }
+ },
+ new Hidden(this, "packagesheader", 1) {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ packagesheader = args.next();
+ return true;
+ }
+ },
+ new Option(this, "splitindex") {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ splitindex = true;
+ return true;
+ }
+ },
+ new Option(this, "stylesheetfile", 1) {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ stylesheetfile = args.next();
+ return true;
+ }
+ },
+ new Option(this, "top", 1) {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ top = args.next();
+ return true;
+ }
+ },
+ new Option(this, "use") {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ classuse = true;
+ return true;
+ }
+ },
+ new Option(this, "windowtitle", 1) {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ windowtitle = args.next().replaceAll("\\<.*?>", "");
+ return true;
+ }
+ },
+ new XOption(this, "xdoclint") {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ doclintOpts.put(this, DocLint.XMSGS_OPTION);
+ return true;
+ }
+ },
+ new XOption(this, "Xdocrootparent", 1) {
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ docrootparent = args.next();
+ return true;
+ }
+ },
+ new XOption(this, "doclet.xusage.xdoclint-extended.", "Xdoclint:", 0) {
+ @Override
+ public boolean matches(String option) {
+ String opt = option.startsWith("-") ? option.substring(1) : option;
+ return opt.toLowerCase().startsWith(getName().toLowerCase());
+ }
+
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ doclintOpts.put(this, opt.replace("-Xdoclint:", DocLint.XMSGS_CUSTOM_PREFIX));
+ return true;
+ }
+ },
+ new XOption(this, "doclet.xusage.xdoclint-package.", "Xdoclint/package:", 0) {
+ @Override
+ public boolean matches(String option) {
+ String opt = option.startsWith("-") ? option.substring(1) : option;
+ return opt.toLowerCase().startsWith(getName().toLowerCase());
+ }
+
+ @Override
+ public boolean process(String opt, ListIterator args) {
+ optionsProcessed.add(this);
+ doclintOpts.put(this, opt.replace("-Xdoclint/package:", DocLint.XCHECK_PACKAGE));
+ return true;
+ }
+ }
+ };
+ Set oset = new TreeSet<>();
+ oset.addAll(Arrays.asList(options));
+ oset.addAll(super.getSupportedOptions());
+ return oset;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java
new file mode 100644
index 00000000000..2b993595998
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java
@@ -0,0 +1,388 @@
+/*
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+import java.util.*;
+
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.ConstantsSummaryWriter;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+
+
+/**
+ * Write the Constants Summary Page in HTML format.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Jamie Ho
+ * @author Bhavesh Patel (Modified)
+ */
+public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements ConstantsSummaryWriter {
+
+ /**
+ * The configuration used in this run of the standard doclet.
+ */
+ ConfigurationImpl configuration;
+
+ /**
+ * The current class being documented.
+ */
+ private TypeElement currentTypeElement;
+
+ private final String constantsTableSummary;
+
+ private final List constantsTableHeader;
+
+ /**
+ * The HTML tree for main tag.
+ */
+ private HtmlTree mainTree = HtmlTree.MAIN();
+
+ /**
+ * The HTML tree for constant values summary.
+ */
+ private HtmlTree summaryTree;
+
+ /**
+ * Construct a ConstantsSummaryWriter.
+ * @param configuration the configuration used in this run
+ * of the standard doclet.
+ */
+ public ConstantsSummaryWriterImpl(ConfigurationImpl configuration)
+ throws IOException {
+ super(configuration, DocPaths.CONSTANT_VALUES);
+ this.configuration = configuration;
+ constantsTableSummary = configuration.getText("doclet.Constants_Table_Summary",
+ configuration.getText("doclet.Constants_Summary"));
+ constantsTableHeader = new ArrayList<>();
+ constantsTableHeader.add(getModifierTypeHeader());
+ constantsTableHeader.add(configuration.getText("doclet.ConstantField"));
+ constantsTableHeader.add(configuration.getText("doclet.Value"));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getHeader() {
+ String label = configuration.getText("doclet.Constants_Summary");
+ HtmlTree bodyTree = getBody(true, getWindowTitle(label));
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
+ ? HtmlTree.HEADER()
+ : bodyTree;
+ addTop(htmlTree);
+ addNavLinks(true, htmlTree);
+ if (configuration.allowTag(HtmlTag.HEADER)) {
+ bodyTree.addContent(htmlTree);
+ }
+ return bodyTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getContentsHeader() {
+ return new HtmlTree(HtmlTag.UL);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addLinkToPackageContent(PackageElement pkg,
+ Set printedPackageHeaders, Content contentListTree) {
+ //add link to summary
+ Content link;
+ if (pkg.isUnnamed()) {
+ link = getHyperLink(getDocLink(
+ SectionName.UNNAMED_PACKAGE_ANCHOR),
+ defaultPackageLabel, "", "");
+ } else {
+ String parsedPackageName = utils.parsePackageName(pkg);
+ Content packageNameContent = getPackageLabel(parsedPackageName);
+ packageNameContent.addContent(".*");
+ link = getHyperLink(DocLink.fragment(parsedPackageName),
+ packageNameContent, "", "");
+ PackageElement abbrevPkg = utils.elementUtils.getPackageElement(parsedPackageName);
+ printedPackageHeaders.add(abbrevPkg);
+ }
+ contentListTree.addContent(HtmlTree.LI(link));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addContentsList(Content contentTree, Content contentListTree) {
+ Content titleContent = getResource(
+ "doclet.Constants_Summary");
+ Content pHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+ HtmlStyle.title, titleContent);
+ Content div = HtmlTree.DIV(HtmlStyle.header, pHeading);
+ Content headingContent = getResource(
+ "doclet.Contents");
+ Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
+ headingContent);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ HtmlTree section = HtmlTree.SECTION(heading);
+ section.addContent(contentListTree);
+ div.addContent(section);
+ mainTree.addContent(div);
+ } else {
+ div.addContent(heading);
+ div.addContent(contentListTree);
+ contentTree.addContent(div);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getConstantSummaries() {
+ HtmlTree summariesDiv = new HtmlTree(HtmlTag.DIV);
+ summariesDiv.addStyle(HtmlStyle.constantValuesContainer);
+ return summariesDiv;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addPackageName(PackageElement pkg, Content summariesTree, boolean first) {
+ Content pkgNameContent;
+ if (!first && configuration.allowTag(HtmlTag.SECTION)) {
+ summariesTree.addContent(summaryTree);
+ }
+ if (pkg.isUnnamed()) {
+ summariesTree.addContent(getMarkerAnchor(
+ SectionName.UNNAMED_PACKAGE_ANCHOR));
+ pkgNameContent = defaultPackageLabel;
+ } else {
+ String parsedPackageName = utils.parsePackageName(pkg);
+ summariesTree.addContent(getMarkerAnchor(parsedPackageName));
+ pkgNameContent = getPackageLabel(parsedPackageName);
+ }
+ Content headingContent = new StringContent(".*");
+ Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
+ pkgNameContent);
+ heading.addContent(headingContent);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ summaryTree = HtmlTree.SECTION(heading);
+ } else {
+ summariesTree.addContent(heading);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getClassConstantHeader() {
+ HtmlTree ul = new HtmlTree(HtmlTag.UL);
+ ul.addStyle(HtmlStyle.blockList);
+ return ul;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addClassConstant(Content summariesTree, Content classConstantTree) {
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ summaryTree.addContent(classConstantTree);
+ } else {
+ summariesTree.addContent(classConstantTree);
+ }
+ }
+
+ /**
+ * Get the table caption and header for the constant summary table
+ *
+ * @param typeElement the TypeElement to be documented
+ * @return constant members header content
+ */
+ public Content getConstantMembersHeader(TypeElement typeElement) {
+ //generate links backward only to public classes.
+ Content classlink = (utils.isPublic(typeElement) || utils.isProtected(typeElement)) ?
+ getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.CONSTANT_SUMMARY, typeElement)) :
+ new StringContent(utils.getFullyQualifiedName(typeElement));
+
+ PackageElement enclosingPackage = utils.containingPackage(typeElement);
+ if (!enclosingPackage.isUnnamed()) {
+ Content cb = new ContentBuilder();
+ cb.addContent(enclosingPackage.getQualifiedName().toString());
+ cb.addContent(".");
+ cb.addContent(classlink);
+ return getClassName(cb);
+ } else {
+ return getClassName(classlink);
+ }
+ }
+
+ /**
+ * Get the class name in the table caption and the table header.
+ *
+ * @param classStr the class name to print.
+ * @return the table caption and header
+ */
+ protected Content getClassName(Content classStr) {
+ Content caption = getTableCaption(classStr);
+ Content table = (configuration.isOutputHtml5())
+ ? HtmlTree.TABLE(HtmlStyle.constantsSummary, caption)
+ : HtmlTree.TABLE(HtmlStyle.constantsSummary, constantsTableSummary, caption);
+ table.addContent(getSummaryTableHeader(constantsTableHeader, "col"));
+ return table;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addConstantMembers(TypeElement typeElement, Collection fields,
+ Content classConstantTree) {
+ currentTypeElement = typeElement;
+ Content tbody = new HtmlTree(HtmlTag.TBODY);
+ boolean altColor = true;
+ for (VariableElement field : fields) {
+ HtmlTree tr = new HtmlTree(HtmlTag.TR);
+ tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
+ addConstantMember(field, tr);
+ tbody.addContent(tr);
+ altColor = !altColor;
+ }
+ Content table = getConstantMembersHeader(typeElement);
+ table.addContent(tbody);
+ Content li = HtmlTree.LI(HtmlStyle.blockList, table);
+ classConstantTree.addContent(li);
+ }
+
+ /**
+ * Add the row for the constant summary table.
+ *
+ * @param member the field to be documented.
+ * @param trTree an htmltree object for the table row
+ */
+ private void addConstantMember(VariableElement member, HtmlTree trTree) {
+ trTree.addContent(getTypeColumn(member));
+ trTree.addContent(getNameColumn(member));
+ trTree.addContent(getValue(member));
+ }
+
+ /**
+ * Get the type column for the constant summary table row.
+ *
+ * @param member the field to be documented.
+ * @return the type column of the constant table row
+ */
+ private Content getTypeColumn(VariableElement member) {
+ Content anchor = getMarkerAnchor(currentTypeElement.getQualifiedName() +
+ "." + member.getSimpleName());
+ Content tdType = HtmlTree.TD(HtmlStyle.colFirst, anchor);
+ Content code = new HtmlTree(HtmlTag.CODE);
+ for (Modifier mod : member.getModifiers()) {
+ Content modifier = new StringContent(mod.toString());
+ code.addContent(modifier);
+ code.addContent(getSpace());
+ }
+ Content type = getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.CONSTANT_SUMMARY, member.asType()));
+ code.addContent(type);
+ tdType.addContent(code);
+ return tdType;
+ }
+
+ /**
+ * Get the name column for the constant summary table row.
+ *
+ * @param member the field to be documented.
+ * @return the name column of the constant table row
+ */
+ private Content getNameColumn(VariableElement member) {
+ Content nameContent = getDocLink(LinkInfoImpl.Kind.CONSTANT_SUMMARY,
+ member, member.getSimpleName().toString(), false);
+ Content code = HtmlTree.CODE(nameContent);
+ return HtmlTree.TD(code);
+ }
+
+ /**
+ * Get the value column for the constant summary table row.
+ *
+ * @param member the field to be documented.
+ * @return the value column of the constant table row
+ */
+ private Content getValue(VariableElement member) {
+ String value = utils.constantValueExpresion(member);
+ Content valueContent = new StringContent(value);
+ Content code = HtmlTree.CODE(valueContent);
+ return HtmlTree.TD(HtmlStyle.colLast, code);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addConstantSummaries(Content contentTree, Content summariesTree) {
+ if (configuration.allowTag(HtmlTag.SECTION) && summaryTree != null) {
+ summariesTree.addContent(summaryTree);
+ }
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ mainTree.addContent(summariesTree);
+ contentTree.addContent(mainTree);
+ } else {
+ contentTree.addContent(summariesTree);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addFooter(Content contentTree) {
+ Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
+ ? HtmlTree.FOOTER()
+ : contentTree;
+ addNavLinks(false, htmlTree);
+ addBottom(htmlTree);
+ if (configuration.allowTag(HtmlTag.FOOTER)) {
+ contentTree.addContent(htmlTree);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void printDocument(Content contentTree) throws IOException {
+ printHtmlDocument(null, true, contentTree);
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java
new file mode 100644
index 00000000000..c3f3a41e163
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java
@@ -0,0 +1,354 @@
+/*
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+import java.util.*;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.ConstructorWriter;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
+import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
+
+
+/**
+ * Writes constructor documentation.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Robert Field
+ * @author Atul M Dambalkar
+ * @author Bhavesh Patel (Modified)
+ */
+public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
+ implements ConstructorWriter, MemberSummaryWriter {
+
+ private boolean foundNonPubConstructor = false;
+
+ /**
+ * Construct a new ConstructorWriterImpl.
+ *
+ * @param writer The writer for the class that the constructors belong to.
+ * @param typeElement the class being documented.
+ */
+ public ConstructorWriterImpl(SubWriterHolderWriter writer, TypeElement typeElement) {
+ super(writer, typeElement);
+
+ VisibleMemberMap visibleMemberMap = new VisibleMemberMap(
+ typeElement,
+ VisibleMemberMap.Kind.CONSTRUCTORS, configuration);
+ SortedSet constructors = visibleMemberMap.getMembersFor(typeElement);
+ for (Element constructor : constructors) {
+ if (utils.isProtected(constructor) || utils.isPrivate(constructor)) {
+ setFoundNonPubConstructor(true);
+ }
+ }
+ }
+
+ /**
+ * Construct a new ConstructorWriterImpl.
+ *
+ * @param writer The writer for the class that the constructors belong to.
+ */
+ public ConstructorWriterImpl(SubWriterHolderWriter writer) {
+ super(writer);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getMemberSummaryHeader(TypeElement typeElement,
+ Content memberSummaryTree) {
+ memberSummaryTree.addContent(HtmlConstants.START_OF_CONSTRUCTOR_SUMMARY);
+ Content memberTree = writer.getMemberTreeHeader();
+ writer.addSummaryHeader(this, typeElement, memberTree);
+ return memberTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addMemberTree(Content memberSummaryTree, Content memberTree) {
+ writer.addMemberTree(memberSummaryTree, memberTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getConstructorDetailsTreeHeader(TypeElement typeElement,
+ Content memberDetailsTree) {
+ memberDetailsTree.addContent(HtmlConstants.START_OF_CONSTRUCTOR_DETAILS);
+ Content constructorDetailsTree = writer.getMemberTreeHeader();
+ constructorDetailsTree.addContent(writer.getMarkerAnchor(
+ SectionName.CONSTRUCTOR_DETAIL));
+ Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+ writer.constructorDetailsLabel);
+ constructorDetailsTree.addContent(heading);
+ return constructorDetailsTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getConstructorDocTreeHeader(ExecutableElement constructor,
+ Content constructorDetailsTree) {
+ String erasureAnchor;
+ if ((erasureAnchor = getErasureAnchor(constructor)) != null) {
+ constructorDetailsTree.addContent(writer.getMarkerAnchor((erasureAnchor)));
+ }
+ constructorDetailsTree.addContent(
+ writer.getMarkerAnchor(writer.getAnchor(constructor)));
+ Content constructorDocTree = writer.getMemberTreeHeader();
+ Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+ heading.addContent(name(constructor));
+ constructorDocTree.addContent(heading);
+ return constructorDocTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getSignature(ExecutableElement constructor) {
+ Content pre = new HtmlTree(HtmlTag.PRE);
+ writer.addAnnotationInfo(constructor, pre);
+ int annotationLength = pre.charCount();
+ addModifiers(constructor, pre);
+ if (configuration.linksource) {
+ Content constructorName = new StringContent(name(constructor));
+ writer.addSrcLink(constructor, constructorName, pre);
+ } else {
+ addName(name(constructor), pre);
+ }
+ int indent = pre.charCount() - annotationLength;
+ addParameters(constructor, pre, indent);
+ addExceptions(constructor, pre, indent);
+ return pre;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setSummaryColumnStyle(HtmlTree tdTree) {
+ if (foundNonPubConstructor)
+ tdTree.addStyle(HtmlStyle.colLast);
+ else
+ tdTree.addStyle(HtmlStyle.colOne);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addDeprecated(ExecutableElement constructor, Content constructorDocTree) {
+ addDeprecatedInfo(constructor, constructorDocTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addComments(ExecutableElement constructor, Content constructorDocTree) {
+ addComment(constructor, constructorDocTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addTags(ExecutableElement constructor, Content constructorDocTree) {
+ writer.addTagsInfo(constructor, constructorDocTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getConstructorDetails(Content constructorDetailsTree) {
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ HtmlTree htmlTree = HtmlTree.SECTION(getMemberTree(constructorDetailsTree));
+ return htmlTree;
+ }
+ return getMemberTree(constructorDetailsTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getConstructorDoc(Content constructorDocTree,
+ boolean isLastContent) {
+ return getMemberTree(constructorDocTree, isLastContent);
+ }
+
+ /**
+ * Close the writer.
+ */
+ @Override
+ public void close() throws IOException {
+ writer.close();
+ }
+
+ /**
+ * Let the writer know whether a non public constructor was found.
+ *
+ * @param foundNonPubConstructor true if we found a non public constructor.
+ */
+ @Override
+ public void setFoundNonPubConstructor(boolean foundNonPubConstructor) {
+ this.foundNonPubConstructor = foundNonPubConstructor;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addSummaryLabel(Content memberTree) {
+ Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+ writer.getResource("doclet.Constructor_Summary"));
+ memberTree.addContent(label);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getTableSummary() {
+ return configuration.getText("doclet.Member_Table_Summary",
+ configuration.getText("doclet.Constructor_Summary"),
+ configuration.getText("doclet.constructors"));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getCaption() {
+ return configuration.getResource("doclet.Constructors");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List getSummaryTableHeader(Element member) {
+ List header = new ArrayList<>();
+ if (foundNonPubConstructor) {
+ header.add(configuration.getText("doclet.Modifier"));
+ }
+ header.add(configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Constructor"),
+ configuration.getText("doclet.Description")));
+ return header;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addSummaryAnchor(TypeElement typeElement, Content memberTree) {
+ memberTree.addContent(writer.getMarkerAnchor(
+ SectionName.CONSTRUCTOR_SUMMARY));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
+ if (link) {
+ return writer.getHyperLink(SectionName.CONSTRUCTOR_SUMMARY,
+ writer.getResource("doclet.navConstructor"));
+ } else {
+ return writer.getResource("doclet.navConstructor");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addNavDetailLink(boolean link, Content liNav) {
+ if (link) {
+ liNav.addContent(writer.getHyperLink(
+ SectionName.CONSTRUCTOR_DETAIL,
+ writer.getResource("doclet.navConstructor")));
+ } else {
+ liNav.addContent(writer.getResource("doclet.navConstructor"));
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addSummaryType(Element member, Content tdSummaryType) {
+ if (foundNonPubConstructor) {
+ Content code = new HtmlTree(HtmlTag.CODE);
+ if (utils.isProtected(member)) {
+ code.addContent("protected ");
+ } else if (utils.isPrivate(member)) {
+ code.addContent("private ");
+ } else if (utils.isPublic(member)) {
+ code.addContent(writer.getSpace());
+ } else {
+ code.addContent(
+ configuration.getText("doclet.Package_private"));
+ }
+ tdSummaryType.addContent(code);
+ }
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java
new file mode 100644
index 00000000000..6defcd7614d
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java
@@ -0,0 +1,385 @@
+/*
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.List;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DeprecatedAPIListBuilder;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+
+import static jdk.javadoc.internal.doclets.toolkit.util.DeprecatedAPIListBuilder.*;
+
+/**
+ * Generate File to list all the deprecated classes and class members with the
+ * appropriate links.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @see java.util.List
+ * @author Atul M Dambalkar
+ * @author Bhavesh Patel (Modified)
+ */
+public class DeprecatedListWriter extends SubWriterHolderWriter {
+
+ private String getAnchorName(DeprElementKind kind) {
+ switch (kind) {
+ case PACKAGE:
+ return "package";
+ case INTERFACE:
+ return "interface";
+ case CLASS:
+ return "class";
+ case ENUM:
+ return "enum";
+ case EXCEPTION:
+ return "exception";
+ case ERROR:
+ return "error";
+ case ANNOTATION_TYPE:
+ return "annotation.type";
+ case FIELD:
+ return "field";
+ case METHOD:
+ return "method";
+ case CONSTRUCTOR:
+ return "constructor";
+ case ENUM_CONSTANT:
+ return "enum.constant";
+ case ANNOTATION_TYPE_MEMBER:
+ return "annotation.type.member";
+ default:
+ throw new AssertionError("unknown kind: " + kind);
+ }
+ }
+
+ private String getHeadingKey(DeprElementKind kind) {
+ switch (kind) {
+ case PACKAGE:
+ return "doclet.Deprecated_Packages";
+ case INTERFACE:
+ return "doclet.Deprecated_Interfaces";
+ case CLASS:
+ return "doclet.Deprecated_Classes";
+ case ENUM:
+ return "doclet.Deprecated_Enums";
+ case EXCEPTION:
+ return "doclet.Deprecated_Exceptions";
+ case ERROR:
+ return "doclet.Deprecated_Errors";
+ case ANNOTATION_TYPE:
+ return "doclet.Deprecated_Annotation_Types";
+ case FIELD:
+ return "doclet.Deprecated_Fields";
+ case METHOD:
+ return "doclet.Deprecated_Methods";
+ case CONSTRUCTOR:
+ return "doclet.Deprecated_Constructors";
+ case ENUM_CONSTANT:
+ return "doclet.Deprecated_Enum_Constants";
+ case ANNOTATION_TYPE_MEMBER:
+ return "doclet.Deprecated_Annotation_Type_Members";
+ default:
+ throw new AssertionError("unknown kind: " + kind);
+ }
+ }
+
+ private String getSummaryKey(DeprElementKind kind) {
+ switch (kind) {
+ case PACKAGE:
+ return "doclet.deprecated_packages";
+ case INTERFACE:
+ return "doclet.deprecated_interfaces";
+ case CLASS:
+ return "doclet.deprecated_classes";
+ case ENUM:
+ return "doclet.deprecated_enums";
+ case EXCEPTION:
+ return "doclet.deprecated_exceptions";
+ case ERROR:
+ return "doclet.deprecated_errors";
+ case ANNOTATION_TYPE:
+ return "doclet.deprecated_annotation_types";
+ case FIELD:
+ return "doclet.deprecated_fields";
+ case METHOD:
+ return "doclet.deprecated_methods";
+ case CONSTRUCTOR:
+ return "doclet.deprecated_constructors";
+ case ENUM_CONSTANT:
+ return "doclet.deprecated_enum_constants";
+ case ANNOTATION_TYPE_MEMBER:
+ return "doclet.deprecated_annotation_type_members";
+ default:
+ throw new AssertionError("unknown kind: " + kind);
+ }
+ }
+
+ private String getHeaderKey(DeprElementKind kind) {
+ switch (kind) {
+ case PACKAGE:
+ return "doclet.Package";
+ case INTERFACE:
+ return "doclet.Interface";
+ case CLASS:
+ return "doclet.Class";
+ case ENUM:
+ return "doclet.Enum";
+ case EXCEPTION:
+ return "doclet.Exceptions";
+ case ERROR:
+ return "doclet.Errors";
+ case ANNOTATION_TYPE:
+ return "doclet.AnnotationType";
+ case FIELD:
+ return "doclet.Field";
+ case METHOD:
+ return "doclet.Method";
+ case CONSTRUCTOR:
+ return "doclet.Constructor";
+ case ENUM_CONSTANT:
+ return "doclet.Enum_Constant";
+ case ANNOTATION_TYPE_MEMBER:
+ return "doclet.Annotation_Type_Member";
+ default:
+ throw new AssertionError("unknown kind: " + kind);
+ }
+ }
+
+ private EnumMap writerMap;
+
+ private ConfigurationImpl configuration;
+
+ /**
+ * Constructor.
+ *
+ * @param filename the file to be generated.
+ */
+
+ public DeprecatedListWriter(ConfigurationImpl configuration,
+ DocPath filename) throws IOException {
+ super(configuration, filename);
+ this.configuration = configuration;
+ NestedClassWriterImpl classW = new NestedClassWriterImpl(this);
+ writerMap = new EnumMap<>(DeprElementKind.class);
+ for (DeprElementKind kind : DeprElementKind.values()) {
+ switch (kind) {
+ case PACKAGE:
+ case INTERFACE:
+ case CLASS:
+ case ENUM:
+ case EXCEPTION:
+ case ERROR:
+ case ANNOTATION_TYPE:
+ writerMap.put(kind, classW);
+ break;
+ case FIELD:
+ writerMap.put(kind, new FieldWriterImpl(this));
+ break;
+ case METHOD:
+ writerMap.put(kind, new MethodWriterImpl(this));
+ break;
+ case CONSTRUCTOR:
+ writerMap.put(kind, new ConstructorWriterImpl(this));
+ break;
+ case ENUM_CONSTANT:
+ writerMap.put(kind, new EnumConstantWriterImpl(this));
+ break;
+ case ANNOTATION_TYPE_MEMBER:
+ writerMap.put(kind, new AnnotationTypeOptionalMemberWriterImpl(this, null));
+ break;
+ default:
+ throw new AssertionError("unknown kind: " + kind);
+ }
+ }
+ }
+
+ /**
+ * Get list of all the deprecated classes and members in all the Packages
+ * specified on the Command Line.
+ * Then instantiate DeprecatedListWriter and generate File.
+ *
+ * @param configuration the current configuration of the doclet.
+ */
+ public static void generate(ConfigurationImpl configuration) {
+ DocPath filename = DocPaths.DEPRECATED_LIST;
+ try {
+ DeprecatedListWriter depr =
+ new DeprecatedListWriter(configuration, filename);
+ depr.generateDeprecatedListFile(
+ new DeprecatedAPIListBuilder(configuration));
+ depr.close();
+ } catch (IOException exc) {
+ configuration.standardmessage.error(
+ "doclet.exception_encountered",
+ exc.toString(), filename);
+ throw new DocletAbortException(exc);
+ }
+ }
+
+ /**
+ * Generate the deprecated API list.
+ *
+ * @param deprapi list of deprecated API built already.
+ */
+ protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi)
+ throws IOException {
+ HtmlTree body = getHeader();
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
+ ? HtmlTree.MAIN()
+ : body;
+ htmlTree.addContent(getContentsList(deprapi));
+ String memberTableSummary;
+ HtmlTree div = new HtmlTree(HtmlTag.DIV);
+ div.addStyle(HtmlStyle.contentContainer);
+ for (DeprElementKind kind : DeprElementKind.values()) {
+ if (deprapi.hasDocumentation(kind)) {
+ addAnchor(deprapi, kind, div);
+ memberTableSummary =
+ configuration.getText("doclet.Member_Table_Summary",
+ configuration.getText(getHeadingKey(kind)),
+ configuration.getText(getSummaryKey(kind)));
+ List memberTableHeader = new ArrayList<>();
+ memberTableHeader.add(configuration.getText("doclet.0_and_1",
+ configuration.getText(getHeaderKey(kind)),
+ configuration.getText("doclet.Description")));
+ if (kind == DeprElementKind.PACKAGE)
+ addPackageDeprecatedAPI(deprapi.getSet(kind),
+ getHeadingKey(kind), memberTableSummary, memberTableHeader, div);
+ else
+ writerMap.get(kind).addDeprecatedAPI(deprapi.getSet(kind),
+ getHeadingKey(kind), memberTableSummary, memberTableHeader, div);
+ }
+ }
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ htmlTree.addContent(div);
+ body.addContent(htmlTree);
+ } else {
+ body.addContent(div);
+ }
+ htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
+ ? HtmlTree.FOOTER()
+ : body;
+ addNavLinks(false, htmlTree);
+ addBottom(htmlTree);
+ if (configuration.allowTag(HtmlTag.FOOTER)) {
+ body.addContent(htmlTree);
+ }
+ printHtmlDocument(null, true, body);
+ }
+
+ /**
+ * Add the index link.
+ *
+ * @param builder the deprecated list builder
+ * @param type the type of list being documented
+ * @param contentTree the content tree to which the index link will be added
+ */
+ private void addIndexLink(DeprecatedAPIListBuilder builder,
+ DeprElementKind kind, Content contentTree) {
+ if (builder.hasDocumentation(kind)) {
+ Content li = HtmlTree.LI(getHyperLink(getAnchorName(kind),
+ getResource(getHeadingKey(kind))));
+ contentTree.addContent(li);
+ }
+ }
+
+ /**
+ * Get the contents list.
+ *
+ * @param deprapi the deprecated list builder
+ * @return a content tree for the contents list
+ */
+ public Content getContentsList(DeprecatedAPIListBuilder deprapi) {
+ Content headContent = getResource("doclet.Deprecated_API");
+ Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+ HtmlStyle.title, headContent);
+ Content div = HtmlTree.DIV(HtmlStyle.header, heading);
+ Content headingContent = getResource("doclet.Contents");
+ div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
+ headingContent));
+ Content ul = new HtmlTree(HtmlTag.UL);
+ for (DeprElementKind kind : DeprElementKind.values()) {
+ addIndexLink(deprapi, kind, ul);
+ }
+ div.addContent(ul);
+ return div;
+ }
+
+ /**
+ * Add the anchor.
+ *
+ * @param builder the deprecated list builder
+ * @param type the type of list being documented
+ * @param htmlTree the content tree to which the anchor will be added
+ */
+ private void addAnchor(DeprecatedAPIListBuilder builder, DeprElementKind kind, Content htmlTree) {
+ if (builder.hasDocumentation(kind)) {
+ htmlTree.addContent(getMarkerAnchor(getAnchorName(kind)));
+ }
+ }
+
+ /**
+ * Get the header for the deprecated API Listing.
+ *
+ * @return a content tree for the header
+ */
+ public HtmlTree getHeader() {
+ String title = configuration.getText("doclet.Window_Deprecated_List");
+ HtmlTree bodyTree = getBody(true, getWindowTitle(title));
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
+ ? HtmlTree.HEADER()
+ : bodyTree;
+ addTop(htmlTree);
+ addNavLinks(true, htmlTree);
+ if (configuration.allowTag(HtmlTag.HEADER)) {
+ bodyTree.addContent(htmlTree);
+ }
+ return bodyTree;
+ }
+
+ /**
+ * Get the deprecated label.
+ *
+ * @return a content tree for the deprecated label
+ */
+ protected Content getNavLinkDeprecated() {
+ Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, deprecatedLabel);
+ return li;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java
new file mode 100644
index 00000000000..fc8bf385bb6
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java
@@ -0,0 +1,330 @@
+/*
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.EnumConstantWriter;
+import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
+
+/**
+ * Writes enum constant documentation in HTML format.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Jamie Ho
+ * @author Bhavesh Patel (Modified)
+ */
+public class EnumConstantWriterImpl extends AbstractMemberWriter
+ implements EnumConstantWriter, MemberSummaryWriter {
+
+ public EnumConstantWriterImpl(SubWriterHolderWriter writer, TypeElement typeElement) {
+ super(writer, typeElement);
+ }
+
+ public EnumConstantWriterImpl(SubWriterHolderWriter writer) {
+ super(writer);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getMemberSummaryHeader(TypeElement typeElement,
+ Content memberSummaryTree) {
+ memberSummaryTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_SUMMARY);
+ Content memberTree = writer.getMemberTreeHeader();
+ writer.addSummaryHeader(this, typeElement, memberTree);
+ return memberTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addMemberTree(Content memberSummaryTree, Content memberTree) {
+ writer.addMemberTree(memberSummaryTree, memberTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getEnumConstantsDetailsTreeHeader(TypeElement typeElement,
+ Content memberDetailsTree) {
+ memberDetailsTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_DETAILS);
+ Content enumConstantsDetailsTree = writer.getMemberTreeHeader();
+ enumConstantsDetailsTree.addContent(writer.getMarkerAnchor(
+ SectionName.ENUM_CONSTANT_DETAIL));
+ Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+ writer.enumConstantsDetailsLabel);
+ enumConstantsDetailsTree.addContent(heading);
+ return enumConstantsDetailsTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getEnumConstantsTreeHeader(VariableElement enumConstant,
+ Content enumConstantsDetailsTree) {
+ enumConstantsDetailsTree.addContent(
+ writer.getMarkerAnchor(name(enumConstant)));
+ Content enumConstantsTree = writer.getMemberTreeHeader();
+ Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+ heading.addContent(name(enumConstant));
+ enumConstantsTree.addContent(heading);
+ return enumConstantsTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getSignature(VariableElement enumConstant) {
+ Content pre = new HtmlTree(HtmlTag.PRE);
+ writer.addAnnotationInfo(enumConstant, pre);
+ addModifiers(enumConstant, pre);
+ Content enumConstantLink = writer.getLink(new LinkInfoImpl(
+ configuration, LinkInfoImpl.Kind.MEMBER, enumConstant.asType()));
+ pre.addContent(enumConstantLink);
+ pre.addContent(" ");
+ if (configuration.linksource) {
+ Content enumConstantName = new StringContent(name(enumConstant));
+ writer.addSrcLink(enumConstant, enumConstantName, pre);
+ } else {
+ addName(name(enumConstant), pre);
+ }
+ return pre;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addDeprecated(VariableElement enumConstant, Content enumConstantsTree) {
+ addDeprecatedInfo(enumConstant, enumConstantsTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addComments(VariableElement enumConstant, Content enumConstantsTree) {
+ addComment(enumConstant, enumConstantsTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addTags(VariableElement enumConstant, Content enumConstantsTree) {
+ writer.addTagsInfo(enumConstant, enumConstantsTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getEnumConstantsDetails(Content enumConstantsDetailsTree) {
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ HtmlTree htmlTree = HtmlTree.SECTION(getMemberTree(enumConstantsDetailsTree));
+ return htmlTree;
+ }
+ return getMemberTree(enumConstantsDetailsTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getEnumConstants(Content enumConstantsTree,
+ boolean isLastContent) {
+ return getMemberTree(enumConstantsTree, isLastContent);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void close() throws IOException {
+ writer.close();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addSummaryLabel(Content memberTree) {
+ Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+ writer.getResource("doclet.Enum_Constant_Summary"));
+ memberTree.addContent(label);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getTableSummary() {
+ return configuration.getText("doclet.Member_Table_Summary",
+ configuration.getText("doclet.Enum_Constant_Summary"),
+ configuration.getText("doclet.enum_constants"));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getCaption() {
+ return configuration.getResource("doclet.Enum_Constants");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List getSummaryTableHeader(Element member) {
+ List header = Arrays.asList(configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Enum_Constant"),
+ configuration.getText("doclet.Description")));
+ return header;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addSummaryAnchor(TypeElement typeElement, Content memberTree) {
+ memberTree.addContent(writer.getMarkerAnchor(
+ SectionName.ENUM_CONSTANT_SUMMARY));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element member,
+ Content tdSummary) {
+ Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink,
+ writer.getDocLink(context, member, name(member), false));
+ Content code = HtmlTree.CODE(memberLink);
+ tdSummary.addContent(code);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setSummaryColumnStyle(HtmlTree tdTree) {
+ tdTree.addStyle(HtmlStyle.colOne);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addInheritedSummaryLink(TypeElement typeElement, Element member, Content linksTree) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addSummaryType(Element member, Content tdSummaryType) {
+ //Not applicable.
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Content getDeprecatedLink(Element member) {
+ String name = utils.getFullyQualifiedName(member) + "." + member.getSimpleName();
+ return writer.getDocLink(LinkInfoImpl.Kind.MEMBER, member, name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
+ if (link) {
+ if (typeElement == null) {
+ return writer.getHyperLink(SectionName.ENUM_CONSTANT_SUMMARY,
+ writer.getResource("doclet.navEnum"));
+ } else {
+ return writer.getHyperLink(
+ SectionName.ENUM_CONSTANTS_INHERITANCE,
+ configuration.getClassName(typeElement), writer.getResource("doclet.navEnum"));
+ }
+ } else {
+ return writer.getResource("doclet.navEnum");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addNavDetailLink(boolean link, Content liNav) {
+ if (link) {
+ liNav.addContent(writer.getHyperLink(
+ SectionName.ENUM_CONSTANT_DETAIL,
+ writer.getResource("doclet.navEnum")));
+ } else {
+ liNav.addContent(writer.getResource("doclet.navEnum"));
+ }
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java
new file mode 100644
index 00000000000..b5e6c03b5f1
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java
@@ -0,0 +1,339 @@
+/*
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.FieldWriter;
+import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
+
+/**
+ * Writes field documentation in HTML format.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Robert Field
+ * @author Atul M Dambalkar
+ * @author Jamie Ho (rewrite)
+ * @author Bhavesh Patel (Modified)
+ */
+public class FieldWriterImpl extends AbstractMemberWriter
+ implements FieldWriter, MemberSummaryWriter {
+
+ public FieldWriterImpl(SubWriterHolderWriter writer, TypeElement typeElement) {
+ super(writer, typeElement);
+ }
+
+ public FieldWriterImpl(SubWriterHolderWriter writer) {
+ super(writer);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getMemberSummaryHeader(TypeElement typeElement,
+ Content memberSummaryTree) {
+ memberSummaryTree.addContent(HtmlConstants.START_OF_FIELD_SUMMARY);
+ Content memberTree = writer.getMemberTreeHeader();
+ writer.addSummaryHeader(this, typeElement, memberTree);
+ return memberTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addMemberTree(Content memberSummaryTree, Content memberTree) {
+ writer.addMemberTree(memberSummaryTree, memberTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getFieldDetailsTreeHeader(TypeElement typeElement, Content memberDetailsTree) {
+ memberDetailsTree.addContent(HtmlConstants.START_OF_FIELD_DETAILS);
+ Content fieldDetailsTree = writer.getMemberTreeHeader();
+ fieldDetailsTree.addContent(writer.getMarkerAnchor(
+ SectionName.FIELD_DETAIL));
+ Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+ writer.fieldDetailsLabel);
+ fieldDetailsTree.addContent(heading);
+ return fieldDetailsTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getFieldDocTreeHeader(VariableElement field, Content fieldDetailsTree) {
+ fieldDetailsTree.addContent(writer.getMarkerAnchor(name(field)));
+ Content fieldTree = writer.getMemberTreeHeader();
+ Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+ heading.addContent(name(field));
+ fieldTree.addContent(heading);
+ return fieldTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getSignature(VariableElement field) {
+ Content pre = new HtmlTree(HtmlTag.PRE);
+ writer.addAnnotationInfo(field, pre);
+ addModifiers(field, pre);
+ Content fieldlink = writer.getLink(new LinkInfoImpl(
+ configuration, LinkInfoImpl.Kind.MEMBER, field.asType()));
+ pre.addContent(fieldlink);
+ pre.addContent(" ");
+ if (configuration.linksource) {
+ Content fieldName = new StringContent(name(field));
+ writer.addSrcLink(field, fieldName, pre);
+ } else {
+ addName(name(field), pre);
+ }
+ return pre;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addDeprecated(VariableElement field, Content fieldTree) {
+ addDeprecatedInfo(field, fieldTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addComments(VariableElement field, Content fieldTree) {
+ if (!utils.getBody(field).isEmpty()) {
+ writer.addInlineComment(field, fieldTree);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addTags(VariableElement field, Content fieldTree) {
+ writer.addTagsInfo(field, fieldTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getFieldDetails(Content fieldDetailsTree) {
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ HtmlTree htmlTree = HtmlTree.SECTION(getMemberTree(fieldDetailsTree));
+ return htmlTree;
+ }
+ return getMemberTree(fieldDetailsTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getFieldDoc(Content fieldTree,
+ boolean isLastContent) {
+ return getMemberTree(fieldTree, isLastContent);
+ }
+
+ /**
+ * Close the writer.
+ */
+ @Override
+ public void close() throws IOException {
+ writer.close();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addSummaryLabel(Content memberTree) {
+ Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+ writer.getResource("doclet.Field_Summary"));
+ memberTree.addContent(label);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getTableSummary() {
+ return configuration.getText("doclet.Member_Table_Summary",
+ configuration.getText("doclet.Field_Summary"),
+ configuration.getText("doclet.fields"));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getCaption() {
+ return configuration.getResource("doclet.Fields");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List getSummaryTableHeader(Element member) {
+ List header = Arrays.asList(writer.getModifierTypeHeader(),
+ configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Field"),
+ configuration.getText("doclet.Description")));
+ return header;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addSummaryAnchor(TypeElement typeElement, Content memberTree) {
+ memberTree.addContent(writer.getMarkerAnchor(
+ SectionName.FIELD_SUMMARY));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) {
+ inheritedTree.addContent(writer.getMarkerAnchor(
+ SectionName.FIELDS_INHERITANCE, configuration.getClassName(typeElement)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) {
+ Content classLink = writer.getPreQualifiedClassLink(
+ LinkInfoImpl.Kind.MEMBER, typeElement, false);
+ Content label = new StringContent(utils.isClass(typeElement)
+ ? configuration.getText("doclet.Fields_Inherited_From_Class")
+ : configuration.getText("doclet.Fields_Inherited_From_Interface"));
+ Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
+ label);
+ labelHeading.addContent(writer.getSpace());
+ labelHeading.addContent(classLink);
+ inheritedTree.addContent(labelHeading);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element member,
+ Content tdSummary) {
+ Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink,
+ writer.getDocLink(context, typeElement , member, name(member), false));
+ Content code = HtmlTree.CODE(memberLink);
+ tdSummary.addContent(code);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addInheritedSummaryLink(TypeElement typeElement, Element member, Content linksTree) {
+ linksTree.addContent(
+ writer.getDocLink(LinkInfoImpl.Kind.MEMBER, typeElement, member,
+ name(member), false));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addSummaryType(Element member, Content tdSummaryType) {
+ addModifierAndType(member, member.asType(), tdSummaryType);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Content getDeprecatedLink(Element member) {
+ String name = utils.getFullyQualifiedName(member) + "." + member.getSimpleName();
+ return writer.getDocLink(LinkInfoImpl.Kind.MEMBER, member, name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
+ if (link) {
+ if (typeElement == null) {
+ return writer.getHyperLink(
+ SectionName.FIELD_SUMMARY,
+ writer.getResource("doclet.navField"));
+ } else {
+ return writer.getHyperLink(
+ SectionName.FIELDS_INHERITANCE,
+ configuration.getClassName(typeElement), writer.getResource("doclet.navField"));
+ }
+ } else {
+ return writer.getResource("doclet.navField");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addNavDetailLink(boolean link, Content liNav) {
+ if (link) {
+ liNav.addContent(writer.getHyperLink(
+ SectionName.FIELD_DETAIL,
+ writer.getResource("doclet.navField")));
+ } else {
+ liNav.addContent(writer.getResource("doclet.navField"));
+ }
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java
new file mode 100644
index 00000000000..69be1be292e
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+
+
+/**
+ * Generate the documentation in the Html "frame" format in the browser. The
+ * generated documentation will have two or three frames depending upon the
+ * number of packages on the command line. In general there will be three frames
+ * in the output, a left-hand top frame will have a list of all packages with
+ * links to target left-hand bottom frame. The left-hand bottom frame will have
+ * the particular package contents or the all-classes list, where as the single
+ * right-hand frame will have overview or package summary or class file. Also
+ * take care of browsers which do not support Html frames.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Atul M Dambalkar
+ */
+public class FrameOutputWriter extends HtmlDocletWriter {
+
+ /**
+ * Number of packages specified on the command line.
+ */
+ int noOfPackages;
+
+ /**
+ * Constructor to construct FrameOutputWriter object.
+ *
+ * @param configuration for this run
+ * @param filename File to be generated.
+ * @throws java.io.IOException
+ */
+ public FrameOutputWriter(ConfigurationImpl configuration, DocPath filename) throws IOException {
+ super(configuration, filename);
+ noOfPackages = configuration.packages.size();
+ }
+
+ /**
+ * Construct FrameOutputWriter object and then use it to generate the Html
+ * file which will have the description of all the frames in the
+ * documentation. The name of the generated file is "index.html" which is
+ * the default first file for Html documents.
+ * @throws DocletAbortException
+ */
+ public static void generate(ConfigurationImpl configuration) {
+ FrameOutputWriter framegen;
+ DocPath filename = DocPath.empty;
+ try {
+ filename = DocPaths.INDEX;
+ framegen = new FrameOutputWriter(configuration, filename);
+ framegen.generateFrameFile();
+ framegen.close();
+ } catch (IOException exc) {
+ configuration.standardmessage.error(
+ "doclet.exception_encountered",
+ exc.toString(), filename);
+ throw new DocletAbortException(exc);
+ }
+ }
+
+ /**
+ * Generate the constants in the "index.html" file. Print the frame details
+ * as well as warning if browser is not supporting the Html frames.
+ */
+ protected void generateFrameFile() throws IOException {
+ Content frame = getFrameDetails();
+ HtmlTree body = new HtmlTree(HtmlTag.BODY);
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ HtmlTree main = HtmlTree.MAIN(frame);
+ body.addContent(main);
+ } else {
+ body.addContent(frame);
+ }
+ if (configuration.windowtitle.length() > 0) {
+ printFramesDocument(configuration.windowtitle, configuration,
+ body);
+ } else {
+ printFramesDocument(configuration.getText("doclet.Generated_Docs_Untitled"),
+ configuration, body);
+ }
+ }
+
+ /**
+ * Get the frame sizes and their contents.
+ *
+ * @return a content tree for the frame details
+ */
+ protected Content getFrameDetails() {
+ HtmlTree leftContainerDiv = new HtmlTree(HtmlTag.DIV);
+ HtmlTree rightContainerDiv = new HtmlTree(HtmlTag.DIV);
+ leftContainerDiv.addStyle(HtmlStyle.leftContainer);
+ rightContainerDiv.addStyle(HtmlStyle.rightContainer);
+ if (noOfPackages <= 1) {
+ addAllClassesFrameTag(leftContainerDiv);
+ } else if (noOfPackages > 1) {
+ addAllPackagesFrameTag(leftContainerDiv);
+ addAllClassesFrameTag(leftContainerDiv);
+ }
+ addClassFrameTag(rightContainerDiv);
+ HtmlTree mainContainer = HtmlTree.DIV(HtmlStyle.mainContainer, leftContainerDiv);
+ mainContainer.addContent(rightContainerDiv);
+ return mainContainer;
+ }
+
+ /**
+ * Add the IFRAME tag for the frame that lists all packages.
+ *
+ * @param contentTree the content tree to which the information will be added
+ */
+ private void addAllPackagesFrameTag(Content contentTree) {
+ HtmlTree frame = HtmlTree.IFRAME(DocPaths.OVERVIEW_FRAME.getPath(),
+ "packageListFrame", configuration.getText("doclet.All_Packages"));
+ HtmlTree leftTop = HtmlTree.DIV(HtmlStyle.leftTop, frame);
+ contentTree.addContent(leftTop);
+ }
+
+ /**
+ * Add the IFRAME tag for the frame that lists all classes.
+ *
+ * @param contentTree the content tree to which the information will be added
+ */
+ private void addAllClassesFrameTag(Content contentTree) {
+ HtmlTree frame = HtmlTree.IFRAME(DocPaths.ALLCLASSES_FRAME.getPath(),
+ "packageFrame", configuration.getText("doclet.All_classes_and_interfaces"));
+ HtmlTree leftBottom = HtmlTree.DIV(HtmlStyle.leftBottom, frame);
+ contentTree.addContent(leftBottom);
+ }
+
+ /**
+ * Add the IFRAME tag for the frame that describes the class in detail.
+ *
+ * @param contentTree the content tree to which the information will be added
+ */
+ private void addClassFrameTag(Content contentTree) {
+ HtmlTree frame = HtmlTree.IFRAME(configuration.topFile.getPath(), "classFrame",
+ configuration.getText("doclet.Package_class_and_interface_descriptions"));
+ frame.addStyle(HtmlStyle.rightIframe);
+ contentTree.addContent(frame);
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java
new file mode 100644
index 00000000000..784cabd3bc9
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java
@@ -0,0 +1,449 @@
+/*
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+
+
+/**
+ * Generate the Help File for the generated API documentation. The help file
+ * contents are helpful for browsing the generated documentation.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Atul M Dambalkar
+ */
+public class HelpWriter extends HtmlDocletWriter {
+
+ HtmlTree mainTree = HtmlTree.MAIN();
+
+ /**
+ * Constructor to construct HelpWriter object.
+ * @param filename File to be generated.
+ */
+ public HelpWriter(ConfigurationImpl configuration,
+ DocPath filename) throws IOException {
+ super(configuration, filename);
+ }
+
+ /**
+ * Construct the HelpWriter object and then use it to generate the help
+ * file. The name of the generated file is "help-doc.html". The help file
+ * will get generated if and only if "-helpfile" and "-nohelp" is not used
+ * on the command line.
+ * @throws DocletAbortException
+ */
+ public static void generate(ConfigurationImpl configuration) {
+ HelpWriter helpgen;
+ DocPath filename = DocPath.empty;
+ try {
+ filename = DocPaths.HELP_DOC;
+ helpgen = new HelpWriter(configuration, filename);
+ helpgen.generateHelpFile();
+ helpgen.close();
+ } catch (IOException exc) {
+ configuration.standardmessage.error(
+ "doclet.exception_encountered",
+ exc.toString(), filename);
+ throw new DocletAbortException(exc);
+ }
+ }
+
+ /**
+ * Generate the help file contents.
+ */
+ protected void generateHelpFile() throws IOException {
+ String title = configuration.getText("doclet.Window_Help_title");
+ HtmlTree body = getBody(true, getWindowTitle(title));
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
+ ? HtmlTree.HEADER()
+ : body;
+ addTop(htmlTree);
+ addNavLinks(true, htmlTree);
+ if (configuration.allowTag(HtmlTag.HEADER)) {
+ body.addContent(htmlTree);
+ }
+ addHelpFileContents(body);
+ if (configuration.allowTag(HtmlTag.FOOTER)) {
+ htmlTree = HtmlTree.FOOTER();
+ }
+ addNavLinks(false, htmlTree);
+ addBottom(htmlTree);
+ if (configuration.allowTag(HtmlTag.FOOTER)) {
+ body.addContent(htmlTree);
+ }
+ printHtmlDocument(null, true, body);
+ }
+
+ /**
+ * Add the help file contents from the resource file to the content tree. While adding the
+ * help file contents it also keeps track of user options. If "-notree"
+ * is used, then the "overview-tree.html" will not get added and hence
+ * help information also will not get added.
+ *
+ * @param contentTree the content tree to which the help file contents will be added
+ */
+ protected void addHelpFileContents(Content contentTree) {
+ Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false, HtmlStyle.title,
+ getResource("doclet.Help_line_1"));
+ Content div = HtmlTree.DIV(HtmlStyle.header, heading);
+ Content line2 = HtmlTree.DIV(HtmlStyle.subTitle,
+ getResource("doclet.Help_line_2"));
+ div.addContent(line2);
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ mainTree.addContent(div);
+ } else {
+ contentTree.addContent(div);
+ }
+ HtmlTree htmlTree;
+ HtmlTree ul = new HtmlTree(HtmlTag.UL);
+ ul.addStyle(HtmlStyle.blockList);
+ if (configuration.createoverview) {
+ Content overviewHeading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ getResource("doclet.Overview"));
+ htmlTree = (configuration.allowTag(HtmlTag.SECTION))
+ ? HtmlTree.SECTION(overviewHeading)
+ : HtmlTree.LI(HtmlStyle.blockList, overviewHeading);
+ Content line3 = getResource("doclet.Help_line_3",
+ getHyperLink(DocPaths.OVERVIEW_SUMMARY,
+ configuration.getText("doclet.Overview")));
+ Content overviewPara = HtmlTree.P(line3);
+ htmlTree.addContent(overviewPara);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
+ } else {
+ ul.addContent(htmlTree);
+ }
+ }
+ Content packageHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ getResource("doclet.Package"));
+ htmlTree = (configuration.allowTag(HtmlTag.SECTION))
+ ? HtmlTree.SECTION(packageHead)
+ : HtmlTree.LI(HtmlStyle.blockList, packageHead);
+ Content line4 = getResource("doclet.Help_line_4");
+ Content packagePara = HtmlTree.P(line4);
+ htmlTree.addContent(packagePara);
+ HtmlTree ulPackage = new HtmlTree(HtmlTag.UL);
+ ulPackage.addContent(HtmlTree.LI(
+ getResource("doclet.Interfaces_Italic")));
+ ulPackage.addContent(HtmlTree.LI(
+ getResource("doclet.Classes")));
+ ulPackage.addContent(HtmlTree.LI(
+ getResource("doclet.Enums")));
+ ulPackage.addContent(HtmlTree.LI(
+ getResource("doclet.Exceptions")));
+ ulPackage.addContent(HtmlTree.LI(
+ getResource("doclet.Errors")));
+ ulPackage.addContent(HtmlTree.LI(
+ getResource("doclet.AnnotationTypes")));
+ htmlTree.addContent(ulPackage);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
+ } else {
+ ul.addContent(htmlTree);
+ }
+ Content classHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ getResource("doclet.Help_line_5"));
+ htmlTree = (configuration.allowTag(HtmlTag.SECTION))
+ ? HtmlTree.SECTION(classHead)
+ : HtmlTree.LI(HtmlStyle.blockList, classHead);
+ Content line6 = getResource("doclet.Help_line_6");
+ Content classPara = HtmlTree.P(line6);
+ htmlTree.addContent(classPara);
+ HtmlTree ul1 = new HtmlTree(HtmlTag.UL);
+ ul1.addContent(HtmlTree.LI(
+ getResource("doclet.Help_line_7")));
+ ul1.addContent(HtmlTree.LI(
+ getResource("doclet.Help_line_8")));
+ ul1.addContent(HtmlTree.LI(
+ getResource("doclet.Help_line_9")));
+ ul1.addContent(HtmlTree.LI(
+ getResource("doclet.Help_line_10")));
+ ul1.addContent(HtmlTree.LI(
+ getResource("doclet.Help_line_11")));
+ ul1.addContent(HtmlTree.LI(
+ getResource("doclet.Help_line_12")));
+ htmlTree.addContent(ul1);
+ HtmlTree ul2 = new HtmlTree(HtmlTag.UL);
+ ul2.addContent(HtmlTree.LI(
+ getResource("doclet.Nested_Class_Summary")));
+ ul2.addContent(HtmlTree.LI(
+ getResource("doclet.Field_Summary")));
+ ul2.addContent(HtmlTree.LI(
+ getResource("doclet.Constructor_Summary")));
+ ul2.addContent(HtmlTree.LI(
+ getResource("doclet.Method_Summary")));
+ htmlTree.addContent(ul2);
+ HtmlTree ul3 = new HtmlTree(HtmlTag.UL);
+ ul3.addContent(HtmlTree.LI(
+ getResource("doclet.Field_Detail")));
+ ul3.addContent(HtmlTree.LI(
+ getResource("doclet.Constructor_Detail")));
+ ul3.addContent(HtmlTree.LI(
+ getResource("doclet.Method_Detail")));
+ htmlTree.addContent(ul3);
+ Content line13 = getResource("doclet.Help_line_13");
+ Content para = HtmlTree.P(line13);
+ htmlTree.addContent(para);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
+ } else {
+ ul.addContent(htmlTree);
+ }
+ //Annotation Types
+ Content aHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ getResource("doclet.AnnotationType"));
+ htmlTree = (configuration.allowTag(HtmlTag.SECTION))
+ ? HtmlTree.SECTION(aHead)
+ : HtmlTree.LI(HtmlStyle.blockList, aHead);
+ Content aline1 = getResource("doclet.Help_annotation_type_line_1");
+ Content aPara = HtmlTree.P(aline1);
+ htmlTree.addContent(aPara);
+ HtmlTree aul = new HtmlTree(HtmlTag.UL);
+ aul.addContent(HtmlTree.LI(
+ getResource("doclet.Help_annotation_type_line_2")));
+ aul.addContent(HtmlTree.LI(
+ getResource("doclet.Help_annotation_type_line_3")));
+ aul.addContent(HtmlTree.LI(
+ getResource("doclet.Annotation_Type_Required_Member_Summary")));
+ aul.addContent(HtmlTree.LI(
+ getResource("doclet.Annotation_Type_Optional_Member_Summary")));
+ aul.addContent(HtmlTree.LI(
+ getResource("doclet.Annotation_Type_Member_Detail")));
+ htmlTree.addContent(aul);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
+ } else {
+ ul.addContent(htmlTree);
+ }
+ //Enums
+ Content enumHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ getResource("doclet.Enum"));
+ htmlTree = (configuration.allowTag(HtmlTag.SECTION))
+ ? HtmlTree.SECTION(enumHead)
+ : HtmlTree.LI(HtmlStyle.blockList, enumHead);
+ Content eline1 = getResource("doclet.Help_enum_line_1");
+ Content enumPara = HtmlTree.P(eline1);
+ htmlTree.addContent(enumPara);
+ HtmlTree eul = new HtmlTree(HtmlTag.UL);
+ eul.addContent(HtmlTree.LI(
+ getResource("doclet.Help_enum_line_2")));
+ eul.addContent(HtmlTree.LI(
+ getResource("doclet.Help_enum_line_3")));
+ eul.addContent(HtmlTree.LI(
+ getResource("doclet.Enum_Constant_Summary")));
+ eul.addContent(HtmlTree.LI(
+ getResource("doclet.Enum_Constant_Detail")));
+ htmlTree.addContent(eul);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
+ } else {
+ ul.addContent(htmlTree);
+ }
+ if (configuration.classuse) {
+ Content useHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ getResource("doclet.Help_line_14"));
+ htmlTree = (configuration.allowTag(HtmlTag.SECTION))
+ ? HtmlTree.SECTION(useHead)
+ : HtmlTree.LI(HtmlStyle.blockList, useHead);
+ Content line15 = getResource("doclet.Help_line_15");
+ Content usePara = HtmlTree.P(line15);
+ htmlTree.addContent(usePara);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
+ } else {
+ ul.addContent(htmlTree);
+ }
+ }
+ if (configuration.createtree) {
+ Content treeHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ getResource("doclet.Help_line_16"));
+ htmlTree = (configuration.allowTag(HtmlTag.SECTION))
+ ? HtmlTree.SECTION(treeHead)
+ : HtmlTree.LI(HtmlStyle.blockList, treeHead);
+ Content line17 = getResource("doclet.Help_line_17_with_tree_link",
+ getHyperLink(DocPaths.OVERVIEW_TREE,
+ configuration.getText("doclet.Class_Hierarchy")),
+ HtmlTree.CODE(new StringContent("java.lang.Object")));
+ Content treePara = HtmlTree.P(line17);
+ htmlTree.addContent(treePara);
+ HtmlTree tul = new HtmlTree(HtmlTag.UL);
+ tul.addContent(HtmlTree.LI(
+ getResource("doclet.Help_line_18")));
+ tul.addContent(HtmlTree.LI(
+ getResource("doclet.Help_line_19")));
+ htmlTree.addContent(tul);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
+ } else {
+ ul.addContent(htmlTree);
+ }
+ }
+ if (!(configuration.nodeprecatedlist ||
+ configuration.nodeprecated)) {
+ Content dHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ getResource("doclet.Deprecated_API"));
+ htmlTree = (configuration.allowTag(HtmlTag.SECTION))
+ ? HtmlTree.SECTION(dHead)
+ : HtmlTree.LI(HtmlStyle.blockList, dHead);
+ Content line20 = getResource("doclet.Help_line_20_with_deprecated_api_link",
+ getHyperLink(DocPaths.DEPRECATED_LIST,
+ configuration.getText("doclet.Deprecated_API")));
+ Content dPara = HtmlTree.P(line20);
+ htmlTree.addContent(dPara);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
+ } else {
+ ul.addContent(htmlTree);
+ }
+ }
+ if (configuration.createindex) {
+ Content indexlink;
+ if (configuration.splitindex) {
+ indexlink = getHyperLink(DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)),
+ configuration.getText("doclet.Index"));
+ } else {
+ indexlink = getHyperLink(DocPaths.INDEX_ALL,
+ configuration.getText("doclet.Index"));
+ }
+ Content indexHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ getResource("doclet.Help_line_21"));
+ htmlTree = (configuration.allowTag(HtmlTag.SECTION))
+ ? HtmlTree.SECTION(indexHead)
+ : HtmlTree.LI(HtmlStyle.blockList, indexHead);
+ Content line22 = getResource("doclet.Help_line_22", indexlink);
+ Content indexPara = HtmlTree.P(line22);
+ htmlTree.addContent(indexPara);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
+ } else {
+ ul.addContent(htmlTree);
+ }
+ }
+ Content prevHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ getResource("doclet.Help_line_23"));
+ htmlTree = (configuration.allowTag(HtmlTag.SECTION))
+ ? HtmlTree.SECTION(prevHead)
+ : HtmlTree.LI(HtmlStyle.blockList, prevHead);
+ Content line24 = getResource("doclet.Help_line_24");
+ Content prevPara = HtmlTree.P(line24);
+ htmlTree.addContent(prevPara);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
+ } else {
+ ul.addContent(htmlTree);
+ }
+ Content frameHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ getResource("doclet.Help_line_25"));
+ htmlTree = (configuration.allowTag(HtmlTag.SECTION))
+ ? HtmlTree.SECTION(frameHead)
+ : HtmlTree.LI(HtmlStyle.blockList, frameHead);
+ Content line26 = getResource("doclet.Help_line_26");
+ Content framePara = HtmlTree.P(line26);
+ htmlTree.addContent(framePara);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
+ } else {
+ ul.addContent(htmlTree);
+ }
+ Content allclassesHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ getResource("doclet.All_Classes"));
+ htmlTree = (configuration.allowTag(HtmlTag.SECTION))
+ ? HtmlTree.SECTION(allclassesHead)
+ : HtmlTree.LI(HtmlStyle.blockList, allclassesHead);
+ Content line27 = getResource("doclet.Help_line_27",
+ getHyperLink(DocPaths.ALLCLASSES_NOFRAME,
+ configuration.getText("doclet.All_Classes")));
+ Content allclassesPara = HtmlTree.P(line27);
+ htmlTree.addContent(allclassesPara);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
+ } else {
+ ul.addContent(htmlTree);
+ }
+ Content sHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ getResource("doclet.Serialized_Form"));
+ htmlTree = (configuration.allowTag(HtmlTag.SECTION))
+ ? HtmlTree.SECTION(sHead)
+ : HtmlTree.LI(HtmlStyle.blockList, sHead);
+ Content line28 = getResource("doclet.Help_line_28");
+ Content serialPara = HtmlTree.P(line28);
+ htmlTree.addContent(serialPara);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
+ } else {
+ ul.addContent(htmlTree);
+ }
+ Content constHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ getResource("doclet.Constants_Summary"));
+ htmlTree = (configuration.allowTag(HtmlTag.SECTION))
+ ? HtmlTree.SECTION(constHead)
+ : HtmlTree.LI(HtmlStyle.blockList, constHead);
+ Content line29 = getResource("doclet.Help_line_29",
+ getHyperLink(DocPaths.CONSTANT_VALUES,
+ configuration.getText("doclet.Constants_Summary")));
+ Content constPara = HtmlTree.P(line29);
+ htmlTree.addContent(constPara);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
+ } else {
+ ul.addContent(htmlTree);
+ }
+ Content divContent = HtmlTree.DIV(HtmlStyle.contentContainer, ul);
+ Content line30 = HtmlTree.SPAN(HtmlStyle.emphasizedPhrase, getResource("doclet.Help_line_30"));
+ divContent.addContent(line30);
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ mainTree.addContent(divContent);
+ contentTree.addContent(mainTree);
+ } else {
+ contentTree.addContent(divContent);
+ }
+ }
+
+ /**
+ * Get the help label.
+ *
+ * @return a content tree for the help label
+ */
+ @Override
+ protected Content getNavLinkHelp() {
+ Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, helpLabel);
+ return li;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java
new file mode 100644
index 00000000000..b0f8ad9b418
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java
@@ -0,0 +1,323 @@
+/*
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+import java.util.*;
+
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+
+import jdk.javadoc.doclet.Doclet.Option;
+import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.doclet.Reporter;
+import jdk.javadoc.internal.doclets.toolkit.AbstractDoclet;
+import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder;
+import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
+import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder;
+
+/**
+ * The class with "start" method, calls individual Writers.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Atul M Dambalkar
+ * @author Robert Field
+ * @author Jamie Ho
+ *
+ */
+public class HtmlDoclet extends AbstractDoclet {
+
+ public HtmlDoclet() {
+ configuration = new ConfigurationImpl();
+ }
+
+ /**
+ * The global configuration information for this run.
+ */
+ public final ConfigurationImpl configuration;
+
+
+ private static final DocPath DOCLET_RESOURCES = DocPath
+ .create("/jdk/javadoc/internal/doclets/formats/html/resources");
+
+ public void init(Locale locale, Reporter reporter) {
+ configuration.reporter = reporter;
+ configuration.locale = locale;
+ }
+
+ /**
+ * The "start" method as required by Javadoc.
+ *
+ * @param root the root of the documentation tree.
+ * @see jdk.doclet.DocletEnvironment
+ * @return true if the doclet ran without encountering any errors.
+ */
+ public boolean run(DocletEnvironment root) {
+ return startDoclet(root);
+ }
+
+ /**
+ * Create the configuration instance.
+ * Override this method to use a different
+ * configuration.
+ */
+ public Configuration configuration() {
+ return configuration;
+ }
+
+ /**
+ * Start the generation of files. Call generate methods in the individual
+ * writers, which will in turn genrate the documentation files. Call the
+ * TreeWriter generation first to ensure the Class Hierarchy is built
+ * first and then can be used in the later generation.
+ *
+ * For new format.
+ *
+ * @see jdk.doclet.RootDoc
+ */
+ protected void generateOtherFiles(DocletEnvironment root, ClassTree classtree)
+ throws Exception {
+ super.generateOtherFiles(root, classtree);
+ if (configuration.linksource) {
+ SourceToHTMLConverter.convertRoot(configuration,
+ root, DocPaths.SOURCE_OUTPUT);
+ }
+
+ if (configuration.topFile.isEmpty()) {
+ configuration.standardmessage.
+ error("doclet.No_Non_Deprecated_Classes_To_Document");
+ return;
+ }
+ boolean nodeprecated = configuration.nodeprecated;
+ performCopy(configuration.helpfile);
+ performCopy(configuration.stylesheetfile);
+ // do early to reduce memory footprint
+ if (configuration.classuse) {
+ ClassUseWriter.generate(configuration, classtree);
+ }
+ IndexBuilder indexbuilder = new IndexBuilder(configuration, nodeprecated);
+
+ if (configuration.createtree) {
+ TreeWriter.generate(configuration, classtree);
+ }
+ if (configuration.createindex) {
+ configuration.buildSearchTagIndex();
+ if (configuration.splitindex) {
+ SplitIndexWriter.generate(configuration, indexbuilder);
+ } else {
+ SingleIndexWriter.generate(configuration, indexbuilder);
+ }
+ }
+
+ if (!(configuration.nodeprecatedlist || nodeprecated)) {
+ DeprecatedListWriter.generate(configuration);
+ }
+
+ AllClassesFrameWriter.generate(configuration,
+ new IndexBuilder(configuration, nodeprecated, true));
+
+ FrameOutputWriter.generate(configuration);
+
+ if (configuration.createoverview) {
+ PackageIndexWriter.generate(configuration);
+ }
+ if (configuration.helpfile.length() == 0 &&
+ !configuration.nohelp) {
+ HelpWriter.generate(configuration);
+ }
+ // If a stylesheet file is not specified, copy the default stylesheet
+ // and replace newline with platform-specific newline.
+ DocFile f;
+ if (configuration.stylesheetfile.length() == 0) {
+ f = DocFile.createFileForOutput(configuration, DocPaths.STYLESHEET);
+ f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.STYLESHEET), false, true);
+ }
+ f = DocFile.createFileForOutput(configuration, DocPaths.JAVASCRIPT);
+ f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.JAVASCRIPT), true, true);
+ if (configuration.createindex) {
+ f = DocFile.createFileForOutput(configuration, DocPaths.SEARCH_JS);
+ f.copyResource(DOCLET_RESOURCES.resolve(DocPaths.SEARCH_JS), true, true);
+
+ f = DocFile.createFileForOutput(configuration, DocPaths.RESOURCES.resolve(DocPaths.GLASS_IMG));
+ f.copyResource(DOCLET_RESOURCES.resolve(DocPaths.GLASS_IMG), true, false);
+
+ f = DocFile.createFileForOutput(configuration, DocPaths.RESOURCES.resolve(DocPaths.X_IMG));
+ f.copyResource(DOCLET_RESOURCES.resolve(DocPaths.X_IMG), true, false);
+ copyJqueryFiles();
+ }
+ }
+
+ protected void copyJqueryFiles() {
+ List files = Arrays.asList(
+ "jquery-1.10.2.js",
+ "jquery-ui.js",
+ "jquery-ui.css",
+ "jquery-ui.min.js",
+ "jquery-ui.min.css",
+ "jquery-ui.structure.min.css",
+ "jquery-ui.structure.css",
+ "external/jquery/jquery.js",
+ "jszip/dist/jszip.js",
+ "jszip/dist/jszip.min.js",
+ "jszip-utils/dist/jszip-utils.js",
+ "jszip-utils/dist/jszip-utils.min.js",
+ "jszip-utils/dist/jszip-utils-ie.js",
+ "jszip-utils/dist/jszip-utils-ie.min.js",
+ "images/ui-bg_flat_0_aaaaaa_40x100.png",
+ "images/ui-icons_454545_256x240.png",
+ "images/ui-bg_glass_95_fef1ec_1x400.png",
+ "images/ui-bg_glass_75_dadada_1x400.png",
+ "images/ui-bg_highlight-soft_75_cccccc_1x100.png",
+ "images/ui-icons_888888_256x240.png",
+ "images/ui-icons_2e83ff_256x240.png",
+ "images/ui-bg_glass_65_ffffff_1x400.png",
+ "images/ui-icons_cd0a0a_256x240.png",
+ "images/ui-bg_glass_55_fbf9ee_1x400.png",
+ "images/ui-icons_222222_256x240.png",
+ "images/ui-bg_glass_75_e6e6e6_1x400.png",
+ "images/ui-bg_flat_75_ffffff_40x100.png");
+ DocFile f;
+ for (String file : files) {
+ DocPath filePath = DocPaths.JQUERY_FILES.resolve(file);
+ f = DocFile.createFileForOutput(configuration, filePath);
+ f.copyResource(DOCLET_RESOURCES.resolve(filePath), true, false);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void generateClassFiles(SortedSet arr, ClassTree classtree) {
+ List list = new ArrayList<>(arr);
+ ListIterator iterator = list.listIterator();
+ TypeElement klass = null;
+ while (iterator.hasNext()) {
+ TypeElement prev = iterator.hasPrevious() ? klass : null;
+ klass = iterator.next();
+ TypeElement next = iterator.nextIndex() == list.size()
+ ? null : list.get(iterator.nextIndex());
+ if (!(configuration.isGeneratedDoc(klass) && utils.isIncluded(klass))) {
+ continue;
+ }
+ try {
+ if (utils.isAnnotationType(klass)) {
+ AbstractBuilder annotationTypeBuilder =
+ configuration.getBuilderFactory()
+ .getAnnotationTypeBuilder(klass,
+ prev == null ? null : prev.asType(),
+ next == null ? null : next.asType());
+ annotationTypeBuilder.build();
+ } else {
+ AbstractBuilder classBuilder =
+ configuration.getBuilderFactory().getClassBuilder(klass,
+ prev, next, classtree);
+ classBuilder.build();
+ }
+ } catch (IOException e) {
+ throw new DocletAbortException(e);
+ } catch (DocletAbortException de) {
+ throw de;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new DocletAbortException(e);
+ }
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void generatePackageFiles(ClassTree classtree) throws Exception {
+ Set packages = configuration.packages;
+ if (packages.size() > 1) {
+ PackageIndexFrameWriter.generate(configuration);
+ }
+ List pList = new ArrayList<>(packages);
+ PackageElement prev = null;
+ for (int i = 0 ; i < pList.size() ; i++) {
+ // if -nodeprecated option is set and the package is marked as
+ // deprecated, do not generate the package-summary.html, package-frame.html
+ // and package-tree.html pages for that package.
+ PackageElement pkg = pList.get(i);
+ if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) {
+ PackageFrameWriter.generate(configuration, pkg);
+ int nexti = i + 1;
+ PackageElement next = null;
+ if (nexti < pList.size()) {
+ next = pList.get(nexti);
+ // If the next package is unnamed package, skip 2 ahead if possible
+ if (next.isUnnamed() && ++nexti < pList.size()) {
+ next = pList.get(nexti);
+ }
+ }
+ AbstractBuilder packageSummaryBuilder =
+ configuration.getBuilderFactory().getPackageSummaryBuilder(
+ pkg, prev, next);
+ packageSummaryBuilder.build();
+ if (configuration.createtree) {
+ PackageTreeWriter.generate(configuration, pkg, prev, next,
+ configuration.nodeprecated);
+ }
+ prev = pkg;
+ }
+ }
+ }
+
+ public Set getSupportedOptions() {
+ return configuration.getSupportedOptions();
+ }
+
+ private void performCopy(String filename) {
+ if (filename.isEmpty())
+ return;
+
+ try {
+ DocFile fromfile = DocFile.createFileForInput(configuration, filename);
+ DocPath path = DocPath.create(fromfile.getName());
+ DocFile toFile = DocFile.createFileForOutput(configuration, path);
+ if (toFile.isSameFile(fromfile))
+ return;
+
+ configuration.message.notice("doclet.Copying_File_0_To_File_1",
+ fromfile.toString(), path.getPath());
+ toFile.copyFile(fromfile);
+ } catch (IOException exc) {
+ configuration.message.error("doclet.perform_copy_exception_encountered",
+ exc.toString());
+ throw new DocletAbortException(exc);
+ }
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
new file mode 100644
index 00000000000..6658c4ca531
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
@@ -0,0 +1,2522 @@
+/*
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.AnnotationValue;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.Name;
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
+import javax.lang.model.type.DeclaredType;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.SimpleAnnotationValueVisitor9;
+import javax.lang.model.util.SimpleElementVisitor9;
+import javax.lang.model.util.SimpleTypeVisitor9;
+
+import com.sun.source.doctree.AttributeTree;
+import com.sun.source.doctree.AttributeTree.ValueKind;
+import com.sun.source.doctree.CommentTree;
+import com.sun.source.doctree.DocRootTree;
+import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.DocTree.Kind;
+import com.sun.source.doctree.EndElementTree;
+import com.sun.source.doctree.EntityTree;
+import com.sun.source.doctree.ErroneousTree;
+import com.sun.source.doctree.InheritDocTree;
+import com.sun.source.doctree.IndexTree;
+import com.sun.source.doctree.LinkTree;
+import com.sun.source.doctree.LiteralTree;
+import com.sun.source.doctree.SeeTree;
+import com.sun.source.doctree.StartElementTree;
+import com.sun.source.doctree.TextTree;
+import com.sun.source.util.SimpleDocTreeVisitor;
+import com.sun.tools.javac.util.DefinedBy;
+import com.sun.tools.javac.util.DefinedBy.Api;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.Comment;
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
+import jdk.javadoc.internal.doclets.formats.html.markup.DocType;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocWriter;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocument;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter;
+import jdk.javadoc.internal.doclets.toolkit.ClassWriter;
+import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.PackageSummaryWriter;
+import jdk.javadoc.internal.doclets.toolkit.taglets.DocRootTaglet;
+import jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter;
+import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
+import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
+import jdk.javadoc.internal.doclets.toolkit.util.ImplementedMethods;
+import jdk.javadoc.internal.doclets.toolkit.util.Utils;
+import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
+
+import static com.sun.source.doctree.AttributeTree.ValueKind.*;
+import static com.sun.source.doctree.DocTree.Kind.*;
+import static jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocWriter.CONTENT_TYPE;
+import static jdk.javadoc.internal.doclets.toolkit.util.CommentHelper.SPACER;
+
+
+/**
+ * Class for the Html Format Code Generation specific to JavaDoc.
+ * This Class contains methods related to the Html Code Generation which
+ * are used extensively while generating the entire documentation.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Atul M Dambalkar
+ * @author Robert Field
+ * @author Bhavesh Patel (Modified)
+ */
+public class HtmlDocletWriter extends HtmlDocWriter {
+
+ /**
+ * Relative path from the file getting generated to the destination
+ * directory. For example, if the file getting generated is
+ * "java/lang/Object.html", then the path to the root is "../..".
+ * This string can be empty if the file getting generated is in
+ * the destination directory.
+ */
+ public final DocPath pathToRoot;
+
+ /**
+ * Platform-independent path from the current or the
+ * destination directory to the file getting generated.
+ * Used when creating the file.
+ */
+ public final DocPath path;
+
+ /**
+ * Name of the file getting generated. If the file getting generated is
+ * "java/lang/Object.html", then the filename is "Object.html".
+ */
+ public final DocPath filename;
+
+ /**
+ * The global configuration information for this run.
+ */
+ public final ConfigurationImpl configuration;
+
+ protected final Utils utils;
+
+ /**
+ * To check whether annotation heading is printed or not.
+ */
+ protected boolean printedAnnotationHeading = false;
+
+ /**
+ * To check whether annotation field heading is printed or not.
+ */
+ protected boolean printedAnnotationFieldHeading = false;
+
+ /**
+ * To check whether the repeated annotations is documented or not.
+ */
+ private boolean isAnnotationDocumented = false;
+
+ /**
+ * To check whether the container annotations is documented or not.
+ */
+ private boolean isContainerDocumented = false;
+
+ HtmlTree fixedNavDiv = new HtmlTree(HtmlTag.DIV);
+
+ /**
+ * Constructor to construct the HtmlStandardWriter object.
+ *
+ * @param path File to be generated.
+ */
+ public HtmlDocletWriter(ConfigurationImpl configuration, DocPath path)
+ throws IOException {
+ super(configuration, path);
+ this.configuration = configuration;
+ this.utils = configuration.utils;
+ this.path = path;
+ this.pathToRoot = path.parent().invert();
+ this.filename = path.basename();
+ }
+
+ /**
+ * Replace {@docRoot} tag used in options that accept HTML text, such
+ * as -header, -footer, -top and -bottom, and when converting a relative
+ * HREF where commentTagsToString inserts a {@docRoot} where one was
+ * missing. (Also see DocRootTaglet for {@docRoot} tags in doc
+ * comments.)
+ *
+ * Replace {@docRoot} tag in htmlstr with the relative path to the
+ * destination directory from the directory where the file is being
+ * written, looping to handle all such tags in htmlstr.
+ *
+ * For example, for "-d docs" and -header containing {@docRoot}, when
+ * the HTML page for source file p/C1.java is being generated, the
+ * {@docRoot} tag would be inserted into the header as "../",
+ * the relative path from docs/p/ to docs/ (the document root).
+ *
+ * Note: This doc comment was written with '@' representing '@'
+ * to prevent the inline tag from being interpreted.
+ */
+ public String replaceDocRootDir(String htmlstr) {
+ // Return if no inline tags exist
+ int index = htmlstr.indexOf("{@");
+ if (index < 0) {
+ return htmlstr;
+ }
+ Matcher docrootMatcher = docrootPattern.matcher(htmlstr);
+ if (!docrootMatcher.find()) {
+ return htmlstr;
+ }
+ StringBuilder buf = new StringBuilder();
+ int prevEnd = 0;
+ do {
+ int match = docrootMatcher.start();
+ // append htmlstr up to start of next {@docroot}
+ buf.append(htmlstr.substring(prevEnd, match));
+ prevEnd = docrootMatcher.end();
+ if (configuration.docrootparent.length() > 0 && htmlstr.startsWith("/..", prevEnd)) {
+ // Insert the absolute link if {@docRoot} is followed by "/..".
+ buf.append(configuration.docrootparent);
+ prevEnd += 3;
+ } else {
+ // Insert relative path where {@docRoot} was located
+ buf.append(pathToRoot.isEmpty() ? "." : pathToRoot.getPath());
+ }
+ // Append slash if next character is not a slash
+ if (prevEnd < htmlstr.length() && htmlstr.charAt(prevEnd) != '/') {
+ buf.append('/');
+ }
+ } while (docrootMatcher.find());
+ buf.append(htmlstr.substring(prevEnd));
+ return buf.toString();
+ }
+ //where:
+ // Note: {@docRoot} is not case sensitive when passed in w/command line option:
+ private static final Pattern docrootPattern =
+ Pattern.compile(Pattern.quote("{@docroot}"), Pattern.CASE_INSENSITIVE);
+
+ /**
+ * Get the script to show or hide the All classes link.
+ *
+ * @param id id of the element to show or hide
+ * @return a content tree for the script
+ */
+ public Content getAllClassesLinkScript(String id) {
+ HtmlTree script = HtmlTree.SCRIPT();
+ String scriptCode = "" + DocletConstants.NL;
+ Content scriptContent = new RawHtml(scriptCode);
+ script.addContent(scriptContent);
+ Content div = HtmlTree.DIV(script);
+ Content div_noscript = HtmlTree.DIV(getResource("doclet.No_Script_Message"));
+ Content noScript = HtmlTree.NOSCRIPT(div_noscript);
+ div.addContent(noScript);
+ return div;
+ }
+
+ /**
+ * Add method information.
+ *
+ * @param method the method to be documented
+ * @param dl the content tree to which the method information will be added
+ */
+ private void addMethodInfo(ExecutableElement method, Content dl) {
+ TypeElement enclosing = utils.getEnclosingTypeElement(method);
+ List extends TypeMirror> intfacs = enclosing.getInterfaces();
+ ExecutableElement overriddenMethod = utils.overriddenMethod(method);
+ // Check whether there is any implementation or overridden info to be
+ // printed. If no overridden or implementation info needs to be
+ // printed, do not print this section.
+ if ((!intfacs.isEmpty()
+ && new ImplementedMethods(method, this.configuration).build().isEmpty() == false)
+ || overriddenMethod != null) {
+ MethodWriterImpl.addImplementsInfo(this, method, dl);
+ if (overriddenMethod != null) {
+ MethodWriterImpl.addOverridden(this,
+ utils.overriddenType(method),
+ overriddenMethod,
+ dl);
+ }
+ }
+ }
+
+ /**
+ * Adds the tags information.
+ *
+ * @param e the Element for which the tags will be generated
+ * @param htmltree the documentation tree to which the tags will be added
+ */
+ protected void addTagsInfo(Element e, Content htmltree) {
+ if (configuration.nocomment) {
+ return;
+ }
+ Content dl = new HtmlTree(HtmlTag.DL);
+ if (utils.isExecutableElement(e) && !utils.isConstructor(e)) {
+ addMethodInfo((ExecutableElement)e, dl);
+ }
+ Content output = new ContentBuilder();
+ TagletWriter.genTagOutput(configuration.tagletManager, e,
+ configuration.tagletManager.getCustomTaglets(e),
+ getTagletWriterInstance(false), output);
+ dl.addContent(output);
+ htmltree.addContent(dl);
+ }
+
+ /**
+ * Check whether there are any tags for Serialization Overview
+ * section to be printed.
+ *
+ * @param field the VariableElement object to check for tags.
+ * @return true if there are tags to be printed else return false.
+ */
+ protected boolean hasSerializationOverviewTags(VariableElement field) {
+ Content output = new ContentBuilder();
+ TagletWriter.genTagOutput(configuration.tagletManager, field,
+ configuration.tagletManager.getCustomTaglets(field),
+ getTagletWriterInstance(false), output);
+ return !output.isEmpty();
+ }
+
+ /**
+ * Returns a TagletWriter that knows how to write HTML.
+ *
+ * @return a TagletWriter that knows how to write HTML.
+ */
+ public TagletWriter getTagletWriterInstance(boolean isFirstSentence) {
+ return new TagletWriterImpl(this, isFirstSentence);
+ }
+
+ /**
+ * Get Package link, with target frame.
+ *
+ * @param pkg The link will be to the "package-summary.html" page for this package
+ * @param target name of the target frame
+ * @param label tag for the link
+ * @return a content for the target package link
+ */
+ public Content getTargetPackageLink(PackageElement pkg, String target,
+ Content label) {
+ return getHyperLink(pathString(pkg, DocPaths.PACKAGE_SUMMARY), label, "", target);
+ }
+
+
+ public void addClassesSummary(SortedSet classes, String label,
+ String tableSummary, List tableHeader, Content summaryContentTree) {
+ if (!classes.isEmpty()) {
+ Content caption = getTableCaption(new RawHtml(label));
+ Content table = (configuration.isOutputHtml5())
+ ? HtmlTree.TABLE(HtmlStyle.typeSummary, caption)
+ : HtmlTree.TABLE(HtmlStyle.typeSummary, tableSummary, caption);
+ table.addContent(getSummaryTableHeader(tableHeader, "col"));
+ Content tbody = new HtmlTree(HtmlTag.TBODY);
+ boolean altColor = true;
+ for (TypeElement te : classes) {
+ if (!utils.isCoreClass(te) ||
+ !configuration.isGeneratedDoc(te)) {
+ continue;
+ }
+ Content classContent = getLink(new LinkInfoImpl(
+ configuration, LinkInfoImpl.Kind.PACKAGE, te));
+ Content tdClass = HtmlTree.TD(HtmlStyle.colFirst, classContent);
+ HtmlTree tr = HtmlTree.TR(tdClass);
+ tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
+ altColor = !altColor;
+ HtmlTree tdClassDescription = new HtmlTree(HtmlTag.TD);
+ tdClassDescription.addStyle(HtmlStyle.colLast);
+ if (utils.isDeprecated(te)) {
+ tdClassDescription.addContent(deprecatedLabel);
+ List extends DocTree> tags = utils.getDeprecatedTrees(te);
+ if (!tags.isEmpty()) {
+ addSummaryDeprecatedComment(te, tags.get(0), tdClassDescription);
+ }
+ } else {
+ addSummaryComment(te, tdClassDescription);
+ }
+ tr.addContent(tdClassDescription);
+ tbody.addContent(tr);
+ }
+ table.addContent(tbody);
+ summaryContentTree.addContent(table);
+ }
+ }
+
+ /**
+ * Generates the HTML document tree and prints it out.
+ *
+ * @param metakeywords Array of String keywords for META tag. Each element
+ * of the array is assigned to a separate META tag.
+ * Pass in null for no array
+ * @param includeScript true if printing windowtitle script
+ * false for files that appear in the left-hand frames
+ * @param body the body htmltree to be included in the document
+ */
+ public void printHtmlDocument(List metakeywords, boolean includeScript,
+ Content body) throws IOException {
+ Content htmlDocType = configuration.isOutputHtml5()
+ ? DocType.HTML5
+ : DocType.TRANSITIONAL;
+ Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
+ Content head = new HtmlTree(HtmlTag.HEAD);
+ head.addContent(getGeneratedBy(!configuration.notimestamp));
+ head.addContent(getTitle());
+ Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE,
+ (configuration.charset.length() > 0) ?
+ configuration.charset : HtmlConstants.HTML_DEFAULT_CHARSET);
+ head.addContent(meta);
+ if (!configuration.notimestamp) {
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ meta = HtmlTree.META(configuration.isOutputHtml5()
+ ? "dc.created"
+ : "date", dateFormat.format(new Date()));
+ head.addContent(meta);
+ }
+ if (metakeywords != null) {
+ for (String metakeyword : metakeywords) {
+ meta = HtmlTree.META("keywords", metakeyword);
+ head.addContent(meta);
+ }
+ }
+ addStyleSheetProperties(head);
+ addScriptProperties(head);
+ Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
+ head, body);
+ Content htmlDocument = new HtmlDocument(htmlDocType,
+ htmlComment, htmlTree);
+ write(htmlDocument);
+ }
+
+ /**
+ * Get the window title.
+ *
+ * @param title the title string to construct the complete window title
+ * @return the window title string
+ */
+ public String getWindowTitle(String title) {
+ if (configuration.windowtitle.length() > 0) {
+ title += " (" + configuration.windowtitle + ")";
+ }
+ return title;
+ }
+
+ /**
+ * Get user specified header and the footer.
+ *
+ * @param header if true print the user provided header else print the
+ * user provided footer.
+ */
+ public Content getUserHeaderFooter(boolean header) {
+ String content;
+ if (header) {
+ content = replaceDocRootDir(configuration.header);
+ } else {
+ if (configuration.footer.length() != 0) {
+ content = replaceDocRootDir(configuration.footer);
+ } else {
+ content = replaceDocRootDir(configuration.header);
+ }
+ }
+ Content rawContent = new RawHtml(content);
+ return rawContent;
+ }
+
+ /**
+ * Adds the user specified top.
+ *
+ * @param htmlTree the content tree to which user specified top will be added
+ */
+ public void addTop(Content htmlTree) {
+ Content top = new RawHtml(replaceDocRootDir(configuration.top));
+ fixedNavDiv.addContent(top);
+ }
+
+ /**
+ * Adds the user specified bottom.
+ *
+ * @param htmlTree the content tree to which user specified bottom will be added
+ */
+ public void addBottom(Content htmlTree) {
+ Content bottom = new RawHtml(replaceDocRootDir(configuration.bottom));
+ Content small = HtmlTree.SMALL(bottom);
+ Content p = HtmlTree.P(HtmlStyle.legalCopy, small);
+ htmlTree.addContent(p);
+ }
+
+ /**
+ * Adds the navigation bar for the Html page at the top and and the bottom.
+ *
+ * @param header If true print navigation bar at the top of the page else
+ * @param htmlTree the HtmlTree to which the nav links will be added
+ */
+ protected void addNavLinks(boolean header, Content htmlTree) {
+ if (!configuration.nonavbar) {
+ Content tree = (configuration.allowTag(HtmlTag.NAV))
+ ? HtmlTree.NAV()
+ : htmlTree;
+ String allClassesId = "allclasses_";
+ HtmlTree navDiv = new HtmlTree(HtmlTag.DIV);
+ fixedNavDiv.addStyle(HtmlStyle.fixedNav);
+ Content skipNavLinks = configuration.getResource("doclet.Skip_navigation_links");
+ if (header) {
+ fixedNavDiv.addContent(HtmlConstants.START_OF_TOP_NAVBAR);
+ navDiv.addStyle(HtmlStyle.topNav);
+ allClassesId += "navbar_top";
+ Content a = getMarkerAnchor(SectionName.NAVBAR_TOP);
+ //WCAG - Hyperlinks should contain text or an image with alt text - for AT tools
+ navDiv.addContent(a);
+ Content skipLinkContent = HtmlTree.DIV(HtmlStyle.skipNav, getHyperLink(
+ getDocLink(SectionName.SKIP_NAVBAR_TOP), skipNavLinks,
+ skipNavLinks.toString(), ""));
+ navDiv.addContent(skipLinkContent);
+ } else {
+ tree.addContent(HtmlConstants.START_OF_BOTTOM_NAVBAR);
+ navDiv.addStyle(HtmlStyle.bottomNav);
+ allClassesId += "navbar_bottom";
+ Content a = getMarkerAnchor(SectionName.NAVBAR_BOTTOM);
+ navDiv.addContent(a);
+ Content skipLinkContent = HtmlTree.DIV(HtmlStyle.skipNav, getHyperLink(
+ getDocLink(SectionName.SKIP_NAVBAR_BOTTOM), skipNavLinks,
+ skipNavLinks.toString(), ""));
+ navDiv.addContent(skipLinkContent);
+ }
+ if (header) {
+ navDiv.addContent(getMarkerAnchor(SectionName.NAVBAR_TOP_FIRSTROW));
+ } else {
+ navDiv.addContent(getMarkerAnchor(SectionName.NAVBAR_BOTTOM_FIRSTROW));
+ }
+ HtmlTree navList = new HtmlTree(HtmlTag.UL);
+ navList.addStyle(HtmlStyle.navList);
+ navList.addAttr(HtmlAttr.TITLE,
+ configuration.getText("doclet.Navigation"));
+ if (configuration.createoverview) {
+ navList.addContent(getNavLinkContents());
+ }
+ if (configuration.packages.size() == 1) {
+ navList.addContent(getNavLinkPackage(configuration.packages.first()));
+ } else if (!configuration.packages.isEmpty()) {
+ navList.addContent(getNavLinkPackage());
+ }
+ navList.addContent(getNavLinkClass());
+ if(configuration.classuse) {
+ navList.addContent(getNavLinkClassUse());
+ }
+ if(configuration.createtree) {
+ navList.addContent(getNavLinkTree());
+ }
+ if(!(configuration.nodeprecated ||
+ configuration.nodeprecatedlist)) {
+ navList.addContent(getNavLinkDeprecated());
+ }
+ if(configuration.createindex) {
+ navList.addContent(getNavLinkIndex());
+ }
+ if (!configuration.nohelp) {
+ navList.addContent(getNavLinkHelp());
+ }
+ navDiv.addContent(navList);
+ Content aboutDiv = HtmlTree.DIV(HtmlStyle.aboutLanguage, getUserHeaderFooter(header));
+ navDiv.addContent(aboutDiv);
+ if (header) {
+ fixedNavDiv.addContent(navDiv);
+ } else {
+ tree.addContent(navDiv);
+ }
+ Content ulNav = HtmlTree.UL(HtmlStyle.navList, getNavLinkPrevious());
+ ulNav.addContent(getNavLinkNext());
+ Content subDiv = HtmlTree.DIV(HtmlStyle.subNav, ulNav);
+ Content ulFrames = HtmlTree.UL(HtmlStyle.navList, getNavShowLists());
+ ulFrames.addContent(getNavHideLists(filename));
+ subDiv.addContent(ulFrames);
+ HtmlTree ulAllClasses = HtmlTree.UL(HtmlStyle.navList, getNavLinkClassIndex());
+ ulAllClasses.addAttr(HtmlAttr.ID, allClassesId);
+ subDiv.addContent(ulAllClasses);
+ if (header && configuration.createindex) {
+ HtmlTree inputText = HtmlTree.INPUT("text", "search");
+ HtmlTree inputReset = HtmlTree.INPUT("reset", "reset");
+ Content searchTxt = configuration.getResource("doclet.search");
+ searchTxt.addContent(getSpace());
+ HtmlTree liInput = HtmlTree.LI(HtmlTree.SPAN(searchTxt));
+ liInput.addContent(inputText);
+ liInput.addContent(inputReset);
+ HtmlTree ulSearch = HtmlTree.UL(HtmlStyle.navListSearch, liInput);
+ subDiv.addContent(ulSearch);
+ }
+ subDiv.addContent(getAllClassesLinkScript(allClassesId));
+ addSummaryDetailLinks(subDiv);
+ if (header) {
+ subDiv.addContent(getMarkerAnchor(SectionName.SKIP_NAVBAR_TOP));
+ fixedNavDiv.addContent(subDiv);
+ fixedNavDiv.addContent(HtmlConstants.END_OF_TOP_NAVBAR);
+ tree.addContent(fixedNavDiv);
+ } else {
+ subDiv.addContent(getMarkerAnchor(SectionName.SKIP_NAVBAR_BOTTOM));
+ tree.addContent(subDiv);
+ tree.addContent(HtmlConstants.END_OF_BOTTOM_NAVBAR);
+ }
+ if (configuration.allowTag(HtmlTag.NAV)) {
+ htmlTree.addContent(tree);
+ }
+ }
+ }
+
+ /**
+ * Get the word "NEXT" to indicate that no link is available. Override
+ * this method to customize next link.
+ *
+ * @return a content tree for the link
+ */
+ protected Content getNavLinkNext() {
+ return getNavLinkNext(null);
+ }
+
+ /**
+ * Get the word "PREV" to indicate that no link is available. Override
+ * this method to customize prev link.
+ *
+ * @return a content tree for the link
+ */
+ protected Content getNavLinkPrevious() {
+ return getNavLinkPrevious(null);
+ }
+
+ /**
+ * Do nothing. This is the default method.
+ */
+ protected void addSummaryDetailLinks(Content navDiv) {
+ }
+
+ /**
+ * Get link to the "overview-summary.html" page.
+ *
+ * @return a content tree for the link
+ */
+ protected Content getNavLinkContents() {
+ Content linkContent = getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_SUMMARY),
+ overviewLabel, "", "");
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+
+ /**
+ * Get link to the "package-summary.html" page for the package passed.
+ *
+ * @param pkg Package to which link will be generated
+ * @return a content tree for the link
+ */
+ protected Content getNavLinkPackage(PackageElement pkg) {
+ Content linkContent = getPackageLink(pkg, packageLabel);
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+
+ /**
+ * Get the word "Package" , to indicate that link is not available here.
+ *
+ * @return a content tree for the link
+ */
+ protected Content getNavLinkPackage() {
+ Content li = HtmlTree.LI(packageLabel);
+ return li;
+ }
+
+ /**
+ * Get the word "Use", to indicate that link is not available.
+ *
+ * @return a content tree for the link
+ */
+ protected Content getNavLinkClassUse() {
+ Content li = HtmlTree.LI(useLabel);
+ return li;
+ }
+
+ /**
+ * Get link for previous file.
+ *
+ * @param prev File name for the prev link
+ * @return a content tree for the link
+ */
+ public Content getNavLinkPrevious(DocPath prev) {
+ Content li;
+ if (prev != null) {
+ li = HtmlTree.LI(getHyperLink(prev, prevLabel, "", ""));
+ }
+ else
+ li = HtmlTree.LI(prevLabel);
+ return li;
+ }
+
+ /**
+ * Get link for next file. If next is null, just print the label
+ * without linking it anywhere.
+ *
+ * @param next File name for the next link
+ * @return a content tree for the link
+ */
+ public Content getNavLinkNext(DocPath next) {
+ Content li;
+ if (next != null) {
+ li = HtmlTree.LI(getHyperLink(next, nextLabel, "", ""));
+ }
+ else
+ li = HtmlTree.LI(nextLabel);
+ return li;
+ }
+
+ /**
+ * Get "FRAMES" link, to switch to the frame version of the output.
+ *
+ * @param link File to be linked, "index.html"
+ * @return a content tree for the link
+ */
+ protected Content getNavShowLists(DocPath link) {
+ DocLink dl = new DocLink(link, path.getPath(), null);
+ Content framesContent = getHyperLink(dl, framesLabel, "", "_top");
+ Content li = HtmlTree.LI(framesContent);
+ return li;
+ }
+
+ /**
+ * Get "FRAMES" link, to switch to the frame version of the output.
+ *
+ * @return a content tree for the link
+ */
+ protected Content getNavShowLists() {
+ return getNavShowLists(pathToRoot.resolve(DocPaths.INDEX));
+ }
+
+ /**
+ * Get "NO FRAMES" link, to switch to the non-frame version of the output.
+ *
+ * @param link File to be linked
+ * @return a content tree for the link
+ */
+ protected Content getNavHideLists(DocPath link) {
+ Content noFramesContent = getHyperLink(link, noframesLabel, "", "_top");
+ Content li = HtmlTree.LI(noFramesContent);
+ return li;
+ }
+
+ /**
+ * Get "Tree" link in the navigation bar. If there is only one package
+ * specified on the command line, then the "Tree" link will be to the
+ * only "package-tree.html" file otherwise it will be to the
+ * "overview-tree.html" file.
+ *
+ * @return a content tree for the link
+ */
+ protected Content getNavLinkTree() {
+ List packages = new ArrayList<>(utils.getSpecifiedPackages());
+ DocPath docPath = packages.size() == 1 && utils.getSpecifiedClasses().isEmpty()
+ ? pathString(packages.get(0), DocPaths.PACKAGE_TREE)
+ : pathToRoot.resolve(DocPaths.OVERVIEW_TREE);
+ return HtmlTree.LI(getHyperLink(docPath, treeLabel, "", ""));
+ }
+
+ /**
+ * Get the overview tree link for the main tree.
+ *
+ * @param label the label for the link
+ * @return a content tree for the link
+ */
+ protected Content getNavLinkMainTree(String label) {
+ Content mainTreeContent = getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE),
+ new StringContent(label));
+ Content li = HtmlTree.LI(mainTreeContent);
+ return li;
+ }
+
+ /**
+ * Get the word "Class", to indicate that class link is not available.
+ *
+ * @return a content tree for the link
+ */
+ protected Content getNavLinkClass() {
+ Content li = HtmlTree.LI(classLabel);
+ return li;
+ }
+
+ /**
+ * Get "Deprecated" API link in the navigation bar.
+ *
+ * @return a content tree for the link
+ */
+ protected Content getNavLinkDeprecated() {
+ Content linkContent = getHyperLink(pathToRoot.resolve(DocPaths.DEPRECATED_LIST),
+ deprecatedLabel, "", "");
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+
+ /**
+ * Get link for generated index. If the user has used "-splitindex"
+ * command line option, then link to file "index-files/index-1.html" is
+ * generated otherwise link to file "index-all.html" is generated.
+ *
+ * @return a content tree for the link
+ */
+ protected Content getNavLinkClassIndex() {
+ Content allClassesContent = getHyperLink(pathToRoot.resolve(
+ DocPaths.ALLCLASSES_NOFRAME),
+ allclassesLabel, "", "");
+ Content li = HtmlTree.LI(allClassesContent);
+ return li;
+ }
+
+ /**
+ * Get link for generated class index.
+ *
+ * @return a content tree for the link
+ */
+ protected Content getNavLinkIndex() {
+ Content linkContent = getHyperLink(pathToRoot.resolve(
+ (configuration.splitindex
+ ? DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1))
+ : DocPaths.INDEX_ALL)),
+ indexLabel, "", "");
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+
+ /**
+ * Get help file link. If user has provided a help file, then generate a
+ * link to the user given file, which is already copied to current or
+ * destination directory.
+ *
+ * @return a content tree for the link
+ */
+ protected Content getNavLinkHelp() {
+ String helpfile = configuration.helpfile;
+ DocPath helpfilenm;
+ if (helpfile.isEmpty()) {
+ helpfilenm = DocPaths.HELP_DOC;
+ } else {
+ DocFile file = DocFile.createFileForInput(configuration, helpfile);
+ helpfilenm = DocPath.create(file.getName());
+ }
+ Content linkContent = getHyperLink(pathToRoot.resolve(helpfilenm),
+ helpLabel, "", "");
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+
+ /**
+ * Get summary table header.
+ *
+ * @param header the header for the table
+ * @param scope the scope of the headers
+ * @return a content tree for the header
+ */
+ public Content getSummaryTableHeader(List header, String scope) {
+ Content tr = new HtmlTree(HtmlTag.TR);
+ final int size = header.size();
+ Content tableHeader;
+ if (size == 1) {
+ tableHeader = new StringContent(header.get(0));
+ tr.addContent(HtmlTree.TH(HtmlStyle.colOne, scope, tableHeader));
+ return tr;
+ }
+ for (int i = 0; i < size; i++) {
+ tableHeader = new StringContent(header.get(i));
+ if(i == 0)
+ tr.addContent(HtmlTree.TH(HtmlStyle.colFirst, scope, tableHeader));
+ else if(i == (size - 1))
+ tr.addContent(HtmlTree.TH(HtmlStyle.colLast, scope, tableHeader));
+ else
+ tr.addContent(HtmlTree.TH(scope, tableHeader));
+ }
+ return tr;
+ }
+
+ /**
+ * Get table caption.
+ *
+ * @param rawText the caption for the table which could be raw Html
+ * @return a content tree for the caption
+ */
+ public Content getTableCaption(Content title) {
+ Content captionSpan = HtmlTree.SPAN(title);
+ Content space = getSpace();
+ Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, space);
+ Content caption = HtmlTree.CAPTION(captionSpan);
+ caption.addContent(tabSpan);
+ return caption;
+ }
+
+ /**
+ * Get the marker anchor which will be added to the documentation tree.
+ *
+ * @param anchorName the anchor name attribute
+ * @return a content tree for the marker anchor
+ */
+ public Content getMarkerAnchor(String anchorName) {
+ return getMarkerAnchor(getName(anchorName), null);
+ }
+
+ /**
+ * Get the marker anchor which will be added to the documentation tree.
+ *
+ * @param sectionName the section name anchor attribute for page
+ * @return a content tree for the marker anchor
+ */
+ public Content getMarkerAnchor(SectionName sectionName) {
+ return getMarkerAnchor(sectionName.getName(), null);
+ }
+
+ /**
+ * Get the marker anchor which will be added to the documentation tree.
+ *
+ * @param sectionName the section name anchor attribute for page
+ * @param anchorName the anchor name combined with section name attribute for the page
+ * @return a content tree for the marker anchor
+ */
+ public Content getMarkerAnchor(SectionName sectionName, String anchorName) {
+ return getMarkerAnchor(sectionName.getName() + getName(anchorName), null);
+ }
+
+ /**
+ * Get the marker anchor which will be added to the documentation tree.
+ *
+ * @param anchorName the anchor name or id attribute
+ * @param anchorContent the content that should be added to the anchor
+ * @return a content tree for the marker anchor
+ */
+ public Content getMarkerAnchor(String anchorName, Content anchorContent) {
+ if (anchorContent == null)
+ anchorContent = new Comment(" ");
+ Content markerAnchor = HtmlTree.A(configuration.htmlVersion, anchorName, anchorContent);
+ return markerAnchor;
+ }
+
+ /**
+ * Returns a packagename content.
+ *
+ * @param packageElement the package to check
+ * @return package name content
+ */
+ public Content getPackageName(PackageElement packageElement) {
+ return packageElement == null || packageElement.isUnnamed()
+ ? defaultPackageLabel
+ : getPackageLabel(packageElement.getQualifiedName().toString());
+ }
+
+ /**
+ * Returns a package name label.
+ *
+ * @param packageName the package name
+ * @return the package name content
+ */
+ public Content getPackageLabel(String packageName) {
+ return new StringContent(packageName);
+ }
+
+ /**
+ * Add package deprecation information to the documentation tree
+ *
+ * @param deprPkgs list of deprecated packages
+ * @param headingKey the caption for the deprecated package table
+ * @param tableSummary the summary for the deprecated package table
+ * @param tableHeader table headers for the deprecated package table
+ * @param contentTree the content tree to which the deprecated package table will be added
+ */
+ protected void addPackageDeprecatedAPI(SortedSet deprPkgs, String headingKey,
+ String tableSummary, List tableHeader, Content contentTree) {
+ if (deprPkgs.size() > 0) {
+ Content caption = getTableCaption(configuration.getResource(headingKey));
+ Content table = (configuration.isOutputHtml5())
+ ? HtmlTree.TABLE(HtmlStyle.deprecatedSummary, caption)
+ : HtmlTree.TABLE(HtmlStyle.deprecatedSummary, tableSummary, caption);
+ table.addContent(getSummaryTableHeader(tableHeader, "col"));
+ Content tbody = new HtmlTree(HtmlTag.TBODY);
+ boolean altColor = true;
+ for (Element e : deprPkgs) {
+ PackageElement pkg = (PackageElement) e;
+ HtmlTree td = HtmlTree.TD(HtmlStyle.colOne,
+ getPackageLink(pkg, getPackageName(pkg)));
+ List extends DocTree> tags = utils.getDeprecatedTrees(pkg);
+ if (!tags.isEmpty()) {
+ addInlineDeprecatedComment(pkg, tags.get(0), td);
+ }
+ HtmlTree tr = HtmlTree.TR(td);
+ tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
+ altColor = !altColor;
+ tbody.addContent(tr);
+ }
+ table.addContent(tbody);
+ Content li = HtmlTree.LI(HtmlStyle.blockList, table);
+ Content ul = HtmlTree.UL(HtmlStyle.blockList, li);
+ contentTree.addContent(ul);
+ }
+ }
+
+ /**
+ * Return the path to the class page for a typeElement.
+ *
+ * @param te TypeElement for which the path is requested.
+ * @param name Name of the file(doesn't include path).
+ */
+ protected DocPath pathString(TypeElement te, DocPath name) {
+ return pathString(utils.containingPackage(te), name);
+ }
+
+ /**
+ * Return path to the given file name in the given package. So if the name
+ * passed is "Object.html" and the name of the package is "java.lang", and
+ * if the relative path is "../.." then returned string will be
+ * "../../java/lang/Object.html"
+ *
+ * @param packageElement Package in which the file name is assumed to be.
+ * @param name File name, to which path string is.
+ */
+ protected DocPath pathString(PackageElement packageElement, DocPath name) {
+ return pathToRoot.resolve(DocPath.forPackage(packageElement).resolve(name));
+ }
+
+ /**
+ * Given a package, return the name to be used in HTML anchor tag.
+ * @param packageElement the package.
+ * @return the name to be used in HTML anchor tag.
+ */
+ public String getPackageAnchorName(PackageElement packageElement) {
+ return packageElement == null || packageElement.isUnnamed()
+ ? SectionName.UNNAMED_PACKAGE_ANCHOR.getName()
+ : utils.getPackageName(packageElement);
+ }
+
+ /**
+ * Return the link to the given package.
+ *
+ * @param packageElement the package to link to.
+ * @param label the label for the link.
+ * @return a content tree for the package link.
+ */
+ public Content getPackageLink(PackageElement packageElement, String label) {
+ return getPackageLink(packageElement, new StringContent(label));
+ }
+
+ public Content getPackageLink(PackageElement packageElement) {
+ StringContent content = packageElement.isUnnamed()
+ ? new StringContent()
+ : new StringContent(utils.getPackageName(packageElement));
+ return getPackageLink(packageElement, content);
+ }
+
+ /**
+ * Return the link to the given package.
+ *
+ * @param packageElement the package to link to.
+ * @param label the label for the link.
+ * @return a content tree for the package link.
+ */
+ public Content getPackageLink(PackageElement packageElement, Content label) {
+ boolean included = packageElement != null && utils.isIncluded(packageElement);
+ if (!included) {
+ for (PackageElement p : configuration.packages) {
+ if (p.equals(packageElement)) {
+ included = true;
+ break;
+ }
+ }
+ }
+ if (included || packageElement == null) {
+ return getHyperLink(pathString(packageElement, DocPaths.PACKAGE_SUMMARY),
+ label);
+ } else {
+ DocLink crossPkgLink = getCrossPackageLink(utils.getPackageName(packageElement));
+ if (crossPkgLink != null) {
+ return getHyperLink(crossPkgLink, label);
+ } else {
+ return label;
+ }
+ }
+ }
+
+ public Content interfaceName(TypeElement typeElement, boolean qual) {
+ Content name = new StringContent((qual)
+ ? typeElement.getQualifiedName().toString()
+ : utils.getSimpleName(typeElement));
+ return (utils.isInterface(typeElement)) ? HtmlTree.SPAN(HtmlStyle.interfaceName, name) : name;
+ }
+
+ /**
+ * Add the link to the content tree.
+ *
+ * @param typeElement program element typeElement for which the link will be added
+ * @param label label for the link
+ * @param htmltree the content tree to which the link will be added
+ */
+ public void addSrcLink(Element typeElement, Content label, Content htmltree) {
+ if (typeElement == null) {
+ return;
+ }
+ TypeElement te = utils.getEnclosingTypeElement(typeElement);
+ if (te == null) {
+ // must be a typeElement since in has no containing class.
+ te = (TypeElement) typeElement;
+ }
+ DocPath href = pathToRoot
+ .resolve(DocPaths.SOURCE_OUTPUT)
+ .resolve(DocPath.forClass(utils, te));
+ Content linkContent = getHyperLink(href
+ .fragment(SourceToHTMLConverter.getAnchorName(utils, typeElement)), label, "", "");
+ htmltree.addContent(linkContent);
+ }
+
+ /**
+ * Return the link to the given class.
+ *
+ * @param linkInfo the information about the link.
+ *
+ * @return the link for the given class.
+ */
+ public Content getLink(LinkInfoImpl linkInfo) {
+ LinkFactoryImpl factory = new LinkFactoryImpl(this);
+ return factory.getLink(linkInfo);
+ }
+
+ /**
+ * Return the type parameters for the given class.
+ *
+ * @param linkInfo the information about the link.
+ * @return the type for the given class.
+ */
+ public Content getTypeParameterLinks(LinkInfoImpl linkInfo) {
+ LinkFactoryImpl factory = new LinkFactoryImpl(this);
+ return factory.getTypeParameterLinks(linkInfo, false);
+ }
+
+ /*************************************************************
+ * Return a class cross link to external class documentation.
+ * The name must be fully qualified to determine which package
+ * the class is in. The -link option does not allow users to
+ * link to external classes in the "default" package.
+ *
+ * @param qualifiedClassName the qualified name of the external class.
+ * @param refMemName the name of the member being referenced. This should
+ * be null or empty string if no member is being referenced.
+ * @param label the label for the external link.
+ * @param strong true if the link should be strong.
+ * @param style the style of the link.
+ * @param code true if the label should be code font.
+ */
+ public Content getCrossClassLink(String qualifiedClassName, String refMemName,
+ Content label, boolean strong, String style,
+ boolean code) {
+ String className = "";
+ String packageName = qualifiedClassName == null ? "" : qualifiedClassName;
+ int periodIndex;
+ while ((periodIndex = packageName.lastIndexOf('.')) != -1) {
+ className = packageName.substring(periodIndex + 1, packageName.length()) +
+ (className.length() > 0 ? "." + className : "");
+ Content defaultLabel = new StringContent(className);
+ if (code)
+ defaultLabel = HtmlTree.CODE(defaultLabel);
+ packageName = packageName.substring(0, periodIndex);
+ if (getCrossPackageLink(packageName) != null) {
+ /*
+ The package exists in external documentation, so link to the external
+ class (assuming that it exists). This is definitely a limitation of
+ the -link option. There are ways to determine if an external package
+ exists, but no way to determine if the external class exists. We just
+ have to assume that it does.
+ */
+ DocLink link = configuration.extern.getExternalLink(packageName, pathToRoot,
+ className + ".html", refMemName);
+ return getHyperLink(link,
+ (label == null) || label.isEmpty() ? defaultLabel : label,
+ strong, style,
+ configuration.getText("doclet.Href_Class_Or_Interface_Title", packageName),
+ "");
+ }
+ }
+ return null;
+ }
+
+ public boolean isClassLinkable(TypeElement typeElement) {
+ if (utils.isIncluded(typeElement)) {
+ return configuration.isGeneratedDoc(typeElement);
+ }
+ return configuration.extern.isExternal(typeElement);
+ }
+
+ public DocLink getCrossPackageLink(String pkgName) {
+ return configuration.extern.getExternalLink(pkgName, pathToRoot,
+ DocPaths.PACKAGE_SUMMARY.getPath());
+ }
+
+ /**
+ * Get the class link.
+ *
+ * @param context the id of the context where the link will be added
+ * @param element to link to
+ * @return a content tree for the link
+ */
+ public Content getQualifiedClassLink(LinkInfoImpl.Kind context, Element element) {
+ LinkInfoImpl linkInfoImpl = new LinkInfoImpl(configuration, context, (TypeElement)element);
+ return getLink(linkInfoImpl.label(utils.getFullyQualifiedName(element)));
+ }
+
+ /**
+ * Add the class link.
+ *
+ * @param context the id of the context where the link will be added
+ * @param typeElement to link to
+ * @param contentTree the content tree to which the link will be added
+ */
+ public void addPreQualifiedClassLink(LinkInfoImpl.Kind context, TypeElement typeElement, Content contentTree) {
+ addPreQualifiedClassLink(context, typeElement, false, contentTree);
+ }
+
+ /**
+ * Retrieve the class link with the package portion of the label in
+ * plain text. If the qualifier is excluded, it will not be included in the
+ * link label.
+ *
+ * @param typeElement the class to link to.
+ * @param isStrong true if the link should be strong.
+ * @return the link with the package portion of the label in plain text.
+ */
+ public Content getPreQualifiedClassLink(LinkInfoImpl.Kind context,
+ TypeElement typeElement, boolean isStrong) {
+ ContentBuilder classlink = new ContentBuilder();
+ PackageElement pkg = utils.containingPackage(typeElement);
+ if (pkg != null && ! configuration.shouldExcludeQualifier(pkg.getSimpleName().toString())) {
+ classlink.addContent(getEnclosingPackageName(typeElement));
+ }
+ classlink.addContent(getLink(new LinkInfoImpl(configuration,
+ context, typeElement).label(utils.getSimpleName(typeElement)).strong(isStrong)));
+ return classlink;
+ }
+
+ /**
+ * Add the class link with the package portion of the label in
+ * plain text. If the qualifier is excluded, it will not be included in the
+ * link label.
+ *
+ * @param context the id of the context where the link will be added
+ * @param typeElement the class to link to
+ * @param isStrong true if the link should be strong
+ * @param contentTree the content tree to which the link with be added
+ */
+ public void addPreQualifiedClassLink(LinkInfoImpl.Kind context,
+ TypeElement typeElement, boolean isStrong, Content contentTree) {
+ PackageElement pkg = utils.containingPackage(typeElement);
+ if(pkg != null && ! configuration.shouldExcludeQualifier(pkg.getSimpleName().toString())) {
+ contentTree.addContent(getEnclosingPackageName(typeElement));
+ }
+ LinkInfoImpl linkinfo = new LinkInfoImpl(configuration, context, typeElement)
+ .label(utils.getSimpleName(typeElement))
+ .strong(isStrong);
+ Content link = getLink(linkinfo);
+ contentTree.addContent(link);
+ }
+
+ /**
+ * Add the class link, with only class name as the strong link and prefixing
+ * plain package name.
+ *
+ * @param context the id of the context where the link will be added
+ * @param typeElement the class to link to
+ * @param contentTree the content tree to which the link with be added
+ */
+ public void addPreQualifiedStrongClassLink(LinkInfoImpl.Kind context, TypeElement typeElement, Content contentTree) {
+ addPreQualifiedClassLink(context, typeElement, true, contentTree);
+ }
+
+ /**
+ * Get the link for the given member.
+ *
+ * @param context the id of the context where the link will be added
+ * @param element the member being linked to
+ * @param label the label for the link
+ * @return a content tree for the element link
+ */
+ public Content getDocLink(LinkInfoImpl.Kind context, Element element, String label) {
+ return getDocLink(context, utils.getEnclosingTypeElement(element), element,
+ new StringContent(label));
+ }
+
+ /**
+ * Return the link for the given member.
+ *
+ * @param context the id of the context where the link will be printed.
+ * @param element the member being linked to.
+ * @param label the label for the link.
+ * @param strong true if the link should be strong.
+ * @return the link for the given member.
+ */
+ public Content getDocLink(LinkInfoImpl.Kind context, Element element, String label,
+ boolean strong) {
+ return getDocLink(context, utils.getEnclosingTypeElement(element), element, label, strong);
+ }
+
+ /**
+ * Return the link for the given member.
+ *
+ * @param context the id of the context where the link will be printed.
+ * @param typeElement the typeElement that we should link to. This is not
+ necessarily equal to element.containingClass(). We may be
+ inheriting comments.
+ * @param element the member being linked to.
+ * @param label the label for the link.
+ * @param strong true if the link should be strong.
+ * @return the link for the given member.
+ */
+ public Content getDocLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element element,
+ String label, boolean strong) {
+ return getDocLink(context, typeElement, element, label, strong, false);
+ }
+
+ public Content getDocLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element element,
+ Content label, boolean strong) {
+ return getDocLink(context, typeElement, element, label, strong, false);
+ }
+
+ /**
+ * Return the link for the given member.
+ *
+ * @param context the id of the context where the link will be printed.
+ * @param typeElement the typeElement that we should link to. This is not
+ necessarily equal to element.containingClass(). We may be
+ inheriting comments.
+ * @param element the member being linked to.
+ * @param label the label for the link.
+ * @param strong true if the link should be strong.
+ * @param isProperty true if the element parameter is a JavaFX property.
+ * @return the link for the given member.
+ */
+ public Content getDocLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element element,
+ String label, boolean strong, boolean isProperty) {
+ return getDocLink(context, typeElement, element, new StringContent(check(label)), strong, isProperty);
+ }
+
+ String check(String s) {
+ if (s.matches(".*[&<>].*")) {
+ throw new IllegalArgumentException(s);
+ }
+ return s;
+ }
+
+ public Content getDocLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element element,
+ Content label, boolean strong, boolean isProperty) {
+ if (! (utils.isIncluded(element) || utils.isLinkable(typeElement))) {
+ return label;
+ } else if (utils.isExecutableElement(element)) {
+ ExecutableElement ee = (ExecutableElement)element;
+ return getLink(new LinkInfoImpl(configuration, context, typeElement)
+ .label(label)
+ .where(getName(getAnchor(ee, isProperty)))
+ .strong(strong));
+ } else if (utils.isVariableElement(element) || utils.isTypeElement(element)) {
+ return getLink(new LinkInfoImpl(configuration, context, typeElement)
+ .label(label)
+ .where(getName(element.getSimpleName().toString()))
+ .strong(strong));
+ } else {
+ return label;
+ }
+ }
+
+ /**
+ * Return the link for the given member.
+ *
+ * @param context the id of the context where the link will be added
+ * @param typeElement the typeElement that we should link to. This is not
+ necessarily equal to element.containingClass(). We may be
+ inheriting comments
+ * @param element the member being linked to
+ * @param label the label for the link
+ * @return the link for the given member
+ */
+ public Content getDocLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element element,
+ Content label) {
+ if (! (utils.isIncluded(element) || utils.isLinkable(typeElement))) {
+ return label;
+ } else if (utils.isExecutableElement(element)) {
+ ExecutableElement emd = (ExecutableElement) element;
+ return getLink(new LinkInfoImpl(configuration, context, typeElement)
+ .label(label)
+ .where(getName(getAnchor(emd))));
+ } else if (utils.isVariableElement(element) || utils.isTypeElement(element)) {
+ return getLink(new LinkInfoImpl(configuration, context, typeElement)
+ .label(label).where(getName(element.getSimpleName().toString())));
+ } else {
+ return label;
+ }
+ }
+
+ public String getAnchor(ExecutableElement executableElement) {
+ return getAnchor(executableElement, false);
+ }
+
+ public String getAnchor(ExecutableElement executableElement, boolean isProperty) {
+ if (isProperty) {
+ return executableElement.getSimpleName().toString();
+ }
+ String signature = utils.signature(executableElement);
+ StringBuilder signatureParsed = new StringBuilder();
+ int counter = 0;
+ for (int i = 0; i < signature.length(); i++) {
+ char c = signature.charAt(i);
+ if (c == '<') {
+ counter++;
+ } else if (c == '>') {
+ counter--;
+ } else if (counter == 0) {
+ signatureParsed.append(c);
+ }
+ }
+ return utils.getSimpleName(executableElement) + signatureParsed.toString();
+ }
+
+ public Content seeTagToContent(Element element, DocTree see) {
+
+ Kind kind = see.getKind();
+ if (!(kind == LINK || kind == SEE || kind == LINK_PLAIN)) {
+ return new ContentBuilder();
+ }
+
+ CommentHelper ch = utils.getCommentHelper(element);
+ String tagName = ch.getTagName(see);
+ String seetext = replaceDocRootDir(utils.normalizeNewlines(ch.getText(see)));
+ // Check if @see is an href or "string"
+ if (seetext.startsWith("<") || seetext.startsWith("\"")) {
+ return new RawHtml(seetext);
+ }
+ boolean isLinkPlain = kind == LINK_PLAIN;
+ Content label = plainOrCode(isLinkPlain, new RawHtml(ch.getLabel(configuration, see)));
+
+ //The text from the @see tag. We will output this text when a label is not specified.
+ Content text = plainOrCode(kind == LINK_PLAIN, new RawHtml(seetext));
+
+ TypeElement refClass = ch.getReferencedClass(configuration, see);
+ String refClassName = ch.getReferencedClassName(configuration, see);
+ Element refMem = ch.getReferencedMember(configuration, see);
+ String refMemName = ch.getReferencedMemberName(see);
+
+ if (refMemName == null && refMem != null) {
+ refMemName = refMem.toString();
+ }
+ if (refClass == null) {
+ //@see is not referencing an included class
+ PackageElement refPackage = ch.getReferencedPackage(configuration, see);
+ if (refPackage != null && utils.isIncluded(refPackage)) {
+ //@see is referencing an included package
+ if (label.isEmpty())
+ label = plainOrCode(isLinkPlain,
+ new StringContent(refPackage.getQualifiedName().toString()));
+ return getPackageLink(refPackage, label);
+ } else {
+ // @see is not referencing an included class or package. Check for cross links.
+ Content classCrossLink;
+ DocLink packageCrossLink = getCrossPackageLink(refClassName);
+ if (packageCrossLink != null) {
+ // Package cross link found
+ return getHyperLink(packageCrossLink,
+ (label.isEmpty() ? text : label));
+ } else if ((classCrossLink = getCrossClassLink(refClassName,
+ refMemName, label, false, "", !isLinkPlain)) != null) {
+ // Class cross link found (possibly to a member in the class)
+ return classCrossLink;
+ } else {
+ // No cross link found so print warning
+ configuration.getDocletSpecificMsg().warning(ch.getDocTreePath(see),
+ "doclet.see.class_or_package_not_found",
+ "@" + tagName,
+ seetext);
+ return (label.isEmpty() ? text: label);
+ }
+ }
+ } else if (refMemName == null) {
+ // Must be a class reference since refClass is not null and refMemName is null.
+ if (label.isEmpty()) {
+ /*
+ * it seems to me this is the right thing to do, but it causes comparator failures.
+ */
+ if (!configuration.backwardCompatibility) {
+ StringContent content = utils.isEnclosingPackageIncluded(refClass)
+ ? new StringContent(utils.getSimpleName(refClass))
+ : new StringContent(utils.getFullyQualifiedName(refClass));
+ label = plainOrCode(isLinkPlain, content);
+ } else {
+ label = plainOrCode(isLinkPlain,
+ new StringContent(utils.getSimpleName(refClass)));
+ }
+
+ }
+ return getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.DEFAULT, refClass)
+ .label(label));
+ } else if (refMem == null) {
+ // Must be a member reference since refClass is not null and refMemName is not null.
+ // However, refMem is null, so this referenced member does not exist.
+ return (label.isEmpty() ? text: label);
+ } else {
+ // Must be a member reference since refClass is not null and refMemName is not null.
+ // refMem is not null, so this @see tag must be referencing a valid member.
+ TypeElement containing = utils.getEnclosingTypeElement(refMem);
+ if (ch.getText(see).trim().startsWith("#") &&
+ ! (utils.isPublic(containing) || utils.isLinkable(containing))) {
+ // Since the link is relative and the holder is not even being
+ // documented, this must be an inherited link. Redirect it.
+ // The current class either overrides the referenced member or
+ // inherits it automatically.
+ if (this instanceof ClassWriterImpl) {
+ containing = ((ClassWriterImpl) this).getTypeElement();
+ } else if (!utils.isPublic(containing)) {
+ configuration.getDocletSpecificMsg().warning(
+ ch.getDocTreePath(see), "doclet.see.class_or_package_not_accessible",
+ tagName, utils.getFullyQualifiedName(containing));
+ } else {
+ configuration.getDocletSpecificMsg().warning(
+ ch.getDocTreePath(see), "doclet.see.class_or_package_not_found",
+ tagName, seetext);
+ }
+ }
+ if (configuration.currentTypeElement != containing) {
+ refMemName = (utils.isConstructor(refMem))
+ ? refMemName
+ : utils.getSimpleName(containing) + "." + refMemName;
+ }
+ if (utils.isExecutableElement(refMem)) {
+ if (refMemName.indexOf('(') < 0) {
+ refMemName += utils.makeSignature((ExecutableElement)refMem, true);
+ }
+ }
+
+ text = plainOrCode(kind == LINK_PLAIN, new StringContent(refMemName));
+
+ return getDocLink(LinkInfoImpl.Kind.SEE_TAG, containing,
+ refMem, (label.isEmpty() ? text: label), false);
+ }
+ }
+
+ private Content plainOrCode(boolean plain, Content body) {
+ return (plain || body.isEmpty()) ? body : HtmlTree.CODE(body);
+ }
+
+ /**
+ * Add the inline comment.
+ *
+ * @param element the Element for which the inline comment will be added
+ * @param tag the inline tag to be added
+ * @param htmltree the content tree to which the comment will be added
+ */
+ public void addInlineComment(Element element, DocTree tag, Content htmltree) {
+ CommentHelper ch = utils.getCommentHelper(element);
+ List extends DocTree> description = ch.getDescription(configuration, tag);
+ addCommentTags(element, tag, description, false, false, htmltree);
+ }
+
+ /**
+ * Add the inline deprecated comment.
+ *
+ * @param e the Element for which the inline deprecated comment will be added
+ * @param tag the inline tag to be added
+ * @param htmltree the content tree to which the comment will be added
+ */
+ public void addInlineDeprecatedComment(Element e, DocTree tag, Content htmltree) {
+ CommentHelper ch = utils.getCommentHelper(e);
+ addCommentTags(e, ch.getBody(configuration, tag), true, false, htmltree);
+ }
+
+ /**
+ * Adds the summary content.
+ *
+ * @param element the Element for which the summary will be generated
+ * @param htmltree the documentation tree to which the summary will be added
+ */
+ public void addSummaryComment(Element element, Content htmltree) {
+ addSummaryComment(element, utils.getFirstSentenceTrees(element), htmltree);
+ }
+
+ /**
+ * Adds the summary content.
+ *
+ * @param element the Element for which the summary will be generated
+ * @param firstSentenceTags the first sentence tags for the doc
+ * @param htmltree the documentation tree to which the summary will be added
+ */
+ public void addSummaryComment(Element element, List extends DocTree> firstSentenceTags, Content htmltree) {
+ addCommentTags(element, firstSentenceTags, false, true, htmltree);
+ }
+
+ public void addSummaryDeprecatedComment(Element element, DocTree tag, Content htmltree) {
+ CommentHelper ch = utils.getCommentHelper(element);
+ List extends DocTree> body = ch.getBody(configuration, tag);
+ addCommentTags(element, ch.getFirstSentenceTrees(configuration, body), true, true, htmltree);
+ }
+
+ /**
+ * Adds the inline comment.
+ *
+ * @param element the Element for which the inline comments will be generated
+ * @param htmltree the documentation tree to which the inline comments will be added
+ */
+ public void addInlineComment(Element element, Content htmltree) {
+ addCommentTags(element, utils.getBody(element), false, false, htmltree);
+ }
+
+ /**
+ * Adds the comment tags.
+ *
+ * @param element the Element for which the comment tags will be generated
+ * @param tags the first sentence tags for the doc
+ * @param depr true if it is deprecated
+ * @param first true if the first sentence tags should be added
+ * @param htmltree the documentation tree to which the comment tags will be added
+ */
+ private void addCommentTags(Element element, List extends DocTree> tags, boolean depr,
+ boolean first, Content htmltree) {
+ addCommentTags(element, null, tags, depr, first, htmltree);
+ }
+
+ /**
+ * Adds the comment tags.
+ *
+ * @param element for which the comment tags will be generated
+ * @param holderTag the block tag context for the inline tags
+ * @param tags the first sentence tags for the doc
+ * @param depr true if it is deprecated
+ * @param first true if the first sentence tags should be added
+ * @param htmltree the documentation tree to which the comment tags will be added
+ */
+ private void addCommentTags(Element element, DocTree holderTag, List extends DocTree> tags, boolean depr,
+ boolean first, Content htmltree) {
+ if(configuration.nocomment){
+ return;
+ }
+ Content div;
+ Content result = commentTagsToContent(null, element, tags, first);
+ if (depr) {
+ Content italic = HtmlTree.SPAN(HtmlStyle.deprecationComment, result);
+ div = HtmlTree.DIV(HtmlStyle.block, italic);
+ htmltree.addContent(div);
+ }
+ else {
+ div = HtmlTree.DIV(HtmlStyle.block, result);
+ htmltree.addContent(div);
+ }
+ if (tags.isEmpty()) {
+ htmltree.addContent(getSpace());
+ }
+ }
+
+ boolean ignoreNonInlineTag(DocTree dtree) {
+ Name name = null;
+ if (dtree.getKind() == Kind.START_ELEMENT) {
+ StartElementTree setree = (StartElementTree)dtree;
+ name = setree.getName();
+ } else if (dtree.getKind() == Kind.END_ELEMENT) {
+ EndElementTree eetree = (EndElementTree)dtree;
+ name = eetree.getName();
+ }
+
+ if (name != null) {
+ com.sun.tools.doclint.HtmlTag htmlTag = com.sun.tools.doclint.HtmlTag.get(name);
+ if (htmlTag != null &&
+ htmlTag.blockType != com.sun.tools.doclint.HtmlTag.BlockType.INLINE) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ boolean isAllWhiteSpace(String body) {
+ for (int i = 0 ; i < body.length(); i++) {
+ if (!Character.isWhitespace(body.charAt(i)))
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Converts inline tags and text to text strings, expanding the
+ * inline tags along the way. Called wherever text can contain
+ * an inline tag, such as in comments or in free-form text arguments
+ * to non-inline tags.
+ *
+ * @param holderTag specific tag where comment resides
+ * @param element specific element where comment resides
+ * @param tags array of text tags and inline tags (often alternating)
+ present in the text of interest for this element
+ * @param isFirstSentence true if text is first sentence
+ * @return a Content object
+ */
+ public Content commentTagsToContent(DocTree holderTag, Element element,
+ List extends DocTree> tags, boolean isFirstSentence) {
+
+ final Content result = new ContentBuilder() {
+ @Override
+ public void addContent(String text) {
+ super.addContent(utils.normalizeNewlines(text));
+ }
+ };
+ CommentHelper ch = utils.getCommentHelper(element);
+ // Array of all possible inline tags for this javadoc run
+ configuration.tagletManager.checkTags(utils, element, tags, true);
+ for (ListIterator extends DocTree> iterator = tags.listIterator(); iterator.hasNext();) {
+ DocTree tag = iterator.next();
+ // zap block tags
+ if (isFirstSentence && ignoreNonInlineTag(tag))
+ continue;
+
+ if (isFirstSentence && iterator.nextIndex() == tags.size() &&
+ (tag.getKind() == TEXT && isAllWhiteSpace(ch.getText(tag))))
+ continue;
+
+ boolean allDone = new SimpleDocTreeVisitor() {
+ // notify the next DocTree handler to take necessary action
+ boolean commentRemoved = false;
+
+ private boolean isLast(DocTree node) {
+ return node.equals(tags.get(tags.size() - 1));
+ }
+
+ private boolean isFirst(DocTree node) {
+ return node.equals(tags.get(0));
+ }
+
+ private boolean inAnAtag() {
+ if (utils.isStartElement(tag)) {
+ StartElementTree st = (StartElementTree)tag;
+ Name name = st.getName();
+ if (name != null) {
+ com.sun.tools.doclint.HtmlTag htag =
+ com.sun.tools.doclint.HtmlTag.get(name);
+ return htag != null && htag.equals(com.sun.tools.doclint.HtmlTag.A);
+ }
+ }
+ return false;
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Boolean visitAttribute(AttributeTree node, Content c) {
+ StringBuilder sb = new StringBuilder(SPACER).append(node.getName());
+ if (node.getValueKind() == ValueKind.EMPTY) {
+ result.addContent(sb.toString());
+ return false;
+ }
+ sb.append("=");
+ String quote;
+ switch (node.getValueKind()) {
+ case DOUBLE:
+ quote = "\"";
+ break;
+ case SINGLE:
+ quote = "\'";
+ break;
+ default:
+ quote = "";
+ break;
+ }
+ sb.append(quote);
+ result.addContent(sb.toString());
+ Content docRootContent = new ContentBuilder();
+
+ for (DocTree dt : node.getValue()) {
+ if (utils.isText(dt) && inAnAtag()) {
+ String text = ((TextTree) dt).getBody();
+ if (text.startsWith("/..") && !configuration.docrootparent.isEmpty()) {
+ result.addContent(configuration.docrootparent);
+ docRootContent = new ContentBuilder();
+ text = textCleanup(text.substring(3), isLast(node));
+ } else {
+ if (!docRootContent.isEmpty()) {
+ docRootContent = copyDocRootContent(docRootContent);
+ } else {
+ text = redirectRelativeLinks(element, (TextTree) dt);
+ }
+ text = textCleanup(text, isLast(node));
+ }
+ result.addContent(text);
+ } else {
+ docRootContent = copyDocRootContent(docRootContent);
+ dt.accept(this, docRootContent);
+ }
+ }
+ copyDocRootContent(docRootContent);
+ result.addContent(quote);
+ return false;
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Boolean visitComment(CommentTree node, Content c) {
+ if (isFirstSentence && isFirst(node)) {
+ commentRemoved = true;
+ return this.visit(iterator.next(), c);
+ }
+ result.addContent(new RawHtml(node.getBody()));
+ return false;
+ }
+
+ private Content copyDocRootContent(Content content) {
+ if (!content.isEmpty()) {
+ result.addContent(content);
+ return new ContentBuilder();
+ }
+ return content;
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Boolean visitDocRoot(DocRootTree node, Content c) {
+ Content docRootContent = TagletWriter.getInlineTagOutput(element,
+ configuration.tagletManager,
+ holderTag,
+ node,
+ getTagletWriterInstance(isFirstSentence));
+ if (c != null) {
+ c.addContent(docRootContent);
+ } else {
+ result.addContent(docRootContent);
+ }
+ return false;
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Boolean visitEndElement(EndElementTree node, Content c) {
+ RawHtml rawHtml = new RawHtml("" + node.getName() + ">");
+ result.addContent(rawHtml);
+ return false;
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Boolean visitEntity(EntityTree node, Content c) {
+ result.addContent(new RawHtml(node.toString()));
+ return false;
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Boolean visitErroneous(ErroneousTree node, Content c) {
+ configuration.getDocletSpecificMsg().warning(ch.getDocTreePath(node),
+ "doclet.tag.invalid_usage", node);
+ result.addContent(new RawHtml(node.toString()));
+ return false;
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Boolean visitInheritDoc(InheritDocTree node, Content c) {
+ Content output = TagletWriter.getInlineTagOutput(element,
+ configuration.tagletManager, holderTag,
+ tag, getTagletWriterInstance(isFirstSentence));
+ result.addContent(output);
+ // if we obtained the first sentence successfully, nothing more to do
+ return (isFirstSentence && !output.isEmpty());
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Boolean visitIndex(IndexTree node, Content p) {
+ Content output = TagletWriter.getInlineTagOutput(element,
+ configuration.tagletManager, holderTag, tag,
+ getTagletWriterInstance(isFirstSentence));
+ if (output != null) {
+ result.addContent(output);
+ }
+ return false;
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Boolean visitLink(LinkTree node, Content c) {
+ // we need to pass the DocTreeImpl here, so ignore node
+ result.addContent(seeTagToContent(element, tag));
+ return false;
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Boolean visitLiteral(LiteralTree node, Content c) {
+ String s = node.getBody().toString();
+ Content content = new StringContent(utils.normalizeNewlines(s));
+ if (node.getKind() == CODE)
+ content = HtmlTree.CODE(content);
+ result.addContent(content);
+ return false;
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Boolean visitSee(SeeTree node, Content c) {
+ // we need to pass the DocTreeImpl here, so ignore node
+ result.addContent(seeTagToContent(element, tag));
+ return false;
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Boolean visitStartElement(StartElementTree node, Content c) {
+ String text = "<" + node.getName();
+ text = utils.normalizeNewlines(text);
+ RawHtml rawHtml = new RawHtml(text);
+ result.addContent(rawHtml);
+
+ for (DocTree dt : node.getAttributes()) {
+ dt.accept(this, null);
+ }
+ result.addContent(new RawHtml(node.isSelfClosing() ? "/>" : ">"));
+ return false;
+ }
+
+ private String textCleanup(String text, boolean isLast) {
+ return textCleanup(text, isLast, false);
+ }
+
+ private String textCleanup(String text, boolean isLast, boolean trimLeader) {
+ if (trimLeader) {
+ text = removeLeadingWhitespace(text);
+ }
+ if (isFirstSentence && isLast) {
+ text = removeTrailingWhitespace(text);
+ }
+ text = utils.replaceTabs(text);
+ text = utils.normalizeNewlines(text);
+ return text;
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public Boolean visitText(TextTree node, Content c) {
+ String text = node.getBody();
+ text = textCleanup(text, isLast(node), commentRemoved);
+ commentRemoved = false;
+ result.addContent(new RawHtml(text));
+ return false;
+ }
+
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ protected Boolean defaultAction(DocTree node, Content c) {
+ Content output = TagletWriter.getInlineTagOutput(element,
+ configuration.tagletManager, holderTag, tag,
+ getTagletWriterInstance(isFirstSentence));
+ if (output != null) {
+ result.addContent(output);
+ }
+ return false;
+ }
+
+ }.visit(tag, null);
+ if (allDone)
+ break;
+ }
+ return result;
+ }
+
+ private String removeTrailingWhitespace(String text) {
+ char[] buf = text.toCharArray();
+ for (int i = buf.length - 1; i > 0 ; i--) {
+ if (!Character.isWhitespace(buf[i]))
+ return text.substring(0, i + 1);
+ }
+ return text;
+ }
+
+ private String removeLeadingWhitespace(String text) {
+ char[] buf = text.toCharArray();
+ for (int i = 0; i < buf.length; i++) {
+ if (!Character.isWhitespace(buf[i])) {
+ return text.substring(i);
+ }
+ }
+ return text;
+ }
+
+ /**
+ * Return true if relative links should not be redirected.
+ *
+ * @return Return true if a relative link should not be redirected.
+ */
+ private boolean shouldNotRedirectRelativeLinks() {
+ return this instanceof AnnotationTypeWriter ||
+ this instanceof ClassWriter ||
+ this instanceof PackageSummaryWriter;
+ }
+
+ /**
+ * Suppose a piece of documentation has a relative link. When you copy
+ * that documentation to another place such as the index or class-use page,
+ * that relative link will no longer work. We should redirect those links
+ * so that they will work again.
+ *
+ * Here is the algorithm used to fix the link:
+ *
+ * {@literal => docRoot + + }
+ *
+ * For example, suppose DocletEnvironment has this link:
+ * {@literal The package Page }
+ *
+ * If this link appeared in the index, we would redirect
+ * the link like this:
+ *
+ * {@literal The package Page }
+ *
+ * @param element the Element object whose documentation is being written.
+ * @param text the text being written.
+ *
+ * @return the text, with all the relative links redirected to work.
+ */
+ private String redirectRelativeLinks(Element element, TextTree tt) {
+ String text = tt.getBody();
+ if (element == null || utils.isOverviewElement(element) || shouldNotRedirectRelativeLinks()) {
+ return text;
+ }
+
+ DocPath redirectPathFromRoot = new SimpleElementVisitor9() {
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public DocPath visitType(TypeElement e, Void p) {
+ return DocPath.forPackage(utils.containingPackage(e));
+ }
+
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public DocPath visitPackage(PackageElement e, Void p) {
+ return DocPath.forPackage(e);
+ }
+
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public DocPath visitVariable(VariableElement e, Void p) {
+ return DocPath.forPackage(utils.containingPackage(e));
+ }
+
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public DocPath visitExecutable(ExecutableElement e, Void p) {
+ return DocPath.forPackage(utils.containingPackage(e));
+ }
+
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ protected DocPath defaultAction(Element e, Void p) {
+ return null;
+ }
+ }.visit(element);
+ if (redirectPathFromRoot == null) {
+ return text;
+ }
+ String lower = Utils.toLowerCase(text);
+ if (!(lower.startsWith("mailto:")
+ || lower.startsWith("http:")
+ || lower.startsWith("https:")
+ || lower.startsWith("file:"))) {
+ text = "{@" + (new DocRootTaglet()).getName() + "}/"
+ + redirectPathFromRoot.resolve(text).getPath();
+ text = replaceDocRootDir(text);
+ }
+ return text;
+ }
+
+ static final Set blockTags = new HashSet<>();
+ static {
+ for (HtmlTag t: HtmlTag.values()) {
+ if (t.blockType == HtmlTag.BlockType.BLOCK)
+ blockTags.add(t.value);
+ }
+ }
+
+ /**
+ * Add a link to the stylesheet file.
+ *
+ * @param head the content tree to which the files will be added
+ */
+ public void addStyleSheetProperties(Content head) {
+ String stylesheetfile = configuration.stylesheetfile;
+ DocPath stylesheet;
+ if (stylesheetfile.isEmpty()) {
+ stylesheet = DocPaths.STYLESHEET;
+ } else {
+ DocFile file = DocFile.createFileForInput(configuration, stylesheetfile);
+ stylesheet = DocPath.create(file.getName());
+ }
+ HtmlTree link = HtmlTree.LINK("stylesheet", "text/css",
+ pathToRoot.resolve(stylesheet).getPath(),
+ "Style");
+ head.addContent(link);
+ if (configuration.createindex) {
+ HtmlTree jq_link = HtmlTree.LINK("stylesheet", "text/css",
+ pathToRoot.resolve(DocPaths.JQUERY_FILES.resolve(DocPaths.JQUERY_STYLESHEET_FILE)).getPath(),
+ "Style");
+ head.addContent(jq_link);
+ }
+ }
+
+ /**
+ * Add a link to the JavaScript file.
+ *
+ * @param head the content tree to which the files will be added
+ */
+ public void addScriptProperties(Content head) {
+ HtmlTree javascript = HtmlTree.SCRIPT(pathToRoot.resolve(DocPaths.JAVASCRIPT).getPath());
+ head.addContent(javascript);
+ if (configuration.createindex) {
+ if (pathToRoot != null && script != null) {
+ String path = pathToRoot.isEmpty() ? "." : pathToRoot.getPath();
+ script.addContent(new RawHtml("var pathtoroot = \"" + path + "/\";loadScripts(document, \'script\');"));
+ }
+ addJQueryFile(head, DocPaths.JSZIP_MIN);
+ addJQueryFile(head, DocPaths.JSZIPUTILS_MIN);
+ head.addContent(new RawHtml(""));
+ addJQueryFile(head, DocPaths.JQUERY_JS_1_10);
+ addJQueryFile(head, DocPaths.JQUERY_JS);
+ }
+ }
+
+ /**
+ * Add a link to the JQuery javascript file.
+ *
+ * @param head the content tree to which the files will be added
+ * @param filePath the DocPath of the file that needs to be added
+ */
+ private void addJQueryFile(Content head, DocPath filePath) {
+ HtmlTree jqyeryScriptFile = HtmlTree.SCRIPT(
+ pathToRoot.resolve(DocPaths.JQUERY_FILES.resolve(filePath)).getPath());
+ head.addContent(jqyeryScriptFile);
+ }
+
+ /**
+ * According to
+ * The Java™ Language Specification ,
+ * all the outer classes and static nested classes are core classes.
+ */
+ public boolean isCoreClass(TypeElement typeElement) {
+ return utils.getEnclosingTypeElement(typeElement) == null || utils.isStatic(typeElement);
+ }
+
+ /**
+ * Adds the annotation types for the given packageElement.
+ *
+ * @param packageElement the package to write annotations for.
+ * @param htmltree the documentation tree to which the annotation info will be
+ * added
+ */
+ public void addAnnotationInfo(PackageElement packageElement, Content htmltree) {
+ addAnnotationInfo(packageElement, packageElement.getAnnotationMirrors(), htmltree);
+ }
+
+ /**
+ * Add the annotation types of the executable receiver.
+ *
+ * @param method the executable to write the receiver annotations for.
+ * @param descList list of annotation description.
+ * @param htmltree the documentation tree to which the annotation info will be
+ * added
+ */
+ public void addReceiverAnnotationInfo(ExecutableElement method, List descList,
+ Content htmltree) {
+ addAnnotationInfo(0, method, descList, false, htmltree);
+ }
+
+ /*
+ * this is a hack to delay dealing with Annotations in the writers, the assumption
+ * is that all necessary checks have been made to get here.
+ */
+ public void addReceiverAnnotationInfo(ExecutableElement method, TypeMirror rcvrTypeMirror,
+ List extends AnnotationMirror> annotationMirrors, Content htmltree) {
+ TypeMirror rcvrType = method.getReceiverType();
+ List extends AnnotationMirror> annotationMirrors1 = rcvrType.getAnnotationMirrors();
+ addAnnotationInfo(0, method, annotationMirrors1, false, htmltree);
+ }
+
+ /**
+ * Adds the annotatation types for the given element.
+ *
+ * @param element the package to write annotations for
+ * @param htmltree the content tree to which the annotation types will be added
+ */
+ public void addAnnotationInfo(Element element, Content htmltree) {
+ addAnnotationInfo(element, element.getAnnotationMirrors(), htmltree);
+ }
+
+ /**
+ * Add the annotatation types for the given element and parameter.
+ *
+ * @param indent the number of spaces to indent the parameters.
+ * @param element the element to write annotations for.
+ * @param param the parameter to write annotations for.
+ * @param tree the content tree to which the annotation types will be added
+ */
+ public boolean addAnnotationInfo(int indent, Element element, VariableElement param,
+ Content tree) {
+ return addAnnotationInfo(indent, element, param.getAnnotationMirrors(), false, tree);
+ }
+
+ /**
+ * Adds the annotatation types for the given Element.
+ *
+ * @param element the element to write annotations for.
+ * @param descList the array of {@link AnnotationDesc}.
+ * @param htmltree the documentation tree to which the annotation info will be
+ * added
+ */
+ private void addAnnotationInfo(Element element, List extends AnnotationMirror> descList,
+ Content htmltree) {
+ addAnnotationInfo(0, element, descList, true, htmltree);
+ }
+
+ /**
+ * Adds the annotation types for the given element.
+ *
+ * @param indent the number of extra spaces to indent the annotations.
+ * @param element the element to write annotations for.
+ * @param descList the array of {@link AnnotationDesc}.
+ * @param htmltree the documentation tree to which the annotation info will be
+ * added
+ */
+ private boolean addAnnotationInfo(int indent, Element element,
+ List extends AnnotationMirror> descList, boolean lineBreak, Content htmltree) {
+ List annotations = getAnnotations(indent, descList, lineBreak);
+ String sep = "";
+ if (annotations.isEmpty()) {
+ return false;
+ }
+ for (Content annotation: annotations) {
+ htmltree.addContent(sep);
+ htmltree.addContent(annotation);
+ if (!lineBreak) {
+ sep = " ";
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Return the string representations of the annotation types for
+ * the given doc.
+ *
+ * @param indent the number of extra spaces to indent the annotations.
+ * @param descList the array of {@link AnnotationDesc}.
+ * @param linkBreak if true, add new line between each member value.
+ * @return an array of strings representing the annotations being
+ * documented.
+ */
+ private List getAnnotations(int indent, List extends AnnotationMirror> descList, boolean linkBreak) {
+ return getAnnotations(indent, descList, linkBreak, true);
+ }
+
+ private List getAnnotations(int indent, AnnotationMirror amirror, boolean linkBreak) {
+ List descList = new ArrayList<>();
+ descList.add(amirror);
+ return getAnnotations(indent, descList, linkBreak, true);
+ }
+
+ /**
+ * Return the string representations of the annotation types for
+ * the given doc.
+ *
+ * A {@code null} {@code elementType} indicates that all the
+ * annotations should be returned without any filtering.
+ *
+ * @param indent the number of extra spaces to indent the annotations.
+ * @param descList the array of {@link AnnotationDesc}.
+ * @param linkBreak if true, add new line between each member value.
+ * @param isJava5DeclarationLocation
+ * @return an array of strings representing the annotations being
+ * documented.
+ */
+ public List getAnnotations(int indent, List extends AnnotationMirror> descList,
+ boolean linkBreak, boolean isJava5DeclarationLocation) {
+ List results = new ArrayList<>();
+ ContentBuilder annotation;
+ for (AnnotationMirror aDesc : descList) {
+ TypeElement annotationElement = (TypeElement)aDesc.getAnnotationType().asElement();
+ // If an annotation is not documented, do not add it to the list. If
+ // the annotation is of a repeatable type, and if it is not documented
+ // and also if its container annotation is not documented, do not add it
+ // to the list. If an annotation of a repeatable type is not documented
+ // but its container is documented, it will be added to the list.
+ if (!utils.isDocumentedAnnotation(annotationElement) &&
+ (!isAnnotationDocumented && !isContainerDocumented)) {
+ continue;
+ }
+ /* TODO: check logic here to correctly handle declaration
+ * and type annotations.
+ if (utils.isDeclarationAnnotation(annotationElement, isJava5DeclarationLocation)) {
+ continue;
+ }*/
+ annotation = new ContentBuilder();
+ isAnnotationDocumented = false;
+ LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.ANNOTATION, annotationElement);
+ Map extends ExecutableElement, ? extends AnnotationValue> pairs = aDesc.getElementValues();
+ // If the annotation is synthesized, do not print the container.
+ if (utils.configuration.workArounds.isSynthesized(aDesc)) {
+ for (ExecutableElement ee : pairs.keySet()) {
+ AnnotationValue annotationValue = pairs.get(ee);
+ List annotationTypeValues = new ArrayList<>();
+
+ new SimpleAnnotationValueVisitor9>() {
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public Void visitArray(List extends AnnotationValue> vals, List p) {
+ p.addAll(vals);
+ return null;
+ }
+
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ protected Void defaultAction(Object o, List p) {
+ p.add(annotationValue);
+ return null;
+ }
+ }.visit(annotationValue, annotationTypeValues);
+
+ String sep = "";
+ for (AnnotationValue av : annotationTypeValues) {
+ annotation.addContent(sep);
+ annotation.addContent(annotationValueToContent(av));
+ sep = " ";
+ }
+ }
+ } else if (isAnnotationArray(pairs)) {
+ // If the container has 1 or more value defined and if the
+ // repeatable type annotation is not documented, do not print
+ // the container.
+ if (pairs.size() == 1 && isAnnotationDocumented) {
+ List annotationTypeValues = new ArrayList<>();
+ for (AnnotationValue a : pairs.values()) {
+ new SimpleAnnotationValueVisitor9>() {
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public Void visitArray(List extends AnnotationValue> vals, List annotationTypeValues) {
+ for (AnnotationValue av : vals) {
+ annotationTypeValues.add(av);
+ }
+ return null;
+ }
+ }.visit(a, annotationTypeValues);
+ }
+ String sep = "";
+ for (AnnotationValue av : annotationTypeValues) {
+ annotation.addContent(sep);
+ annotation.addContent(annotationValueToContent(av));
+ sep = " ";
+ }
+ }
+ // If the container has 1 or more value defined and if the
+ // repeatable type annotation is not documented, print the container.
+ else {
+ addAnnotations(annotationElement, linkInfo, annotation, pairs,
+ indent, false);
+ }
+ }
+ else {
+ addAnnotations(annotationElement, linkInfo, annotation, pairs,
+ indent, linkBreak);
+ }
+ annotation.addContent(linkBreak ? DocletConstants.NL : "");
+ results.add(annotation);
+ }
+ return results;
+ }
+
+ /**
+ * Add annotation to the annotation string.
+ *
+ * @param annotationDoc the annotation being documented
+ * @param linkInfo the information about the link
+ * @param annotation the annotation string to which the annotation will be added
+ * @param pairs annotation type element and value pairs
+ * @param indent the number of extra spaces to indent the annotations.
+ * @param linkBreak if true, add new line between each member value
+ */
+ private void addAnnotations(TypeElement annotationDoc, LinkInfoImpl linkInfo,
+ ContentBuilder annotation, Map extends ExecutableElement,? extends AnnotationValue>map,
+ int indent, boolean linkBreak) {
+ linkInfo.label = new StringContent("@" + annotationDoc.getSimpleName().toString());
+ annotation.addContent(getLink(linkInfo));
+ if (!map.isEmpty()) {
+ annotation.addContent("(");
+ boolean isFirst = true;
+ for (ExecutableElement element : map.keySet()) {
+ if (isFirst) {
+ isFirst = false;
+ } else {
+ annotation.addContent(",");
+ if (linkBreak) {
+ annotation.addContent(DocletConstants.NL);
+ int spaces = annotationDoc.getSimpleName().toString().length() + 2;
+ for (int k = 0; k < (spaces + indent); k++) {
+ annotation.addContent(" ");
+ }
+ }
+ }
+ annotation.addContent(getDocLink(LinkInfoImpl.Kind.ANNOTATION,
+ element, element.getSimpleName().toString(), false));
+ annotation.addContent("=");
+ AnnotationValue annotationValue = map.get(element);
+ List annotationTypeValues = new ArrayList<>();
+ new SimpleAnnotationValueVisitor9() {
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public Void visitArray(List extends AnnotationValue> vals, AnnotationValue p) {
+ annotationTypeValues.addAll(vals);
+ return null;
+ }
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ protected Void defaultAction(Object o, AnnotationValue p) {
+ annotationTypeValues.add(p);
+ return null;
+ }
+ }.visit(annotationValue, annotationValue);
+ annotation.addContent(annotationTypeValues.size() == 1 ? "" : "{");
+ String sep = "";
+ for (AnnotationValue av : annotationTypeValues) {
+ annotation.addContent(sep);
+ annotation.addContent(annotationValueToContent(av));
+ sep = ",";
+ }
+ annotation.addContent(annotationTypeValues.size() == 1 ? "" : "}");
+ isContainerDocumented = false;
+ }
+ annotation.addContent(")");
+ }
+ }
+
+ /**
+ * Check if the annotation contains an array of annotation as a value. This
+ * check is to verify if a repeatable type annotation is present or not.
+ *
+ * @param pairs annotation type element and value pairs
+ *
+ * @return true if the annotation contains an array of annotation as a value.
+ */
+ private boolean isAnnotationArray(Map extends ExecutableElement, ? extends AnnotationValue> pairs) {
+ AnnotationValue annotationValue;
+ for (ExecutableElement ee : pairs.keySet()) {
+ annotationValue = pairs.get(ee);
+ boolean rvalue = new SimpleAnnotationValueVisitor9() {
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public Boolean visitArray(List extends AnnotationValue> vals, Void p) {
+ if (vals.size() > 1) {
+ if (vals.get(0) instanceof AnnotationMirror) {
+ isContainerDocumented = true;
+ return new SimpleAnnotationValueVisitor9() {
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public Boolean visitAnnotation(AnnotationMirror a, Void p) {
+ isContainerDocumented = true;
+ Element asElement = a.getAnnotationType().asElement();
+ if (utils.isDocumentedAnnotation((TypeElement)asElement)) {
+ isAnnotationDocumented = true;
+ }
+ return true;
+ }
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ protected Boolean defaultAction(Object o, Void p) {
+ return false;
+ }
+ }.visit(vals.get(0));
+ }
+ }
+ return false;
+ }
+
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ protected Boolean defaultAction(Object o, Void p) {
+ return false;
+ }
+ }.visit(annotationValue);
+ if (rvalue) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private Content annotationValueToContent(AnnotationValue annotationValue) {
+ return new SimpleAnnotationValueVisitor9() {
+
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public Content visitType(TypeMirror t, Void p) {
+ return new SimpleTypeVisitor9() {
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public Content visitDeclared(DeclaredType t, Void p) {
+ LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.ANNOTATION, t);
+ String name = utils.isIncluded(t.asElement())
+ ? t.asElement().getSimpleName().toString()
+ : utils.getFullyQualifiedName(t.asElement());
+ linkInfo.label = new StringContent(name + utils.getDimension(t) + ".class");
+ return getLink(linkInfo);
+ }
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ protected Content defaultAction(TypeMirror e, Void p) {
+ return new StringContent(t + utils.getDimension(t) + ".class");
+ }
+ }.visit(t);
+ }
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public Content visitAnnotation(AnnotationMirror a, Void p) {
+ List list = getAnnotations(0, a, false);
+ ContentBuilder buf = new ContentBuilder();
+ for (Content c : list) {
+ buf.addContent(c);
+ }
+ return buf;
+ }
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public Content visitEnumConstant(VariableElement c, Void p) {
+ return getDocLink(LinkInfoImpl.Kind.ANNOTATION,
+ c, c.getSimpleName().toString(), false);
+ }
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ public Content visitArray(List extends AnnotationValue> vals, Void p) {
+ ContentBuilder buf = new ContentBuilder();
+ String sep = "";
+ for (AnnotationValue av : vals) {
+ buf.addContent(sep);
+ buf.addContent(visit(av));
+ sep = " ";
+ }
+ return buf;
+ }
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
+ protected Content defaultAction(Object o, Void p) {
+ return new StringContent(annotationValue.toString());
+ }
+ }.visit(annotationValue);
+ }
+
+ /**
+ * Return the configuration for this doclet.
+ *
+ * @return the configuration for this doclet.
+ */
+ public Configuration configuration() {
+ return configuration;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java
new file mode 100644
index 00000000000..5421c278411
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialFieldWriter.java
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.util.*;
+
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
+
+import com.sun.source.doctree.DocTree;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter;
+import jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter;
+import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
+
+/**
+ * Generate serialized form for serializable fields.
+ * Documentation denoted by the tags serial
and
+ * serialField
is processed.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Joe Fialli
+ * @author Bhavesh Patel (Modified)
+ */
+public class HtmlSerialFieldWriter extends FieldWriterImpl
+ implements SerializedFormWriter.SerialFieldWriter {
+
+ public HtmlSerialFieldWriter(SubWriterHolderWriter writer, TypeElement typeElement) {
+ super(writer, typeElement);
+ }
+
+ public SortedSet members(TypeElement te) {
+ return utils.serializableFields(te);
+ }
+
+ /**
+ * Return the header for serializable fields section.
+ *
+ * @return a content tree for the header
+ */
+ public Content getSerializableFieldsHeader() {
+ HtmlTree ul = new HtmlTree(HtmlTag.UL);
+ ul.addStyle(HtmlStyle.blockList);
+ return ul;
+ }
+
+ /**
+ * Return the header for serializable fields content section.
+ *
+ * @param isLastContent true if the cotent being documented is the last content.
+ * @return a content tree for the header
+ */
+ public Content getFieldsContentHeader(boolean isLastContent) {
+ HtmlTree li = new HtmlTree(HtmlTag.LI);
+ if (isLastContent)
+ li.addStyle(HtmlStyle.blockListLast);
+ else
+ li.addStyle(HtmlStyle.blockList);
+ return li;
+ }
+
+ /**
+ * Add serializable fields.
+ *
+ * @param heading the heading for the section
+ * @param serializableFieldsTree the tree to be added to the serializable fileds
+ * content tree
+ * @return a content tree for the serializable fields content
+ */
+ public Content getSerializableFields(String heading, Content serializableFieldsTree) {
+ HtmlTree li = new HtmlTree(HtmlTag.LI);
+ li.addStyle(HtmlStyle.blockList);
+ if (serializableFieldsTree.isValid()) {
+ Content headingContent = new StringContent(heading);
+ Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
+ headingContent);
+ li.addContent(serialHeading);
+ li.addContent(serializableFieldsTree);
+ }
+ return li;
+ }
+
+ /**
+ * Add the member header.
+ *
+ * @param fieldType the class document to be listed
+ * @param fieldTypeStr the string for the field type to be documented
+ * @param fieldDimensions the dimensions of the field string to be added
+ * @param fieldName name of the field to be added
+ * @param contentTree the content tree to which the member header will be added
+ */
+ public void addMemberHeader(TypeElement fieldType, String fieldTypeStr,
+ String fieldDimensions, String fieldName, Content contentTree) {
+ Content nameContent = new RawHtml(fieldName);
+ Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, nameContent);
+ contentTree.addContent(heading);
+ Content pre = new HtmlTree(HtmlTag.PRE);
+ if (fieldType == null) {
+ pre.addContent(fieldTypeStr);
+ } else {
+ Content fieldContent = writer.getLink(new LinkInfoImpl(
+ configuration, LinkInfoImpl.Kind.SERIAL_MEMBER, fieldType));
+ pre.addContent(fieldContent);
+ }
+ pre.addContent(fieldDimensions + " ");
+ pre.addContent(fieldName);
+ contentTree.addContent(pre);
+ }
+
+ /**
+ * Add the deprecated information for this member.
+ *
+ * @param field the field to document.
+ * @param contentTree the tree to which the deprecated info will be added
+ */
+ public void addMemberDeprecatedInfo(VariableElement field, Content contentTree) {
+ addDeprecatedInfo(field, contentTree);
+ }
+
+ /**
+ * Add the description text for this member.
+ *
+ * @param field the field to document.
+ * @param contentTree the tree to which the deprecated info will be added
+ */
+ public void addMemberDescription(VariableElement field, Content contentTree) {
+ if (!utils.getBody(field).isEmpty()) {
+ writer.addInlineComment(field, contentTree);
+ }
+ List extends DocTree> tags = utils.getBlockTags(field, DocTree.Kind.SERIAL);
+ if (!tags.isEmpty()) {
+ writer.addInlineComment(field, tags.get(0), contentTree);
+ }
+ }
+
+ /**
+ * Add the description text for this member represented by the tag.
+ *
+ * @param serialFieldTag the field to document (represented by tag)
+ * @param contentTree the tree to which the deprecated info will be added
+ */
+ public void addMemberDescription(VariableElement field, DocTree serialFieldTag, Content contentTree) {
+ CommentHelper ch = utils.getCommentHelper(field);
+ List extends DocTree> description = ch.getDescription(configuration, serialFieldTag);
+ if (!description.isEmpty()) {
+ Content serialFieldContent = new RawHtml(ch.getText(description));
+ Content div = HtmlTree.DIV(HtmlStyle.block, serialFieldContent);
+ contentTree.addContent(div);
+ }
+ }
+
+ /**
+ * Add the tag information for this member.
+ *
+ * @param field the field to document.
+ * @param contentTree the tree to which the member tags info will be added
+ */
+ public void addMemberTags(VariableElement field, Content contentTree) {
+ Content tagContent = new ContentBuilder();
+ TagletWriter.genTagOutput(configuration.tagletManager, field,
+ configuration.tagletManager.getCustomTaglets(field),
+ writer.getTagletWriterInstance(false), tagContent);
+ Content dlTags = new HtmlTree(HtmlTag.DL);
+ dlTags.addContent(tagContent);
+ contentTree.addContent(dlTags); // TODO: what if empty?
+ }
+
+ /**
+ * Check to see if overview details should be printed. If
+ * nocomment option set or if there is no text to be printed
+ * for deprecation info, comment or tags, do not print overview details.
+ *
+ * @param field the field to check overview details for.
+ * @return true if overview details need to be printed
+ */
+ public boolean shouldPrintOverview(VariableElement field) {
+ if (!configuration.nocomment) {
+ if(!utils.getBody(field).isEmpty() ||
+ writer.hasSerializationOverviewTags(field))
+ return true;
+ }
+ if (utils.isDeprecated(field))
+ return true;
+ return false;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialMethodWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialMethodWriter.java
new file mode 100644
index 00000000000..ca58a2e4dea
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlSerialMethodWriter.java
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter;
+import jdk.javadoc.internal.doclets.toolkit.taglets.TagletManager;
+import jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter;
+
+
+/**
+ * Generate serialized form for Serializable/Externalizable methods.
+ * Documentation denoted by the serialData
tag is processed.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Joe Fialli
+ * @author Bhavesh Patel (Modified)
+ */
+public class HtmlSerialMethodWriter extends MethodWriterImpl implements
+ SerializedFormWriter.SerialMethodWriter{
+
+ public HtmlSerialMethodWriter(SubWriterHolderWriter writer, TypeElement typeElement) {
+ super(writer, typeElement);
+ }
+
+ /**
+ * Return the header for serializable methods section.
+ *
+ * @return a content tree for the header
+ */
+ public Content getSerializableMethodsHeader() {
+ HtmlTree ul = new HtmlTree(HtmlTag.UL);
+ ul.addStyle(HtmlStyle.blockList);
+ return ul;
+ }
+
+ /**
+ * Return the header for serializable methods content section.
+ *
+ * @param isLastContent true if the cotent being documented is the last content.
+ * @return a content tree for the header
+ */
+ public Content getMethodsContentHeader(boolean isLastContent) {
+ HtmlTree li = new HtmlTree(HtmlTag.LI);
+ if (isLastContent)
+ li.addStyle(HtmlStyle.blockListLast);
+ else
+ li.addStyle(HtmlStyle.blockList);
+ return li;
+ }
+
+ /**
+ * Add serializable methods.
+ *
+ * @param heading the heading for the section
+ * @param serializableMethodContent the tree to be added to the serializable methods
+ * content tree
+ * @return a content tree for the serializable methods content
+ */
+ public Content getSerializableMethods(String heading, Content serializableMethodContent) {
+ Content headingContent = new StringContent(heading);
+ Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
+ headingContent);
+ Content li = HtmlTree.LI(HtmlStyle.blockList, serialHeading);
+ li.addContent(serializableMethodContent);
+ return li;
+ }
+
+ /**
+ * Return the no customization message.
+ *
+ * @param msg the message to be displayed
+ * @return no customization message content
+ */
+ public Content getNoCustomizationMsg(String msg) {
+ Content noCustomizationMsg = new StringContent(msg);
+ return noCustomizationMsg;
+ }
+
+ /**
+ * Add the member header.
+ *
+ * @param member the method document to be listed
+ * @param methodsContentTree the content tree to which the member header will be added
+ */
+ public void addMemberHeader(ExecutableElement member, Content methodsContentTree) {
+ methodsContentTree.addContent(getHead(member));
+ methodsContentTree.addContent(getSignature(member));
+ }
+
+ /**
+ * Add the deprecated information for this member.
+ *
+ * @param member the method to document.
+ * @param methodsContentTree the tree to which the deprecated info will be added
+ */
+ public void addDeprecatedMemberInfo(ExecutableElement member, Content methodsContentTree) {
+ addDeprecatedInfo(member, methodsContentTree);
+ }
+
+ /**
+ * Add the description text for this member.
+ *
+ * @param member the method to document.
+ * @param methodsContentTree the tree to which the deprecated info will be added
+ */
+ public void addMemberDescription(ExecutableElement member, Content methodsContentTree) {
+ addComment(member, methodsContentTree);
+ }
+
+ /**
+ * Add the tag information for this member.
+ *
+ * @param member the method to document.
+ * @param methodsContentTree the tree to which the member tags info will be added
+ */
+ public void addMemberTags(ExecutableElement member, Content methodsContentTree) {
+ Content tagContent = new ContentBuilder();
+ TagletManager tagletManager =
+ configuration.tagletManager;
+ TagletWriter.genTagOutput(tagletManager, member,
+ tagletManager.getSerializedFormTaglets(),
+ writer.getTagletWriterInstance(false), tagContent);
+ Content dlTags = new HtmlTree(HtmlTag.DL);
+ dlTags.addContent(tagContent);
+ methodsContentTree.addContent(dlTags);
+ if (name(member).compareTo("writeExternal") == 0
+ && utils.getSerialDataTrees(member).isEmpty()) {
+ serialWarning(member, "doclet.MissingSerialDataTag",
+ utils.getFullyQualifiedName(member.getEnclosingElement()), name(member));
+ }
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java
new file mode 100644
index 00000000000..dbb476920be
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java
@@ -0,0 +1,237 @@
+/*
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.util.List;
+
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.TypeMirror;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
+import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.Utils;
+import jdk.javadoc.internal.doclets.toolkit.util.links.LinkFactory;
+import jdk.javadoc.internal.doclets.toolkit.util.links.LinkInfo;
+
+import static jdk.javadoc.internal.doclets.formats.html.LinkInfoImpl.Kind.MEMBER_TYPE_PARAMS;
+
+/**
+ * A factory that returns a link given the information about it.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Jamie Ho
+ */
+public class LinkFactoryImpl extends LinkFactory {
+
+ private final HtmlDocletWriter m_writer;
+
+ public LinkFactoryImpl(HtmlDocletWriter writer) {
+ m_writer = writer;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Content newContent() {
+ return new ContentBuilder();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Content getClassLink(LinkInfo linkInfo) {
+ Configuration configuration = m_writer.configuration;
+ Utils utils = configuration.utils;
+ LinkInfoImpl classLinkInfo = (LinkInfoImpl) linkInfo;
+ boolean noLabel = linkInfo.label == null || linkInfo.label.isEmpty();
+ TypeElement typeElement = classLinkInfo.typeElement;
+ // Create a tool tip if we are linking to a class or interface. Don't
+ // create one if we are linking to a member.
+ String title = "";
+ if (classLinkInfo.where == null || classLinkInfo.where.length() == 0) {
+ boolean isTypeLink = classLinkInfo.type != null &&
+ utils.isTypeVariable(utils.getComponentType(classLinkInfo.type));
+ title = getClassToolTip(typeElement, isTypeLink);
+ }
+ Content label = classLinkInfo.getClassLinkLabel(m_writer.configuration);
+
+ Content link = new ContentBuilder();
+ if (utils.isIncluded(typeElement)) {
+ if (configuration.isGeneratedDoc(typeElement)) {
+ DocPath filename = getPath(classLinkInfo);
+ if (linkInfo.linkToSelf ||
+ !(DocPath.forName(utils, typeElement)).equals(m_writer.filename)) {
+ link.addContent(m_writer.getHyperLink(
+ filename.fragment(classLinkInfo.where),
+ label,
+ classLinkInfo.isStrong, classLinkInfo.styleName,
+ title, classLinkInfo.target));
+ if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
+ link.addContent(getTypeParameterLinks(linkInfo));
+ }
+ return link;
+ }
+ }
+ } else {
+ Content crossLink = m_writer.getCrossClassLink(
+ typeElement.getQualifiedName().toString(), classLinkInfo.where,
+ label, classLinkInfo.isStrong, classLinkInfo.styleName,
+ true);
+ if (crossLink != null) {
+ link.addContent(crossLink);
+ if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
+ link.addContent(getTypeParameterLinks(linkInfo));
+ }
+ return link;
+ }
+ }
+ // Can't link so just write label.
+ link.addContent(label);
+ if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
+ link.addContent(getTypeParameterLinks(linkInfo));
+ }
+ return link;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Content getTypeParameterLink(LinkInfo linkInfo, TypeMirror typeParam) {
+ LinkInfoImpl typeLinkInfo = new LinkInfoImpl(m_writer.configuration,
+ ((LinkInfoImpl) linkInfo).getContext(), typeParam);
+ typeLinkInfo.excludeTypeBounds = linkInfo.excludeTypeBounds;
+ typeLinkInfo.excludeTypeParameterLinks = linkInfo.excludeTypeParameterLinks;
+ typeLinkInfo.linkToSelf = linkInfo.linkToSelf;
+ typeLinkInfo.isJava5DeclarationLocation = false;
+ return getLink(typeLinkInfo);
+ }
+
+ @Override
+ protected Content getTypeAnnotationLink(LinkInfo linkInfo, AnnotationMirror annotation) {
+ throw new RuntimeException("Not implemented yet!");
+ }
+
+ @Override
+ public Content getTypeAnnotationLinks(LinkInfo linkInfo) {
+ Utils utils = ((LinkInfoImpl)linkInfo).utils;
+ ContentBuilder links = new ContentBuilder();
+ List extends AnnotationMirror> annotations;
+ if (utils.isAnnotated(linkInfo.type)) {
+ annotations = linkInfo.type.getAnnotationMirrors();
+ } else if (utils.isTypeVariable(linkInfo.type)) {
+ // TODO: use the context for now, and special case for Receiver_Types,
+ // which takes the default case.
+ switch (((LinkInfoImpl)linkInfo).context) {
+ case MEMBER_TYPE_PARAMS:
+ case EXECUTABLE_MEMBER_PARAM:
+ case CLASS_SIGNATURE:
+ Element element = utils.typeUtils.asElement(linkInfo.type);
+ annotations = element.getAnnotationMirrors();
+ break;
+ default:
+ annotations = linkInfo.type.getAnnotationMirrors();
+ break;
+ }
+
+ } else {
+ return links;
+ }
+
+ if (annotations.isEmpty())
+ return links;
+
+ List annos = m_writer.getAnnotations(0, annotations, false, linkInfo.isJava5DeclarationLocation);
+
+ boolean isFirst = true;
+ for (Content anno : annos) {
+ if (!isFirst) {
+ links.addContent(" ");
+ }
+ links.addContent(anno);
+ isFirst = false;
+ }
+ if (!annos.isEmpty()) {
+ links.addContent(" ");
+ }
+
+ return links;
+ }
+
+ /**
+ * Given a class, return the appropriate tool tip.
+ *
+ * @param typeElement the class to get the tool tip for.
+ * @return the tool tip for the appropriate class.
+ */
+ private String getClassToolTip(TypeElement typeElement, boolean isTypeLink) {
+ Configuration configuration = m_writer.configuration;
+ Utils utils = configuration.utils;
+ if (isTypeLink) {
+ return configuration.getText("doclet.Href_Type_Param_Title",
+ utils.getSimpleName(typeElement));
+ } else if (utils.isInterface(typeElement)){
+ return configuration.getText("doclet.Href_Interface_Title",
+ utils.getPackageName(utils.containingPackage(typeElement)));
+ } else if (utils.isAnnotationType(typeElement)) {
+ return configuration.getText("doclet.Href_Annotation_Title",
+ utils.getPackageName(utils.containingPackage(typeElement)));
+ } else if (utils.isEnum(typeElement)) {
+ return configuration.getText("doclet.Href_Enum_Title",
+ utils.getPackageName(utils.containingPackage(typeElement)));
+ } else {
+ return configuration.getText("doclet.Href_Class_Title",
+ utils.getPackageName(utils.containingPackage(typeElement)));
+ }
+ }
+
+ /**
+ * Return path to the given file name in the given package. So if the name
+ * passed is "Object.html" and the name of the package is "java.lang", and
+ * if the relative path is "../.." then returned string will be
+ * "../../java/lang/Object.html"
+ *
+ * @param linkInfo the information about the link.
+ */
+ private DocPath getPath(LinkInfoImpl linkInfo) {
+ if (linkInfo.context == LinkInfoImpl.Kind.PACKAGE_FRAME) {
+ //Not really necessary to do this but we want to be consistent
+ //with 1.4.2 output.
+ return DocPath.forName(linkInfo.utils, linkInfo.typeElement);
+ }
+ return m_writer.pathToRoot.resolve(DocPath.forClass(linkInfo.utils, linkInfo.typeElement));
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkInfoImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkInfoImpl.java
new file mode 100644
index 00000000000..01cd9508a1a
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkInfoImpl.java
@@ -0,0 +1,450 @@
+/*
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.TypeMirror;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.Utils;
+import jdk.javadoc.internal.doclets.toolkit.util.links.LinkInfo;
+
+
+/**
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ */
+public class LinkInfoImpl extends LinkInfo {
+
+ public enum Kind {
+ DEFAULT,
+
+ /**
+ * Indicate that the link appears in a class list.
+ */
+ ALL_CLASSES_FRAME,
+
+ /**
+ * Indicate that the link appears in a class documentation.
+ */
+ CLASS,
+
+ /**
+ * Indicate that the link appears in member documentation.
+ */
+ MEMBER,
+
+ /**
+ * Indicate that the link appears in class use documentation.
+ */
+ CLASS_USE,
+
+ /**
+ * Indicate that the link appears in index documentation.
+ */
+ INDEX,
+
+ /**
+ * Indicate that the link appears in constant value summary.
+ */
+ CONSTANT_SUMMARY,
+
+ /**
+ * Indicate that the link appears in serialized form documentation.
+ */
+ SERIALIZED_FORM,
+
+ /**
+ * Indicate that the link appears in serial member documentation.
+ */
+ SERIAL_MEMBER,
+
+ /**
+ * Indicate that the link appears in package documentation.
+ */
+ PACKAGE,
+
+ /**
+ * Indicate that the link appears in see tag documentation.
+ */
+ SEE_TAG,
+
+ /**
+ * Indicate that the link appears in value tag documentation.
+ */
+ VALUE_TAG,
+
+ /**
+ * Indicate that the link appears in tree documentation.
+ */
+ TREE,
+
+ /**
+ * Indicate that the link appears in a class list.
+ */
+ PACKAGE_FRAME,
+
+ /**
+ * The header in the class documentation.
+ */
+ CLASS_HEADER,
+
+ /**
+ * The signature in the class documentation.
+ */
+ CLASS_SIGNATURE,
+
+ /**
+ * The return type of a method.
+ */
+ RETURN_TYPE,
+
+ /**
+ * The return type of a method in a member summary.
+ */
+ SUMMARY_RETURN_TYPE,
+
+ /**
+ * The type of a method/constructor parameter.
+ */
+ EXECUTABLE_MEMBER_PARAM,
+
+ /**
+ * Super interface links.
+ */
+ SUPER_INTERFACES,
+
+ /**
+ * Implemented interface links.
+ */
+ IMPLEMENTED_INTERFACES,
+
+ /**
+ * Implemented class links.
+ */
+ IMPLEMENTED_CLASSES,
+
+ /**
+ * Subinterface links.
+ */
+ SUBINTERFACES,
+
+ /**
+ * Subclasses links.
+ */
+ SUBCLASSES,
+
+ /**
+ * The signature in the class documentation (implements/extends portion).
+ */
+ CLASS_SIGNATURE_PARENT_NAME,
+
+ /**
+ * The header for method documentation copied from parent.
+ */
+ EXECUTABLE_ELEMENT_COPY,
+
+ /**
+ * Method "specified by" link.
+ */
+ METHOD_SPECIFIED_BY,
+
+ /**
+ * Method "overrides" link.
+ */
+ METHOD_OVERRIDES,
+
+ /**
+ * Annotation link.
+ */
+ ANNOTATION,
+
+ /**
+ * The header for field documentation copied from parent.
+ */
+ VARIABLE_ELEMENT_COPY,
+
+ /**
+ * The parent nodes in the class tree.
+ */
+ CLASS_TREE_PARENT,
+
+ /**
+ * The type parameters of a method or constructor.
+ */
+ MEMBER_TYPE_PARAMS,
+
+ /**
+ * Indicate that the link appears in class use documentation.
+ */
+ CLASS_USE_HEADER,
+
+ /**
+ * The header for property documentation copied from parent.
+ */
+ PROPERTY_COPY,
+
+ /**
+ * A receiver type
+ */
+ RECEIVER_TYPE
+ }
+
+ public final ConfigurationImpl configuration;
+
+ /**
+ * The location of the link.
+ */
+ public Kind context = Kind.DEFAULT;
+
+ /**
+ * The value of the marker #.
+ */
+ public String where = "";
+
+ /**
+ * String style of text defined in style sheet.
+ */
+ public String styleName = "";
+
+ /**
+ * The value of the target.
+ */
+ public String target = "";
+ public final Utils utils;
+ /**
+ * Construct a LinkInfo object.
+ *
+ * @param configuration the configuration data for the doclet
+ * @param context the context of the link.
+ * @param ee the member to link to.
+ */
+ public LinkInfoImpl(ConfigurationImpl configuration, Kind context, ExecutableElement ee) {
+ this.configuration = configuration;
+ this.utils = configuration.utils;
+ this.executableElement = ee;
+ setContext(context);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Content newContent() {
+ return new ContentBuilder();
+ }
+
+ /**
+ * Construct a LinkInfo object.
+ *
+ * @param configuration the configuration data for the doclet
+ * @param context the context of the link.
+ * @param typeElement the class to link to.
+ */
+ public LinkInfoImpl(ConfigurationImpl configuration, Kind context, TypeElement typeElement) {
+ this.configuration = configuration;
+ this.utils = configuration.utils;
+ this.typeElement = typeElement;
+ setContext(context);
+ }
+
+ /**
+ * Construct a LinkInfo object.
+ *
+ * @param configuration the configuration data for the doclet
+ * @param context the context of the link.
+ * @param type the class to link to.
+ */
+ public LinkInfoImpl(ConfigurationImpl configuration, Kind context, TypeMirror type) {
+ this.configuration = configuration;
+ this.utils = configuration.utils;
+ this.type = type;
+ setContext(context);
+ }
+
+ /**
+ * Set the label for the link.
+ * @param label plain-text label for the link
+ */
+ public LinkInfoImpl label(String label) {
+ this.label = new StringContent(label);
+ return this;
+ }
+
+ /**
+ * Set the label for the link.
+ */
+ public LinkInfoImpl label(Content label) {
+ this.label = label;
+ return this;
+ }
+
+ /**
+ * Set whether or not the link should be strong.
+ */
+ public LinkInfoImpl strong(boolean strong) {
+ this.isStrong = strong;
+ return this;
+ }
+
+ /**
+ * Set the style to be used for the link.
+ * @param styleName String style of text defined in style sheet.
+ */
+ public LinkInfoImpl styleName(String styleName) {
+ this.styleName = styleName;
+ return this;
+ }
+
+ /**
+ * Set the target to be used for the link.
+ * @param styleName String style of text defined in style sheet.
+ */
+ public LinkInfoImpl target(String target) {
+ this.target = target;
+ return this;
+ }
+
+ /**
+ * Set whether or not this is a link to a varargs parameter.
+ */
+ public LinkInfoImpl varargs(boolean varargs) {
+ this.isVarArg = varargs;
+ return this;
+ }
+
+ /**
+ * Set the fragment specifier for the link.
+ */
+ public LinkInfoImpl where(String where) {
+ this.where = where;
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Kind getContext() {
+ return context;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * This method sets the link attributes to the appropriate values
+ * based on the context.
+ *
+ * @param c the context id to set.
+ */
+ public final void setContext(Kind c) {
+ //NOTE: Put context specific link code here.
+ switch (c) {
+ case ALL_CLASSES_FRAME:
+ case PACKAGE_FRAME:
+ case IMPLEMENTED_CLASSES:
+ case SUBCLASSES:
+ case EXECUTABLE_ELEMENT_COPY:
+ case VARIABLE_ELEMENT_COPY:
+ case PROPERTY_COPY:
+ case CLASS_USE_HEADER:
+ includeTypeInClassLinkLabel = false;
+ break;
+
+ case ANNOTATION:
+ excludeTypeParameterLinks = true;
+ excludeTypeBounds = true;
+ break;
+
+ case IMPLEMENTED_INTERFACES:
+ case SUPER_INTERFACES:
+ case SUBINTERFACES:
+ case CLASS_TREE_PARENT:
+ case TREE:
+ case CLASS_SIGNATURE_PARENT_NAME:
+ excludeTypeParameterLinks = true;
+ excludeTypeBounds = true;
+ includeTypeInClassLinkLabel = false;
+ includeTypeAsSepLink = true;
+ break;
+
+ case PACKAGE:
+ case CLASS_USE:
+ case CLASS_HEADER:
+ case CLASS_SIGNATURE:
+ case RECEIVER_TYPE:
+ excludeTypeParameterLinks = true;
+ includeTypeAsSepLink = true;
+ includeTypeInClassLinkLabel = false;
+ break;
+
+ case MEMBER_TYPE_PARAMS:
+ includeTypeAsSepLink = true;
+ includeTypeInClassLinkLabel = false;
+ break;
+
+ case RETURN_TYPE:
+ case SUMMARY_RETURN_TYPE:
+ excludeTypeBounds = true;
+ break;
+ case EXECUTABLE_MEMBER_PARAM:
+ excludeTypeBounds = true;
+ break;
+ }
+ context = c;
+ if (type != null &&
+ utils.isTypeVariable(type) &&
+ utils.isExecutableElement(utils.asTypeElement(type).getEnclosingElement())) {
+ excludeTypeParameterLinks = true;
+ }
+ }
+
+ /**
+ * Return true if this link is linkable and false if we can't link to the
+ * desired place.
+ *
+ * @return true if this link is linkable and false if we can't link to the
+ * desired place.
+ */
+ @Override
+ public boolean isLinkable() {
+ return configuration.utils.isLinkable(typeElement);
+ }
+
+ @Override
+ public String toString() {
+ return "LinkInfoImpl{" +
+ "context=" + context +
+ ", where=" + where +
+ ", styleName=" + styleName +
+ ", target=" + target +
+ super.toString() + '}';
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkOutputImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkOutputImpl.java
new file mode 100644
index 00000000000..f13d7e9a282
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkOutputImpl.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import jdk.javadoc.internal.doclets.toolkit.util.links.LinkOutput;
+
+/**
+ * Stores output of a link.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Jamie Ho
+ */
+public class LinkOutputImpl implements LinkOutput {
+
+ /**
+ * The output of the link.
+ */
+ public StringBuilder output;
+
+ /**
+ * Construct a new LinkOutputImpl.
+ */
+ public LinkOutputImpl() {
+ output = new StringBuilder();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void append(Object o) {
+ output.append(o instanceof String ?
+ (String) o : ((LinkOutputImpl)o).toString());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void insert(int offset, Object o) {
+ output.insert(offset, o.toString());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString() {
+ return output.toString();
+ }
+
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java
new file mode 100644
index 00000000000..40b00cdd1fd
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java
@@ -0,0 +1,457 @@
+/*
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.TypeMirror;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
+import jdk.javadoc.internal.doclets.toolkit.MethodWriter;
+import jdk.javadoc.internal.doclets.toolkit.util.ImplementedMethods;
+import jdk.javadoc.internal.doclets.toolkit.util.Utils;
+
+/**
+ * Writes method documentation in HTML format.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Robert Field
+ * @author Atul M Dambalkar
+ * @author Jamie Ho (rewrite)
+ * @author Bhavesh Patel (Modified)
+ */
+public class MethodWriterImpl extends AbstractExecutableMemberWriter
+ implements MethodWriter, MemberSummaryWriter {
+
+ /**
+ * Construct a new MethodWriterImpl.
+ *
+ * @param writer the writer for the class that the methods belong to.
+ * @param typeElement the class being documented.
+ */
+ public MethodWriterImpl(SubWriterHolderWriter writer, TypeElement typeElement) {
+ super(writer, typeElement);
+ }
+
+ /**
+ * Construct a new MethodWriterImpl.
+ *
+ * @param writer The writer for the class that the methods belong to.
+ */
+ public MethodWriterImpl(SubWriterHolderWriter writer) {
+ super(writer);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getMemberSummaryHeader(TypeElement typeElement, Content memberSummaryTree) {
+ memberSummaryTree.addContent(HtmlConstants.START_OF_METHOD_SUMMARY);
+ Content memberTree = writer.getMemberTreeHeader();
+ writer.addSummaryHeader(this, typeElement, memberTree);
+ return memberTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addMemberTree(Content memberSummaryTree, Content memberTree) {
+ writer.addMemberTree(memberSummaryTree, memberTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getMethodDetailsTreeHeader(TypeElement typeElement, Content memberDetailsTree) {
+ memberDetailsTree.addContent(HtmlConstants.START_OF_METHOD_DETAILS);
+ Content methodDetailsTree = writer.getMemberTreeHeader();
+ methodDetailsTree.addContent(writer.getMarkerAnchor(
+ SectionName.METHOD_DETAIL));
+ Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+ writer.methodDetailsLabel);
+ methodDetailsTree.addContent(heading);
+ return methodDetailsTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getMethodDocTreeHeader(ExecutableElement method, Content methodDetailsTree) {
+ String erasureAnchor;
+ if ((erasureAnchor = getErasureAnchor(method)) != null) {
+ methodDetailsTree.addContent(writer.getMarkerAnchor((erasureAnchor)));
+ }
+ methodDetailsTree.addContent(
+ writer.getMarkerAnchor(writer.getAnchor(method)));
+ Content methodDocTree = writer.getMemberTreeHeader();
+ Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+ heading.addContent(name(method));
+ methodDocTree.addContent(heading);
+ return methodDocTree;
+ }
+
+ /**
+ * Get the signature for the given method.
+ *
+ * @param method the method being documented.
+ * @return a content object for the signature
+ */
+ @Override
+ public Content getSignature(ExecutableElement method) {
+ Content pre = new HtmlTree(HtmlTag.PRE);
+ writer.addAnnotationInfo(method, pre);
+ int annotationLength = pre.charCount();
+ addModifiers(method, pre);
+ addTypeParameters(method, pre);
+ addReturnType(method, pre);
+ if (configuration.linksource) {
+ Content methodName = new StringContent(name(method));
+ writer.addSrcLink(method, methodName, pre);
+ } else {
+ addName(name(method), pre);
+ }
+ int indent = pre.charCount() - annotationLength;
+ addParameters(method, pre, indent);
+ addExceptions(method, pre, indent);
+ return pre;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addDeprecated(ExecutableElement method, Content methodDocTree) {
+ addDeprecatedInfo(method, methodDocTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addComments(TypeMirror holderType, ExecutableElement method, Content methodDocTree) {
+ TypeElement holder = utils.asTypeElement(holderType);
+ if (!utils.getBody(method).isEmpty()) {
+ if (holder.equals(typeElement) ||
+ !(utils.isPublic(holder) ||
+ utils.isLinkable(holder))) {
+ writer.addInlineComment(method, methodDocTree);
+ } else {
+ Content link =
+ writer.getDocLink(LinkInfoImpl.Kind.EXECUTABLE_ELEMENT_COPY,
+ holder, method,
+ utils.isIncluded(holder)
+ ? utils.getSimpleName(holder)
+ : utils.getFullyQualifiedName(holder),
+ false);
+ Content codelLink = HtmlTree.CODE(link);
+ Content descfrmLabel = HtmlTree.SPAN(HtmlStyle.descfrmTypeLabel,
+ utils.isClass(holder)
+ ? writer.descfrmClassLabel
+ : writer.descfrmInterfaceLabel);
+ descfrmLabel.addContent(writer.getSpace());
+ descfrmLabel.addContent(codelLink);
+ methodDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, descfrmLabel));
+ writer.addInlineComment(method, methodDocTree);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addTags(ExecutableElement method, Content methodDocTree) {
+ writer.addTagsInfo(method, methodDocTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getMethodDetails(Content methodDetailsTree) {
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ HtmlTree htmlTree = HtmlTree.SECTION(getMemberTree(methodDetailsTree));
+ return htmlTree;
+ }
+ return getMemberTree(methodDetailsTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getMethodDoc(Content methodDocTree,
+ boolean isLastContent) {
+ return getMemberTree(methodDocTree, isLastContent);
+ }
+
+ /**
+ * Close the writer.
+ */
+ @Override
+ public void close() throws IOException {
+ writer.close();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addSummaryLabel(Content memberTree) {
+ Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+ writer.getResource("doclet.Method_Summary"));
+ memberTree.addContent(label);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getTableSummary() {
+ return configuration.getText("doclet.Member_Table_Summary",
+ configuration.getText("doclet.Method_Summary"),
+ configuration.getText("doclet.methods"));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getCaption() {
+ return configuration.getResource("doclet.Methods");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List getSummaryTableHeader(Element member) {
+ List header = Arrays.asList(writer.getModifierTypeHeader(),
+ configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Method"),
+ configuration.getText("doclet.Description")));
+ return header;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addSummaryAnchor(TypeElement typeElement, Content memberTree) {
+ memberTree.addContent(writer.getMarkerAnchor(
+ SectionName.METHOD_SUMMARY));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) {
+ inheritedTree.addContent(writer.getMarkerAnchor(
+ SectionName.METHODS_INHERITANCE, configuration.getClassName(typeElement)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) {
+ Content classLink = writer.getPreQualifiedClassLink(
+ LinkInfoImpl.Kind.MEMBER, typeElement, false);
+ Content label = new StringContent(utils.isClass(typeElement)
+ ? configuration.getText("doclet.Methods_Inherited_From_Class")
+ : configuration.getText("doclet.Methods_Inherited_From_Interface"));
+ Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
+ label);
+ labelHeading.addContent(writer.getSpace());
+ labelHeading.addContent(classLink);
+ inheritedTree.addContent(labelHeading);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addSummaryType(Element member, Content tdSummaryType) {
+ ExecutableElement meth = (ExecutableElement)member;
+ addModifierAndType(meth, utils.getReturnType(meth), tdSummaryType);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected static void addOverridden(HtmlDocletWriter writer,
+ TypeMirror overriddenType, ExecutableElement method, Content dl) {
+ if (writer.configuration.nocomment) {
+ return;
+ }
+ Utils utils = writer.configuration().utils;
+ TypeElement holder = utils.getEnclosingTypeElement(method);
+ if (!(utils.isPublic(holder) ||
+ utils.isLinkable(holder))) {
+ //This is an implementation detail that should not be documented.
+ return;
+ }
+ if (utils.isIncluded(holder) && ! utils.isIncluded(method)) {
+ //The class is included but the method is not. That means that it
+ //is not visible so don't document this.
+ return;
+ }
+ Content label = writer.overridesLabel;
+ LinkInfoImpl.Kind context = LinkInfoImpl.Kind.METHOD_OVERRIDES;
+
+ if (method != null) {
+ if (utils.isAbstract(holder) && utils.isAbstract(method)){
+ //Abstract method is implemented from abstract class,
+ //not overridden
+ label = writer.specifiedByLabel;
+ context = LinkInfoImpl.Kind.METHOD_SPECIFIED_BY;
+ }
+ Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.overrideSpecifyLabel, label));
+ dl.addContent(dt);
+ Content overriddenTypeLink =
+ writer.getLink(new LinkInfoImpl(writer.configuration, context, overriddenType));
+ Content codeOverridenTypeLink = HtmlTree.CODE(overriddenTypeLink);
+ String name = method.getSimpleName().toString();
+ Content methlink = writer.getLink(
+ new LinkInfoImpl(writer.configuration, LinkInfoImpl.Kind.MEMBER,
+ holder)
+ .where(writer.getName(writer.getAnchor(method))).label(name));
+ Content codeMethLink = HtmlTree.CODE(methlink);
+ Content dd = HtmlTree.DD(codeMethLink);
+ dd.addContent(writer.getSpace());
+ dd.addContent(writer.getResource("doclet.in_class"));
+ dd.addContent(writer.getSpace());
+ dd.addContent(codeOverridenTypeLink);
+ dl.addContent(dd);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected static void addImplementsInfo(HtmlDocletWriter writer,
+ ExecutableElement method, Content dl) {
+ if (writer.configuration.nocomment) {
+ return;
+ }
+ Utils utils = writer.utils;
+ ImplementedMethods implementedMethodsFinder =
+ new ImplementedMethods(method, writer.configuration);
+ SortedSet implementedMethods =
+ new TreeSet<>(utils.makeOverrideUseComparator());
+ implementedMethods.addAll(implementedMethodsFinder.build());
+ for (ExecutableElement implementedMeth : implementedMethods) {
+ TypeMirror intfac = implementedMethodsFinder.getMethodHolder(implementedMeth);
+ intfac = utils.getDeclaredType(utils.getEnclosingTypeElement(method), intfac);
+ Content intfaclink = writer.getLink(new LinkInfoImpl(
+ writer.configuration, LinkInfoImpl.Kind.METHOD_SPECIFIED_BY, intfac));
+ Content codeIntfacLink = HtmlTree.CODE(intfaclink);
+ Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.overrideSpecifyLabel, writer.specifiedByLabel));
+ dl.addContent(dt);
+ Content methlink = writer.getDocLink(
+ LinkInfoImpl.Kind.MEMBER, implementedMeth,
+ implementedMeth.getSimpleName().toString(), false);
+ Content codeMethLink = HtmlTree.CODE(methlink);
+ Content dd = HtmlTree.DD(codeMethLink);
+ dd.addContent(writer.getSpace());
+ dd.addContent(writer.getResource("doclet.in_interface"));
+ dd.addContent(writer.getSpace());
+ dd.addContent(codeIntfacLink);
+ dl.addContent(dd);
+ }
+ }
+
+ /**
+ * Add the return type.
+ *
+ * @param method the method being documented.
+ * @param htmltree the content tree to which the return type will be added
+ */
+ protected void addReturnType(ExecutableElement method, Content htmltree) {
+ TypeMirror type = utils.getReturnType(method);
+ if (type != null) {
+ Content linkContent = writer.getLink(
+ new LinkInfoImpl(configuration, LinkInfoImpl.Kind.RETURN_TYPE, type));
+ htmltree.addContent(linkContent);
+ htmltree.addContent(writer.getSpace());
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
+ if (link) {
+ if (typeElement == null) {
+ return writer.getHyperLink(
+ SectionName.METHOD_SUMMARY,
+ writer.getResource("doclet.navMethod"));
+ } else {
+ return writer.getHyperLink(
+ SectionName.METHODS_INHERITANCE,
+ configuration.getClassName(typeElement), writer.getResource("doclet.navMethod"));
+ }
+ } else {
+ return writer.getResource("doclet.navMethod");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addNavDetailLink(boolean link, Content liNav) {
+ if (link) {
+ liNav.addContent(writer.getHyperLink(
+ SectionName.METHOD_DETAIL, writer.getResource("doclet.navMethod")));
+ } else {
+ liNav.addContent(writer.getResource("doclet.navMethod"));
+ }
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java
new file mode 100644
index 00000000000..c0828b8d5e2
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java
@@ -0,0 +1,241 @@
+/*
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
+
+/**
+ * Writes nested class documentation in HTML format.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Robert Field
+ * @author Atul M Dambalkar
+ * @author Jamie Ho (rewrite)
+ * @author Bhavesh Patel (Modified)
+ */
+public class NestedClassWriterImpl extends AbstractMemberWriter
+ implements MemberSummaryWriter {
+
+ public NestedClassWriterImpl(SubWriterHolderWriter writer, TypeElement typeElement) {
+ super(writer, typeElement);
+ }
+
+ public NestedClassWriterImpl(SubWriterHolderWriter writer) {
+ super(writer);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getMemberSummaryHeader(TypeElement typeElement,
+ Content memberSummaryTree) {
+ memberSummaryTree.addContent(HtmlConstants.START_OF_NESTED_CLASS_SUMMARY);
+ Content memberTree = writer.getMemberTreeHeader();
+ writer.addSummaryHeader(this, typeElement, memberTree);
+ return memberTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addMemberTree(Content memberSummaryTree, Content memberTree) {
+ writer.addMemberTree(memberSummaryTree, memberTree);
+ }
+
+ /**
+ * Close the writer.
+ */
+ @Override
+ public void close() throws IOException {
+ writer.close();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addSummaryLabel(Content memberTree) {
+ Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+ writer.getResource("doclet.Nested_Class_Summary"));
+ memberTree.addContent(label);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getTableSummary() {
+ return configuration.getText("doclet.Member_Table_Summary",
+ configuration.getText("doclet.Nested_Class_Summary"),
+ configuration.getText("doclet.nested_classes"));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getCaption() {
+ return configuration.getResource("doclet.Nested_Classes");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List getSummaryTableHeader(Element member) {
+ if (utils.isInterface(member)) {
+ return Arrays.asList(writer.getModifierTypeHeader(),
+ configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Interface"),
+ configuration.getText("doclet.Description")));
+
+ } else {
+ return Arrays.asList(writer.getModifierTypeHeader(),
+ configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Class"),
+ configuration.getText("doclet.Description")));
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addSummaryAnchor(TypeElement typeElement, Content memberTree) {
+ memberTree.addContent(writer.getMarkerAnchor(
+ SectionName.NESTED_CLASS_SUMMARY));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) {
+ inheritedTree.addContent(writer.getMarkerAnchor(
+ SectionName.NESTED_CLASSES_INHERITANCE,
+ utils.getFullyQualifiedName(typeElement)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) {
+ Content classLink = writer.getPreQualifiedClassLink(
+ LinkInfoImpl.Kind.MEMBER, typeElement, false);
+ Content label = new StringContent(utils.isInterface(typeElement)
+ ? configuration.getText("doclet.Nested_Classes_Interface_Inherited_From_Interface")
+ : configuration.getText("doclet.Nested_Classes_Interfaces_Inherited_From_Class"));
+ Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
+ label);
+ labelHeading.addContent(writer.getSpace());
+ labelHeading.addContent(classLink);
+ inheritedTree.addContent(labelHeading);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element member,
+ Content tdSummary) {
+ Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink,
+ writer.getLink(new LinkInfoImpl(configuration, context, (TypeElement)member)));
+ Content code = HtmlTree.CODE(memberLink);
+ tdSummary.addContent(code);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addInheritedSummaryLink(TypeElement typeElement, Element member, Content linksTree) {
+ linksTree.addContent(
+ writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER,
+ (TypeElement)member)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addSummaryType(Element member, Content tdSummaryType) {
+ addModifierAndType(member, null, tdSummaryType);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Content getDeprecatedLink(Element member) {
+ return writer.getQualifiedClassLink(LinkInfoImpl.Kind.MEMBER, member);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
+ if (link) {
+ if (typeElement == null) {
+ return writer.getHyperLink(
+ SectionName.NESTED_CLASS_SUMMARY,
+ writer.getResource("doclet.navNested"));
+ } else {
+ return writer.getHyperLink(
+ SectionName.NESTED_CLASSES_INHERITANCE,
+ utils.getFullyQualifiedName(typeElement), writer.getResource("doclet.navNested"));
+ }
+ } else {
+ return writer.getResource("doclet.navNested");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addNavDetailLink(boolean link, Content liNav) {
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java
new file mode 100644
index 00000000000..4925b55d00b
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+import java.util.*;
+
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+
+
+/**
+ * Class to generate file for each package contents in the left-hand bottom
+ * frame. This will list all the Class Kinds in the package. A click on any
+ * class-kind will update the right-hand frame with the clicked class-kind page.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Atul M Dambalkar
+ * @author Bhavesh Patel (Modified)
+ */
+public class PackageFrameWriter extends HtmlDocletWriter {
+
+ /**
+ * The package being documented.
+ */
+ private PackageElement packageElement;
+
+ /**
+ * The classes to be documented. Use this to filter out classes
+ * that will not be documented.
+ */
+ private SortedSet documentedClasses;
+
+ /**
+ * Constructor to construct PackageFrameWriter object and to generate
+ * "package-frame.html" file in the respective package directory.
+ * For example for package "java.lang" this will generate file
+ * "package-frame.html" file in the "java/lang" directory. It will also
+ * create "java/lang" directory in the current or the destination directory
+ * if it doesn't exist.
+ *
+ * @param configuration the configuration of the doclet.
+ * @param packageElement PackageElement under consideration.
+ */
+ public PackageFrameWriter(ConfigurationImpl configuration, PackageElement packageElement)
+ throws IOException {
+ super(configuration, DocPath.forPackage(packageElement).resolve(DocPaths.PACKAGE_FRAME));
+ this.packageElement = packageElement;
+ if (utils.getSpecifiedPackages().isEmpty()) {
+ documentedClasses = new TreeSet<>(utils.makeGeneralPurposeComparator());
+ documentedClasses.addAll(configuration.root.getIncludedClasses());
+ }
+ }
+
+ /**
+ * Generate a package summary page for the left-hand bottom frame. Construct
+ * the PackageFrameWriter object and then uses it generate the file.
+ *
+ * @param configuration the current configuration of the doclet.
+ * @param packageElement The package for which "pacakge-frame.html" is to be generated.
+ */
+ public static void generate(ConfigurationImpl configuration, PackageElement packageElement) {
+ PackageFrameWriter packgen;
+ try {
+ packgen = new PackageFrameWriter(configuration, packageElement);
+ String pkgName = configuration.utils.getPackageName(packageElement);
+ HtmlTree body = packgen.getBody(false, packgen.getWindowTitle(pkgName));
+ Content pkgNameContent = new StringContent(pkgName);
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
+ ? HtmlTree.MAIN()
+ : body;
+ Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar,
+ packgen.getTargetPackageLink(packageElement, "classFrame", pkgNameContent));
+ htmlTree.addContent(heading);
+ HtmlTree div = new HtmlTree(HtmlTag.DIV);
+ div.addStyle(HtmlStyle.indexContainer);
+ packgen.addClassListing(div);
+ htmlTree.addContent(div);
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ body.addContent(htmlTree);
+ }
+ packgen.printHtmlDocument(
+ configuration.metakeywords.getMetaKeywords(packageElement), false, body);
+ packgen.close();
+ } catch (IOException exc) {
+ configuration.standardmessage.error(
+ "doclet.exception_encountered",
+ exc.toString(), DocPaths.PACKAGE_FRAME.getPath());
+ throw new DocletAbortException(exc);
+ }
+ }
+
+ /**
+ * Add class listing for all the classes in this package. Divide class
+ * listing as per the class kind and generate separate listing for
+ * Classes, Interfaces, Exceptions and Errors.
+ *
+ * @param contentTree the content tree to which the listing will be added
+ */
+ protected void addClassListing(HtmlTree contentTree) {
+ Configuration config = configuration;
+ if (utils.isIncluded(packageElement)) {
+ addClassKindListing(utils.getInterfaces(packageElement),
+ getResource("doclet.Interfaces"), contentTree);
+ addClassKindListing(utils.getOrdinaryClasses(packageElement),
+ getResource("doclet.Classes"), contentTree);
+ addClassKindListing(utils.getEnums(packageElement),
+ getResource("doclet.Enums"), contentTree);
+ addClassKindListing(utils.getExceptions(packageElement),
+ getResource("doclet.Exceptions"), contentTree);
+ addClassKindListing(utils.getErrors(packageElement),
+ getResource("doclet.Errors"), contentTree);
+ addClassKindListing(utils.getAnnotationTypes(packageElement),
+ getResource("doclet.AnnotationTypes"), contentTree);
+ } else {
+ addClassKindListing(config.typeElementCatalog.interfaces(packageElement),
+ getResource("doclet.Interfaces"), contentTree);
+ addClassKindListing(config.typeElementCatalog.ordinaryClasses(packageElement),
+ getResource("doclet.Classes"), contentTree);
+ addClassKindListing(config.typeElementCatalog.enums(packageElement),
+ getResource("doclet.Enums"), contentTree);
+ addClassKindListing(config.typeElementCatalog.exceptions(packageElement),
+ getResource("doclet.Exceptions"), contentTree);
+ addClassKindListing(config.typeElementCatalog.errors(packageElement),
+ getResource("doclet.Errors"), contentTree);
+ addClassKindListing(config.typeElementCatalog.annotationTypes(packageElement),
+ getResource("doclet.AnnotationTypes"), contentTree);
+ }
+ }
+
+ /**
+ * Add specific class kind listing. Also add label to the listing.
+ *
+ * @param arr Array of specific class kinds, namely Class or Interface or Exception or Error
+ * @param labelContent content tree of the label to be added
+ * @param contentTree the content tree to which the class kind listing will be added
+ */
+ protected void addClassKindListing(Iterable list, Content labelContent,
+ HtmlTree contentTree) {
+ SortedSet tset = utils.filterOutPrivateClasses(list, configuration.javafx);
+ if(!tset.isEmpty()) {
+ boolean printedHeader = false;
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.SECTION))
+ ? HtmlTree.SECTION()
+ : contentTree;
+ HtmlTree ul = new HtmlTree(HtmlTag.UL);
+ ul.setTitle(labelContent);
+ for (TypeElement typeElement : tset) {
+ if (documentedClasses != null && !documentedClasses.contains(typeElement)) {
+ continue;
+ }
+ if (!utils.isCoreClass(typeElement) || !configuration.isGeneratedDoc(typeElement)) {
+ continue;
+ }
+ if (!printedHeader) {
+ Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+ true, labelContent);
+ htmlTree.addContent(heading);
+ printedHeader = true;
+ }
+ Content arr_i_name = new StringContent(utils.getSimpleName(typeElement));
+ if (utils.isInterface(typeElement))
+ arr_i_name = HtmlTree.SPAN(HtmlStyle.interfaceName, arr_i_name);
+ Content link = getLink(new LinkInfoImpl(configuration,
+ LinkInfoImpl.Kind.PACKAGE_FRAME, typeElement).label(arr_i_name).target("classFrame"));
+ Content li = HtmlTree.LI(link);
+ ul.addContent(li);
+ }
+ htmlTree.addContent(ul);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ contentTree.addContent(htmlTree);
+ }
+ }
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java
new file mode 100644
index 00000000000..064a93ce9d2
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import javax.lang.model.element.PackageElement;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+
+
+/**
+ * Generate the package index for the left-hand frame in the generated output.
+ * A click on the package name in this frame will update the page in the bottom
+ * left hand frame with the listing of contents of the clicked package.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Atul M Dambalkar
+ */
+public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
+
+ /**
+ * Construct the PackageIndexFrameWriter object.
+ *
+ * @param filename Name of the package index file to be generated.
+ */
+ public PackageIndexFrameWriter(ConfigurationImpl configuration,
+ DocPath filename) throws IOException {
+ super(configuration, filename);
+ }
+
+ /**
+ * Generate the package index file named "overview-frame.html".
+ * @throws DocletAbortException
+ */
+ public static void generate(ConfigurationImpl configuration) {
+ PackageIndexFrameWriter packgen;
+ DocPath filename = DocPaths.OVERVIEW_FRAME;
+ try {
+ packgen = new PackageIndexFrameWriter(configuration, filename);
+ packgen.buildPackageIndexFile("doclet.Window_Overview", false);
+ packgen.close();
+ } catch (IOException exc) {
+ configuration.standardmessage.error(
+ "doclet.exception_encountered",
+ exc.toString(), filename);
+ throw new DocletAbortException(exc);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void addPackagesList(Collection packages, String text,
+ String tableSummary, Content body) {
+ Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
+ packagesLabel);
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
+ ? HtmlTree.MAIN(HtmlStyle.indexContainer, heading)
+ : HtmlTree.DIV(HtmlStyle.indexContainer, heading);
+ HtmlTree ul = new HtmlTree(HtmlTag.UL);
+ ul.setTitle(packagesLabel);
+ for (PackageElement aPackage : packages) {
+ // Do not list the package if -nodeprecated option is set and the
+ // package is marked as deprecated.
+ if (aPackage != null &&
+ (!(configuration.nodeprecated && utils.isDeprecated(aPackage)))) {
+ ul.addContent(getPackage(aPackage));
+ }
+ }
+ htmlTree.addContent(ul);
+ body.addContent(htmlTree);
+ }
+
+ /**
+ * Returns each package name as a separate link.
+ *
+ * @param pe PackageElement
+ * @return content for the package link
+ */
+ protected Content getPackage(PackageElement pe) {
+ Content packageLinkContent;
+ Content packageLabel;
+ if (pe.isUnnamed()) {
+ packageLabel = new StringContent("");
+ packageLinkContent = getHyperLink(DocPaths.PACKAGE_FRAME,
+ packageLabel, "", "packageFrame");
+ } else {
+ packageLabel = getPackageLabel(pe.getQualifiedName().toString());
+ packageLinkContent = getHyperLink(pathString(pe,
+ DocPaths.PACKAGE_FRAME), packageLabel, "",
+ "packageFrame");
+ }
+ Content li = HtmlTree.LI(packageLinkContent);
+ return li;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void addNavigationBarHeader(Content body) {
+ Content headerContent;
+ if (configuration.packagesheader.length() > 0) {
+ headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
+ } else {
+ headerContent = new RawHtml(replaceDocRootDir(configuration.header));
+ }
+ Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+ HtmlStyle.bar, headerContent);
+ body.addContent(heading);
+ }
+
+ /**
+ * Do nothing as there is no overview information in this page.
+ */
+ protected void addOverviewHeader(Content body) {
+ }
+
+ /**
+ * Adds "All Classes" link for the top of the left-hand frame page to the
+ * documentation tree.
+ *
+ * @param ul the Content object to which the "All Classes" link should be added
+ */
+ protected void addAllClassesLink(Content ul) {
+ Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME,
+ allclassesLabel, "", "packageFrame");
+ Content li = HtmlTree.LI(linkContent);
+ ul.addContent(li);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void addNavigationBarFooter(Content body) {
+ Content p = HtmlTree.P(getSpace());
+ body.addContent(p);
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java
new file mode 100644
index 00000000000..c9a3a987038
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java
@@ -0,0 +1,274 @@
+/*
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+import java.util.*;
+
+import javax.lang.model.element.PackageElement;
+
+import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+import jdk.javadoc.internal.doclets.toolkit.util.Group;
+
+/**
+ * Generate the package index page "overview-summary.html" for the right-hand
+ * frame. A click on the package name on this page will update the same frame
+ * with the "package-summary.html" file for the clicked package.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Atul M Dambalkar
+ * @author Bhavesh Patel (Modified)
+ */
+public class PackageIndexWriter extends AbstractPackageIndexWriter {
+
+ /**
+ * Root of the program structure. Used for "overview" documentation.
+ */
+ private DocletEnvironment root;
+
+ /**
+ * Map representing the group of packages as specified on the command line.
+ *
+ * @see Group
+ */
+ private Map> groupPackageMap;
+
+ /**
+ * List to store the order groups as specified on the command line.
+ */
+ private List groupList;
+
+ /**
+ * HTML tree for main tag.
+ */
+ private HtmlTree htmlTree = HtmlTree.MAIN();
+
+ /**
+ * Construct the PackageIndexWriter. Also constructs the grouping
+ * information as provided on the command line by "-group" option. Stores
+ * the order of groups specified by the user.
+ *
+ * @see Group
+ */
+ public PackageIndexWriter(ConfigurationImpl configuration, DocPath filename) throws IOException {
+ super(configuration, filename);
+ this.root = configuration.root;
+ groupPackageMap = configuration.group.groupPackages(packages);
+ groupList = configuration.group.getGroupList();
+ }
+
+ /**
+ * Generate the package index page for the right-hand frame.
+ *
+ * @param configuration the current configuration of the doclet.
+ */
+ public static void generate(ConfigurationImpl configuration) {
+ PackageIndexWriter packgen;
+ DocPath filename = DocPaths.OVERVIEW_SUMMARY;
+ try {
+ packgen = new PackageIndexWriter(configuration, filename);
+ packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true);
+ packgen.close();
+ } catch (IOException exc) {
+ configuration.standardmessage.error(
+ "doclet.exception_encountered",
+ exc.toString(), filename);
+ throw new DocletAbortException(exc);
+ }
+ }
+
+ /**
+ * Depending upon the grouping information and their titles, add
+ * separate table indices for each package group.
+ *
+ * @param body the documentation tree to which the index will be added
+ */
+ protected void addIndex(Content body) {
+ for (String groupname : groupList) {
+ SortedSet list = groupPackageMap.get(groupname);
+ if (list != null && !list.isEmpty()) {
+ addIndexContents(list,
+ groupname, configuration.getText("doclet.Member_Table_Summary",
+ groupname, configuration.getText("doclet.packages")), body);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void addPackagesList(Collection packages, String text,
+ String tableSummary, Content body) {
+ Content table = (configuration.isOutputHtml5())
+ ? HtmlTree.TABLE(HtmlStyle.overviewSummary, getTableCaption(new RawHtml(text)))
+ : HtmlTree.TABLE(HtmlStyle.overviewSummary, tableSummary, getTableCaption(new RawHtml(text)));
+ table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
+ Content tbody = new HtmlTree(HtmlTag.TBODY);
+ addPackagesList(packages, tbody);
+ table.addContent(tbody);
+ Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table);
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ htmlTree.addContent(div);
+ } else {
+ body.addContent(div);
+ }
+ }
+
+ /**
+ * Adds list of packages in the index table. Generate link to each package.
+ *
+ * @param packages Packages to which link is to be generated
+ * @param tbody the documentation tree to which the list will be added
+ */
+ protected void addPackagesList(Collection packages, Content tbody) {
+ boolean altColor = true;
+ for (PackageElement pkg : packages) {
+ if (!pkg.isUnnamed()) {
+ if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) {
+ Content packageLinkContent = getPackageLink(pkg, getPackageName(pkg));
+ Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, packageLinkContent);
+ HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
+ tdSummary.addStyle(HtmlStyle.colLast);
+ addSummaryComment(pkg, tdSummary);
+ HtmlTree tr = HtmlTree.TR(tdPackage);
+ tr.addContent(tdSummary);
+ tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
+ tbody.addContent(tr);
+ }
+ }
+ altColor = !altColor;
+ }
+ }
+
+ /**
+ * Adds the overview summary comment for this documentation. Add one line
+ * summary at the top of the page and generate a link to the description,
+ * which is added at the end of this page.
+ *
+ * @param body the documentation tree to which the overview header will be added
+ */
+ protected void addOverviewHeader(Content body) {
+ addConfigurationTitle(body);
+ if (!utils.getBody(configuration.overviewElement).isEmpty()) {
+ HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV);
+ subTitleDiv.addStyle(HtmlStyle.subTitle);
+ addSummaryComment(configuration.overviewElement, subTitleDiv);
+ Content div = HtmlTree.DIV(HtmlStyle.header, subTitleDiv);
+ Content see = seeLabel;
+ see.addContent(" ");
+ Content descPara = HtmlTree.P(see);
+ Content descLink = getHyperLink(getDocLink(
+ SectionName.OVERVIEW_DESCRIPTION),
+ descriptionLabel, "", "");
+ descPara.addContent(descLink);
+ div.addContent(descPara);
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ htmlTree.addContent(div);
+ } else {
+ body.addContent(div);
+ }
+ }
+ }
+
+ /**
+ * Adds the overview comment as provided in the file specified by the
+ * "-overview" option on the command line.
+ *
+ * @param htmltree the documentation tree to which the overview comment will
+ * be added
+ */
+ protected void addOverviewComment(Content htmltree) {
+ if (!utils.getBody(configuration.overviewElement).isEmpty()) {
+ htmltree.addContent(getMarkerAnchor(SectionName.OVERVIEW_DESCRIPTION));
+ addInlineComment(configuration.overviewElement, htmltree);
+ }
+ }
+
+ /**
+ * Adds the tag information as provided in the file specified by the
+ * "-overview" option on the command line.
+ *
+ * @param body the documentation tree to which the overview will be added
+ */
+ protected void addOverview(Content body) throws IOException {
+ HtmlTree div = new HtmlTree(HtmlTag.DIV);
+ div.addStyle(HtmlStyle.contentContainer);
+ addOverviewComment(div);
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ htmlTree.addContent(div);
+ body.addContent(htmlTree);
+ } else {
+ body.addContent(div);
+ }
+ }
+
+ /**
+ * Adds the top text (from the -top option), the upper
+ * navigation bar, and then the title (from the"-title"
+ * option), at the top of page.
+ *
+ * @param body the documentation tree to which the navigation bar header will be added
+ */
+ protected void addNavigationBarHeader(Content body) {
+ Content htmlTree = (configuration.allowTag(HtmlTag.HEADER))
+ ? HtmlTree.HEADER()
+ : body;
+ addTop(htmlTree);
+ addNavLinks(true, htmlTree);
+ if (configuration.allowTag(HtmlTag.HEADER)) {
+ body.addContent(htmlTree);
+ }
+ }
+
+ /**
+ * Adds the lower navigation bar and the bottom text
+ * (from the -bottom option) at the bottom of page.
+ *
+ * @param body the documentation tree to which the navigation bar footer will be added
+ */
+ protected void addNavigationBarFooter(Content body) {
+ Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
+ ? HtmlTree.FOOTER()
+ : body;
+ addNavLinks(false, htmlTree);
+ addBottom(htmlTree);
+ if (configuration.allowTag(HtmlTag.FOOTER)) {
+ body.addContent(htmlTree);
+ }
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java
new file mode 100644
index 00000000000..9dac9a3bf18
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java
@@ -0,0 +1,237 @@
+/*
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+
+import javax.lang.model.element.PackageElement;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+
+
+/**
+ * Class to generate Tree page for a package. The name of the file generated is
+ * "package-tree.html" and it is generated in the respective package directory.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Atul M Dambalkar
+ * @author Bhavesh Patel (Modified)
+ */
+public class PackageTreeWriter extends AbstractTreeWriter {
+
+ /**
+ * Package for which tree is to be generated.
+ */
+ protected PackageElement packageElement;
+
+ /**
+ * The previous package name in the alpha-order list.
+ */
+ protected PackageElement prev;
+
+ /**
+ * The next package name in the alpha-order list.
+ */
+ protected PackageElement next;
+
+ /**
+ * Constructor.
+ * @param configuration the configuration
+ * @param path the docpath to generate files into
+ * @param packageElement the current package
+ * @param prev the previous package
+ * @param next the next package
+ * @throws IOException
+ * @throws DocletAbortException
+ */
+ public PackageTreeWriter(ConfigurationImpl configuration,
+ DocPath path,
+ PackageElement packageElement,
+ PackageElement prev, PackageElement next)
+ throws IOException {
+ super(configuration, path,
+ new ClassTree(configuration.typeElementCatalog.allClasses(packageElement), configuration));
+ this.packageElement = packageElement;
+ this.prev = prev;
+ this.next = next;
+ }
+
+ /**
+ * Construct a PackageTreeWriter object and then use it to generate the
+ * package tree page.
+ *
+ * @param configuration the configuration for this run.
+ * @param pkg Package for which tree file is to be generated.
+ * @param prev Previous package in the alpha-ordered list.
+ * @param next Next package in the alpha-ordered list.
+ * @param noDeprecated If true, do not generate any information for
+ * deprecated classe or interfaces.
+ * @throws DocletAbortException
+ */
+ public static void generate(ConfigurationImpl configuration,
+ PackageElement pkg, PackageElement prev,
+ PackageElement next, boolean noDeprecated) {
+ PackageTreeWriter packgen;
+ DocPath path = DocPath.forPackage(pkg).resolve(DocPaths.PACKAGE_TREE);
+ try {
+ packgen = new PackageTreeWriter(configuration, path, pkg,
+ prev, next);
+ packgen.generatePackageTreeFile();
+ packgen.close();
+ } catch (IOException exc) {
+ configuration.standardmessage.error(
+ "doclet.exception_encountered",
+ exc.toString(), path.getPath());
+ throw new DocletAbortException(exc);
+ }
+ }
+
+ /**
+ * Generate a separate tree file for each package.
+ * @throws java.io.IOException
+ */
+ protected void generatePackageTreeFile() throws IOException {
+ HtmlTree body = getPackageTreeHeader();
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
+ ? HtmlTree.MAIN()
+ : body;
+ Content headContent = getResource("doclet.Hierarchy_For_Package",
+ utils.getPackageName(packageElement));
+ Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false,
+ HtmlStyle.title, headContent);
+ Content div = HtmlTree.DIV(HtmlStyle.header, heading);
+ if (configuration.packages.size() > 1) {
+ addLinkToMainTree(div);
+ }
+ htmlTree.addContent(div);
+ HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
+ divTree.addStyle(HtmlStyle.contentContainer);
+ addTree(classtree.baseClasses(), "doclet.Class_Hierarchy", divTree);
+ addTree(classtree.baseInterfaces(), "doclet.Interface_Hierarchy", divTree);
+ addTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy", divTree);
+ addTree(classtree.baseEnums(), "doclet.Enum_Hierarchy", divTree, true);
+ htmlTree.addContent(divTree);
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ body.addContent(htmlTree);
+ }
+ HtmlTree tree = (configuration.allowTag(HtmlTag.FOOTER))
+ ? HtmlTree.FOOTER()
+ : body;
+ addNavLinks(false, tree);
+ addBottom(tree);
+ if (configuration.allowTag(HtmlTag.FOOTER)) {
+ body.addContent(tree);
+ }
+ printHtmlDocument(null, true, body);
+ }
+
+ /**
+ * Get the package tree header.
+ *
+ * @return a content tree for the header
+ */
+ protected HtmlTree getPackageTreeHeader() {
+ String packageName = packageElement.isUnnamed() ? "" : utils.getPackageName(packageElement);
+ String title = packageName + " " + configuration.getText("doclet.Window_Class_Hierarchy");
+ HtmlTree bodyTree = getBody(true, getWindowTitle(title));
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
+ ? HtmlTree.HEADER()
+ : bodyTree;
+ addTop(htmlTree);
+ addNavLinks(true, htmlTree);
+ if (configuration.allowTag(HtmlTag.HEADER)) {
+ bodyTree.addContent(htmlTree);
+ }
+ return bodyTree;
+ }
+
+ /**
+ * Add a link to the tree for all the packages.
+ *
+ * @param div the content tree to which the link will be added
+ */
+ protected void addLinkToMainTree(Content div) {
+ Content span = HtmlTree.SPAN(HtmlStyle.packageHierarchyLabel,
+ getResource("doclet.Package_Hierarchies"));
+ div.addContent(span);
+ HtmlTree ul = new HtmlTree (HtmlTag.UL);
+ ul.addStyle(HtmlStyle.horizontal);
+ ul.addContent(getNavLinkMainTree(configuration.getText("doclet.All_Packages")));
+ div.addContent(ul);
+ }
+
+ /**
+ * Get link for the previous package tree file.
+ *
+ * @return a content tree for the link
+ */
+ protected Content getNavLinkPrevious() {
+ if (prev == null) {
+ return getNavLinkPrevious(null);
+ } else {
+ DocPath path = DocPath.relativePath(packageElement, prev);
+ return getNavLinkPrevious(path.resolve(DocPaths.PACKAGE_TREE));
+ }
+ }
+
+ /**
+ * Get link for the next package tree file.
+ *
+ * @return a content tree for the link
+ */
+ protected Content getNavLinkNext() {
+ if (next == null) {
+ return getNavLinkNext(null);
+ } else {
+ DocPath path = DocPath.relativePath(packageElement, next);
+ return getNavLinkNext(path.resolve(DocPaths.PACKAGE_TREE));
+ }
+ }
+
+ /**
+ * Get link to the package summary page for the package of this tree.
+ *
+ * @return a content tree for the package link
+ */
+ protected Content getNavLinkPackage() {
+ Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
+ packageLabel);
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java
new file mode 100644
index 00000000000..3763e725892
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java
@@ -0,0 +1,339 @@
+/*
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+import java.util.*;
+
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+
+/**
+ * Generate package usage information.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Robert G. Field
+ * @author Bhavesh Patel (Modified)
+ */
+public class PackageUseWriter extends SubWriterHolderWriter {
+
+ final PackageElement packageElement;
+ final SortedMap> usingPackageToUsedClasses = new TreeMap<>();
+ protected HtmlTree mainTree = HtmlTree.MAIN();
+
+ /**
+ * Constructor.
+ *
+ * @param filename the file to be generated.
+ * @throws IOException
+ * @throws DocletAbortException
+ */
+ public PackageUseWriter(ConfigurationImpl configuration,
+ ClassUseMapper mapper, DocPath filename,
+ PackageElement pkgElement) throws IOException {
+ super(configuration, DocPath.forPackage(pkgElement).resolve(filename));
+ this.packageElement = pkgElement;
+
+ // by examining all classes in this package, find what packages
+ // use these classes - produce a map between using package and
+ // used classes.
+ for (TypeElement usedClass : utils.getEnclosedTypeElements(pkgElement)) {
+ Set usingClasses = mapper.classToClass.get(usedClass);
+ if (usingClasses != null) {
+ for (TypeElement usingClass : usingClasses) {
+ PackageElement usingPackage = utils.containingPackage(usingClass);
+ Set usedClasses = usingPackageToUsedClasses
+ .get(utils.getPackageName(usingPackage));
+ if (usedClasses == null) {
+ usedClasses = new TreeSet<>(utils.makeGeneralPurposeComparator());
+ usingPackageToUsedClasses.put(utils.getPackageName(usingPackage),
+ usedClasses);
+ }
+ usedClasses.add(usedClass);
+ }
+ }
+ }
+ }
+
+ /**
+ * Generate a class page.
+ *
+ * @param configuration the current configuration of the doclet.
+ * @param mapper the mapping of the class usage.
+ * @param pkgElement the package being documented.
+ */
+ public static void generate(ConfigurationImpl configuration,
+ ClassUseMapper mapper, PackageElement pkgElement) {
+ PackageUseWriter pkgusegen;
+ DocPath filename = DocPaths.PACKAGE_USE;
+ try {
+ pkgusegen = new PackageUseWriter(configuration, mapper, filename, pkgElement);
+ pkgusegen.generatePackageUseFile();
+ pkgusegen.close();
+ } catch (IOException exc) {
+ configuration.standardmessage.error(
+ "doclet.exception_encountered",
+ exc.toString(), filename);
+ throw new DocletAbortException(exc);
+ }
+ }
+
+ /**
+ * Generate the package use list.
+ */
+ protected void generatePackageUseFile() throws IOException {
+ HtmlTree body = getPackageUseHeader();
+ HtmlTree div = new HtmlTree(HtmlTag.DIV);
+ div.addStyle(HtmlStyle.contentContainer);
+ if (usingPackageToUsedClasses.isEmpty()) {
+ div.addContent(getResource("doclet.ClassUse_No.usage.of.0", utils.getPackageName(packageElement)));
+ } else {
+ addPackageUse(div);
+ }
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ mainTree.addContent(div);
+ body.addContent(mainTree);
+ } else {
+ body.addContent(div);
+ }
+ HtmlTree tree = (configuration.allowTag(HtmlTag.FOOTER))
+ ? HtmlTree.FOOTER()
+ : body;
+ addNavLinks(false, tree);
+ addBottom(tree);
+ if (configuration.allowTag(HtmlTag.FOOTER)) {
+ body.addContent(tree);
+ }
+ printHtmlDocument(null, true, body);
+ }
+
+ /**
+ * Add the package use information.
+ *
+ * @param contentTree the content tree to which the package use information will be added
+ */
+ protected void addPackageUse(Content contentTree) throws IOException {
+ HtmlTree ul = new HtmlTree(HtmlTag.UL);
+ ul.addStyle(HtmlStyle.blockList);
+ if (configuration.packages.size() > 1) {
+ addPackageList(ul);
+ }
+ addClassList(ul);
+ contentTree.addContent(ul);
+ }
+
+ /**
+ * Add the list of packages that use the given package.
+ *
+ * @param contentTree the content tree to which the package list will be added
+ */
+ protected void addPackageList(Content contentTree) throws IOException {
+ Content caption = getTableCaption(configuration.getResource(
+ "doclet.ClassUse_Packages.that.use.0",
+ getPackageLink(packageElement, utils.getPackageName(packageElement))));
+ Content table = (configuration.isOutputHtml5())
+ ? HtmlTree.TABLE(HtmlStyle.useSummary, caption)
+ : HtmlTree.TABLE(HtmlStyle.useSummary, useTableSummary, caption);
+ table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
+ Content tbody = new HtmlTree(HtmlTag.TBODY);
+ boolean altColor = true;
+ for (String pkgname: usingPackageToUsedClasses.keySet()) {
+ PackageElement pkg = utils.elementUtils.getPackageElement(pkgname);
+ HtmlTree tr = new HtmlTree(HtmlTag.TR);
+ tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
+ altColor = !altColor;
+ addPackageUse(pkg, tr);
+ tbody.addContent(tr);
+ }
+ table.addContent(tbody);
+ Content li = HtmlTree.LI(HtmlStyle.blockList, table);
+ contentTree.addContent(li);
+ }
+
+ /**
+ * Add the list of classes that use the given package.
+ *
+ * @param contentTree the content tree to which the class list will be added
+ */
+ protected void addClassList(Content contentTree) throws IOException {
+ List classTableHeader = Arrays.asList(
+ configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Class"),
+ configuration.getText("doclet.Description")));
+ for (String packageName : usingPackageToUsedClasses.keySet()) {
+ PackageElement usingPackage = utils.elementUtils.getPackageElement(packageName);
+ HtmlTree li = new HtmlTree(HtmlTag.LI);
+ li.addStyle(HtmlStyle.blockList);
+ if (usingPackage != null) {
+ li.addContent(getMarkerAnchor(utils.getPackageName(usingPackage)));
+ }
+ String tableSummary = configuration.getText("doclet.Use_Table_Summary",
+ configuration.getText("doclet.classes"));
+ Content caption = getTableCaption(configuration.getResource(
+ "doclet.ClassUse_Classes.in.0.used.by.1",
+ getPackageLink(packageElement, utils.getPackageName(packageElement)),
+ getPackageLink(usingPackage, utils.getPackageName(usingPackage))));
+ Content table = (configuration.isOutputHtml5())
+ ? HtmlTree.TABLE(HtmlStyle.useSummary, caption)
+ : HtmlTree.TABLE(HtmlStyle.useSummary, tableSummary, caption);
+ table.addContent(getSummaryTableHeader(classTableHeader, "col"));
+ Content tbody = new HtmlTree(HtmlTag.TBODY);
+ boolean altColor = true;
+ for (TypeElement te : usingPackageToUsedClasses.get(packageName)) {
+ HtmlTree tr = new HtmlTree(HtmlTag.TR);
+ tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
+ altColor = !altColor;
+ addClassRow(te, usingPackage, tr);
+ tbody.addContent(tr);
+ }
+ table.addContent(tbody);
+ li.addContent(table);
+ contentTree.addContent(li);
+ }
+ }
+
+ /**
+ * Add a row for the class that uses the given package.
+ *
+ * @param usedClass the class that uses the given package
+ * @param pkg the package to which the class belongs
+ * @param contentTree the content tree to which the row will be added
+ */
+ protected void addClassRow(TypeElement usedClass, PackageElement pkg,
+ Content contentTree) {
+ DocPath dp = pathString(usedClass,
+ DocPaths.CLASS_USE.resolve(DocPath.forName(utils, usedClass)));
+ StringContent stringContent = new StringContent(utils.getSimpleName(usedClass));
+ Content td = HtmlTree.TD(HtmlStyle.colOne,
+ getHyperLink(dp.fragment(getPackageAnchorName(pkg)), stringContent));
+ addIndexComment(usedClass, td);
+ contentTree.addContent(td);
+ }
+
+ /**
+ * Add the package use information.
+ *
+ * @param pkg the package that used the given package
+ * @param contentTree the content tree to which the information will be added
+ */
+ protected void addPackageUse(PackageElement pkg, Content contentTree) throws IOException {
+ Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst,
+ getHyperLink(utils.getPackageName(pkg),
+ new StringContent(utils.getPackageName(pkg))));
+ contentTree.addContent(tdFirst);
+ HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
+ tdLast.addStyle(HtmlStyle.colLast);
+ if (pkg != null && !pkg.isUnnamed()) {
+ addSummaryComment(pkg, tdLast);
+ } else {
+ tdLast.addContent(getSpace());
+ }
+ contentTree.addContent(tdLast);
+ }
+
+ /**
+ * Get the header for the package use listing.
+ *
+ * @return a content tree representing the package use header
+ */
+ protected HtmlTree getPackageUseHeader() {
+ String packageText = configuration.getText("doclet.Package");
+ String name = packageElement.isUnnamed() ? "" : utils.getPackageName(packageElement);
+ String title = configuration.getText("doclet.Window_ClassUse_Header", packageText, name);
+ HtmlTree bodyTree = getBody(true, getWindowTitle(title));
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
+ ? HtmlTree.HEADER()
+ : bodyTree;
+ addTop(htmlTree);
+ addNavLinks(true, htmlTree);
+ if (configuration.allowTag(HtmlTag.HEADER)) {
+ bodyTree.addContent(htmlTree);
+ }
+ ContentBuilder headContent = new ContentBuilder();
+ headContent.addContent(getResource("doclet.ClassUse_Title", packageText));
+ headContent.addContent(new HtmlTree(HtmlTag.BR));
+ headContent.addContent(name);
+ Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+ HtmlStyle.title, headContent);
+ Content div = HtmlTree.DIV(HtmlStyle.header, heading);
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ mainTree.addContent(div);
+ } else {
+ bodyTree.addContent(div);
+ }
+ return bodyTree;
+ }
+
+ /**
+ * Get this package link.
+ *
+ * @return a content tree for the package link
+ */
+ protected Content getNavLinkPackage() {
+ Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
+ packageLabel);
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+
+ /**
+ * Get the use link.
+ *
+ * @return a content tree for the use link
+ */
+ protected Content getNavLinkClassUse() {
+ Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, useLabel);
+ return li;
+ }
+
+ /**
+ * Get the tree link.
+ *
+ * @return a content tree for the tree link
+ */
+ protected Content getNavLinkTree() {
+ Content linkContent = getHyperLink(DocPaths.PACKAGE_TREE,
+ treeLabel);
+ Content li = HtmlTree.LI(linkContent);
+ return li;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java
new file mode 100644
index 00000000000..8689b0f76e8
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java
@@ -0,0 +1,377 @@
+/*
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+import java.util.*;
+
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+
+import com.sun.source.doctree.DocTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.PackageSummaryWriter;
+import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+
+/**
+ * Class to generate file for each package contents in the right-hand
+ * frame. This will list all the Class Kinds in the package. A click on any
+ * class-kind will update the frame with the clicked class-kind page.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Atul M Dambalkar
+ * @author Bhavesh Patel (Modified)
+ */
+public class PackageWriterImpl extends HtmlDocletWriter
+ implements PackageSummaryWriter {
+
+ /**
+ * The prev package name in the alpha-order list.
+ */
+ protected PackageElement prev;
+
+ /**
+ * The next package name in the alpha-order list.
+ */
+ protected PackageElement next;
+
+ /**
+ * The package being documented.
+ */
+ protected PackageElement packageElement;
+
+ /**
+ * The HTML tree for main tag.
+ */
+ protected HtmlTree mainTree = HtmlTree.MAIN();
+
+ /**
+ * The HTML tree for section tag.
+ */
+ protected HtmlTree sectionTree = HtmlTree.SECTION();
+
+ /**
+ * Constructor to construct PackageWriter object and to generate
+ * "package-summary.html" file in the respective package directory.
+ * For example for package "java.lang" this will generate file
+ * "package-summary.html" file in the "java/lang" directory. It will also
+ * create "java/lang" directory in the current or the destination directory
+ * if it doesn't exist.
+ *
+ * @param configuration the configuration of the doclet.
+ * @param packageElement PackageElement under consideration.
+ * @param prev Previous package in the sorted array.
+ * @param next Next package in the sorted array.
+ */
+ public PackageWriterImpl(ConfigurationImpl configuration,
+ PackageElement packageElement, PackageElement prev, PackageElement next)
+ throws IOException {
+ super(configuration, DocPath
+ .forPackage(packageElement)
+ .resolve(DocPaths.PACKAGE_SUMMARY));
+ this.prev = prev;
+ this.next = next;
+ this.packageElement = packageElement;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getPackageHeader(String heading) {
+ HtmlTree bodyTree = getBody(true, getWindowTitle(utils.getPackageName(packageElement)));
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
+ ? HtmlTree.HEADER()
+ : bodyTree;
+ addTop(htmlTree);
+ addNavLinks(true, htmlTree);
+ if (configuration.allowTag(HtmlTag.HEADER)) {
+ bodyTree.addContent(htmlTree);
+ }
+ HtmlTree div = new HtmlTree(HtmlTag.DIV);
+ div.addStyle(HtmlStyle.header);
+ Content annotationContent = new HtmlTree(HtmlTag.P);
+ addAnnotationInfo(packageElement, annotationContent);
+ div.addContent(annotationContent);
+ Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+ HtmlStyle.title, packageLabel);
+ tHeading.addContent(getSpace());
+ Content packageHead = new StringContent(heading);
+ tHeading.addContent(packageHead);
+ div.addContent(tHeading);
+ addDeprecationInfo(div);
+ if (!utils.getBody(packageElement).isEmpty() && !configuration.nocomment) {
+ HtmlTree docSummaryDiv = new HtmlTree(HtmlTag.DIV);
+ docSummaryDiv.addStyle(HtmlStyle.docSummary);
+ addSummaryComment(packageElement, docSummaryDiv);
+ div.addContent(docSummaryDiv);
+ Content space = getSpace();
+ Content descLink = getHyperLink(getDocLink(
+ SectionName.PACKAGE_DESCRIPTION),
+ descriptionLabel, "", "");
+ Content descPara = new HtmlTree(HtmlTag.P, seeLabel, space, descLink);
+ div.addContent(descPara);
+ }
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ mainTree.addContent(div);
+ } else {
+ bodyTree.addContent(div);
+ }
+ return bodyTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getContentHeader() {
+ HtmlTree div = new HtmlTree(HtmlTag.DIV);
+ div.addStyle(HtmlStyle.contentContainer);
+ return div;
+ }
+
+ /**
+ * Add the package deprecation information to the documentation tree.
+ *
+ * @param div the content tree to which the deprecation information will be added
+ */
+ public void addDeprecationInfo(Content div) {
+ List extends DocTree> deprs = utils.getBlockTags(packageElement, DocTree.Kind.DEPRECATED);
+ if (utils.isDeprecated(packageElement)) {
+ CommentHelper ch = utils.getCommentHelper(packageElement);
+ HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV);
+ deprDiv.addStyle(HtmlStyle.deprecatedContent);
+ Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
+ deprDiv.addContent(deprPhrase);
+ if (!deprs.isEmpty()) {
+ List extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0));
+ if (!commentTags.isEmpty()) {
+ addInlineDeprecatedComment(packageElement, deprs.get(0), deprDiv);
+ }
+ }
+ div.addContent(deprDiv);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getSummaryHeader() {
+ HtmlTree ul = new HtmlTree(HtmlTag.UL);
+ ul.addStyle(HtmlStyle.blockList);
+ return ul;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addClassesSummary(SortedSet classes, String label,
+ String tableSummary, List tableHeader, Content summaryContentTree) {
+ if(!classes.isEmpty()) {
+ Content caption = getTableCaption(new RawHtml(label));
+ Content table = (configuration.isOutputHtml5())
+ ? HtmlTree.TABLE(HtmlStyle.typeSummary, caption)
+ : HtmlTree.TABLE(HtmlStyle.typeSummary, tableSummary, caption);
+ table.addContent(getSummaryTableHeader(tableHeader, "col"));
+ Content tbody = new HtmlTree(HtmlTag.TBODY);
+ boolean altColor = false;
+ for (TypeElement klass : classes) {
+ altColor = !altColor;
+ if (!utils.isCoreClass(klass) ||
+ !configuration.isGeneratedDoc(klass)) {
+ continue;
+ }
+ Content classContent = getLink(new LinkInfoImpl(
+ configuration, LinkInfoImpl.Kind.PACKAGE, klass));
+ Content tdClass = HtmlTree.TD(HtmlStyle.colFirst, classContent);
+ HtmlTree tr = HtmlTree.TR(tdClass);
+ tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
+
+ HtmlTree tdClassDescription = new HtmlTree(HtmlTag.TD);
+ tdClassDescription.addStyle(HtmlStyle.colLast);
+ if (utils.isDeprecated(klass)) {
+ tdClassDescription.addContent(deprecatedLabel);
+ List extends DocTree> tags = utils.getDeprecatedTrees(klass);
+ if (!tags.isEmpty()) {
+ addSummaryDeprecatedComment(klass, tags.get(0), tdClassDescription);
+ }
+ } else {
+ addSummaryComment(klass, tdClassDescription);
+ }
+ tr.addContent(tdClassDescription);
+ tbody.addContent(tr);
+ }
+ table.addContent(tbody);
+ Content li = HtmlTree.LI(HtmlStyle.blockList, table);
+ summaryContentTree.addContent(li);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addPackageDescription(Content packageContentTree) {
+ if (!utils.getBody(packageElement).isEmpty()) {
+ packageContentTree.addContent(
+ getMarkerAnchor(SectionName.PACKAGE_DESCRIPTION));
+ Content h2Content = new StringContent(
+ configuration.getText("doclet.Package_Description",
+ packageElement.isUnnamed() ? "" : utils.getPackageName(packageElement)));
+ Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, h2Content);
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ sectionTree.addContent(heading);
+ addInlineComment(packageElement, sectionTree);
+ } else {
+ packageContentTree.addContent(heading);
+ addInlineComment(packageElement, packageContentTree);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addPackageTags(Content packageContentTree) {
+ Content htmlTree = (configuration.allowTag(HtmlTag.SECTION))
+ ? sectionTree
+ : packageContentTree;
+ addTagsInfo(packageElement, htmlTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addPackageContent(Content contentTree, Content packageContentTree) {
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ packageContentTree.addContent(sectionTree);
+ mainTree.addContent(packageContentTree);
+ contentTree.addContent(mainTree);
+ } else {
+ contentTree.addContent(packageContentTree);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addPackageFooter(Content contentTree) {
+ Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
+ ? HtmlTree.FOOTER()
+ : contentTree;
+ addNavLinks(false, htmlTree);
+ addBottom(htmlTree);
+ if (configuration.allowTag(HtmlTag.FOOTER)) {
+ contentTree.addContent(htmlTree);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void printDocument(Content contentTree) throws IOException {
+ printHtmlDocument(configuration.metakeywords.getMetaKeywords(packageElement),
+ true, contentTree);
+ }
+
+ /**
+ * Get "Use" link for this pacakge in the navigation bar.
+ *
+ * @return a content tree for the class use link
+ */
+ protected Content getNavLinkClassUse() {
+ Content useLink = getHyperLink(DocPaths.PACKAGE_USE,
+ useLabel, "", "");
+ Content li = HtmlTree.LI(useLink);
+ return li;
+ }
+
+ /**
+ * Get "PREV PACKAGE" link in the navigation bar.
+ *
+ * @return a content tree for the previous link
+ */
+ public Content getNavLinkPrevious() {
+ Content li;
+ if (prev == null) {
+ li = HtmlTree.LI(prevpackageLabel);
+ } else {
+ DocPath path = DocPath.relativePath(packageElement, prev);
+ li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY),
+ prevpackageLabel, "", ""));
+ }
+ return li;
+ }
+
+ /**
+ * Get "NEXT PACKAGE" link in the navigation bar.
+ *
+ * @return a content tree for the next link
+ */
+ public Content getNavLinkNext() {
+ Content li;
+ if (next == null) {
+ li = HtmlTree.LI(nextpackageLabel);
+ } else {
+ DocPath path = DocPath.relativePath(packageElement, next);
+ li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY),
+ nextpackageLabel, "", ""));
+ }
+ return li;
+ }
+
+ /**
+ * Get "Tree" link in the navigation bar. This will be link to the package
+ * tree file.
+ *
+ * @return a content tree for the tree link
+ */
+ protected Content getNavLinkTree() {
+ Content useLink = getHyperLink(DocPaths.PACKAGE_TREE,
+ treeLabel, "", "");
+ Content li = HtmlTree.LI(useLink);
+ return li;
+ }
+
+ /**
+ * Highlight "Package" in the navigation bar, as this is the package page.
+ *
+ * @return a content tree for the package link
+ */
+ protected Content getNavLinkPackage() {
+ Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, packageLabel);
+ return li;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java
new file mode 100644
index 00000000000..3a1eebc23cf
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java
@@ -0,0 +1,369 @@
+/*
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
+import jdk.javadoc.internal.doclets.toolkit.PropertyWriter;
+
+
+/**
+ * Writes property documentation in HTML format.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Robert Field
+ * @author Atul M Dambalkar
+ * @author Jamie Ho (rewrite)
+ * @author Bhavesh Patel (Modified)
+ */
+public class PropertyWriterImpl extends AbstractMemberWriter
+ implements PropertyWriter, MemberSummaryWriter {
+
+ public PropertyWriterImpl(SubWriterHolderWriter writer, TypeElement typeElement) {
+ super(writer, typeElement);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getMemberSummaryHeader(TypeElement typeElement,
+ Content memberSummaryTree) {
+ memberSummaryTree.addContent(HtmlConstants.START_OF_PROPERTY_SUMMARY);
+ Content memberTree = writer.getMemberTreeHeader();
+ writer.addSummaryHeader(this, typeElement, memberTree);
+ return memberTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addMemberTree(Content memberSummaryTree, Content memberTree) {
+ writer.addMemberTree(memberSummaryTree, memberTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getPropertyDetailsTreeHeader(TypeElement typeElement,
+ Content memberDetailsTree) {
+ memberDetailsTree.addContent(HtmlConstants.START_OF_PROPERTY_DETAILS);
+ Content propertyDetailsTree = writer.getMemberTreeHeader();
+ propertyDetailsTree.addContent(writer.getMarkerAnchor(
+ SectionName.PROPERTY_DETAIL));
+ Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
+ writer.propertyDetailsLabel);
+ propertyDetailsTree.addContent(heading);
+ return propertyDetailsTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getPropertyDocTreeHeader(ExecutableElement property,
+ Content propertyDetailsTree) {
+ propertyDetailsTree.addContent(
+ writer.getMarkerAnchor(name(property)));
+ Content propertyDocTree = writer.getMemberTreeHeader();
+ Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
+ heading.addContent(utils.getPropertyLabel(name(property)));
+ propertyDocTree.addContent(heading);
+ return propertyDocTree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getSignature(ExecutableElement property) {
+ Content pre = new HtmlTree(HtmlTag.PRE);
+ writer.addAnnotationInfo(property, pre);
+ addModifiers(property, pre);
+ Content propertylink = writer.getLink(new LinkInfoImpl(
+ configuration, LinkInfoImpl.Kind.MEMBER,
+ utils.getReturnType(property)));
+ pre.addContent(propertylink);
+ pre.addContent(" ");
+ if (configuration.linksource) {
+ Content propertyName = new StringContent(name(property));
+ writer.addSrcLink(property, propertyName, pre);
+ } else {
+ addName(name(property), pre);
+ }
+ return pre;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addDeprecated(ExecutableElement property, Content propertyDocTree) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addComments(ExecutableElement property, Content propertyDocTree) {
+ TypeElement holder = (TypeElement)property.getEnclosingElement();
+ if (!utils.getBody(property).isEmpty()) {
+ if (holder.equals(typeElement) ||
+ (!utils.isPublic(holder) || utils.isLinkable(holder))) {
+ writer.addInlineComment(property, propertyDocTree);
+ } else {
+ Content link =
+ writer.getDocLink(LinkInfoImpl.Kind.PROPERTY_COPY,
+ holder, property,
+ utils.isIncluded(holder)
+ ? holder.toString() : utils.getFullyQualifiedName(holder),
+ false);
+ Content codeLink = HtmlTree.CODE(link);
+ Content descfrmLabel = HtmlTree.SPAN(HtmlStyle.descfrmTypeLabel,
+ utils.isClass(holder)
+ ? writer.descfrmClassLabel
+ : writer.descfrmInterfaceLabel);
+ descfrmLabel.addContent(writer.getSpace());
+ descfrmLabel.addContent(codeLink);
+ propertyDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, descfrmLabel));
+ writer.addInlineComment(property, propertyDocTree);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addTags(ExecutableElement property, Content propertyDocTree) {
+ writer.addTagsInfo(property, propertyDocTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getPropertyDetails(Content propertyDetailsTree) {
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ HtmlTree htmlTree = HtmlTree.SECTION(getMemberTree(propertyDetailsTree));
+ return htmlTree;
+ }
+ return getMemberTree(propertyDetailsTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getPropertyDoc(Content propertyDocTree,
+ boolean isLastContent) {
+ return getMemberTree(propertyDocTree, isLastContent);
+ }
+
+ /**
+ * Close the writer.
+ */
+ @Override
+ public void close() throws IOException {
+ writer.close();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addSummaryLabel(Content memberTree) {
+ Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
+ writer.getResource("doclet.Property_Summary"));
+ memberTree.addContent(label);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getTableSummary() {
+ return configuration.getText("doclet.Member_Table_Summary",
+ configuration.getText("doclet.Property_Summary"),
+ configuration.getText("doclet.properties"));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Content getCaption() {
+ return configuration.getResource("doclet.Properties");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List getSummaryTableHeader(Element member) {
+ List header = Arrays.asList(configuration.getText("doclet.Type"),
+ configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Property"),
+ configuration.getText("doclet.Description")));
+ return header;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addSummaryAnchor(TypeElement typeElement, Content memberTree) {
+ memberTree.addContent(writer.getMarkerAnchor(
+ SectionName.PROPERTY_SUMMARY));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addInheritedSummaryAnchor(TypeElement typeElement, Content inheritedTree) {
+ inheritedTree.addContent(writer.getMarkerAnchor(
+ SectionName.PROPERTIES_INHERITANCE,
+ configuration.getClassName(typeElement)));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) {
+ Content classLink = writer.getPreQualifiedClassLink(
+ LinkInfoImpl.Kind.MEMBER, typeElement, false);
+ Content label = new StringContent(
+ utils.isClass(typeElement)
+ ? configuration.getText("doclet.Properties_Inherited_From_Class")
+ : configuration.getText("doclet.Properties_Inherited_From_Interface"));
+ Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
+ label);
+ labelHeading.addContent(writer.getSpace());
+ labelHeading.addContent(classLink);
+ inheritedTree.addContent(labelHeading);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element member,
+ Content tdSummary) {
+ Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink,
+ writer.getDocLink(context, typeElement,
+ member,
+ utils.getPropertyLabel(name(member)),
+ false,
+ true));
+
+ Content code = HtmlTree.CODE(memberLink);
+ tdSummary.addContent(code);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addInheritedSummaryLink(TypeElement typeElement, Element member, Content linksTree) {
+ String mname = name(member);
+ Content content = writer.getDocLink(LinkInfoImpl.Kind.MEMBER, typeElement, member,
+ utils.isProperty(mname) ? utils.getPropertyName(mname) : mname,
+ false, true);
+ linksTree.addContent(content);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addSummaryType(Element member, Content tdSummaryType) {
+ addModifierAndType(member, utils.getReturnType((ExecutableElement)member), tdSummaryType);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Content getDeprecatedLink(Element member) {
+ return writer.getDocLink(LinkInfoImpl.Kind.MEMBER, member,
+ utils.getFullyQualifiedName(member));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
+ if (link) {
+ if (typeElement == null) {
+ return writer.getHyperLink(
+ SectionName.PROPERTY_SUMMARY,
+ writer.getResource("doclet.navProperty"));
+ } else {
+ return writer.getHyperLink(
+ SectionName.PROPERTIES_INHERITANCE,
+ configuration.getClassName(typeElement), writer.getResource("doclet.navProperty"));
+ }
+ } else {
+ return writer.getResource("doclet.navProperty");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void addNavDetailLink(boolean link, Content liNav) {
+ if (link) {
+ liNav.addContent(writer.getHyperLink(
+ SectionName.PROPERTY_DETAIL,
+ writer.getResource("doclet.navProperty")));
+ } else {
+ liNav.addContent(writer.getResource("doclet.navProperty"));
+ }
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SearchIndexItem.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SearchIndexItem.java
new file mode 100644
index 00000000000..d260a9b5538
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SearchIndexItem.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+/**
+ * Index item for search.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ */
+public class SearchIndexItem {
+
+ private String label = "";
+ private String url = "";
+ private String category = "";
+ private String containingPackage = "";
+ private String containingClass = "";
+ private String holder = "";
+ private String description = "";
+
+ public void setLabel(String l) {
+ label = l;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setUrl(String u) {
+ url = u;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setContainingPackage(String p) {
+ containingPackage = p;
+ }
+
+ public void setContainingClass(String c) {
+ containingClass = c;
+ }
+
+ public void setCategory(String c) {
+ category = c;
+ }
+
+ public void setHolder(String h) {
+ holder = h;
+ }
+
+ public String getHolder() {
+ return holder;
+ }
+
+ public void setDescription(String d) {
+ description = d;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String toString() {
+ StringBuilder item = new StringBuilder("");
+ if (category.equals("Packages")) {
+ item.append("{")
+ .append("\"l\":\"").append(label).append("\"")
+ .append("}");
+ } else if (category.equals("Types")) {
+ item.append("{")
+ .append("\"p\":\"").append(containingPackage).append("\",")
+ .append("\"l\":\"").append(label).append("\"")
+ .append("}");
+ } else if (category.equals("Members")) {
+ item.append("{")
+ .append("\"p\":\"").append(containingPackage).append("\",")
+ .append("\"c\":\"").append(containingClass).append("\",")
+ .append("\"l\":\"").append(label).append("\"");
+ if (!url.equals("")) {
+ item.append(",\"url\":\"").append(url).append("\"");
+ }
+ item.append("}");
+ } else {
+ item.append("{")
+ .append("\"l\":\"").append(label).append("\",")
+ .append("\"h\":\"").append(holder).append("\",");
+ if (!description.equals("")) {
+ item.append("\"d\":\"").append(description).append("\",");
+ }
+ item.append("\"u\":\"").append(url).append("\"")
+ .append("}");
+ }
+ return item.toString();
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SectionName.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SectionName.java
new file mode 100644
index 00000000000..a9ff3e50311
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SectionName.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+/**
+ * Enum representing various section names of generated API documentation.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Bhavesh Patel
+ */
+public enum SectionName {
+
+ ANNOTATION_TYPE_ELEMENT_DETAIL("annotation.type.element.detail"),
+ ANNOTATION_TYPE_FIELD_DETAIL("annotation.type.field.detail"),
+ ANNOTATION_TYPE_FIELD_SUMMARY("annotation.type.field.summary"),
+ ANNOTATION_TYPE_OPTIONAL_ELEMENT_SUMMARY("annotation.type.optional.element.summary"),
+ ANNOTATION_TYPE_REQUIRED_ELEMENT_SUMMARY("annotation.type.required.element.summary"),
+ CONSTRUCTOR_DETAIL("constructor.detail"),
+ CONSTRUCTOR_SUMMARY("constructor.summary"),
+ ENUM_CONSTANT_DETAIL("enum.constant.detail"),
+ ENUM_CONSTANTS_INHERITANCE("enum.constants.inherited.from.class."),
+ ENUM_CONSTANT_SUMMARY("enum.constant.summary"),
+ FIELD_DETAIL("field.detail"),
+ FIELDS_INHERITANCE("fields.inherited.from.class."),
+ FIELD_SUMMARY("field.summary"),
+ METHOD_DETAIL("method.detail"),
+ METHODS_INHERITANCE("methods.inherited.from.class."),
+ METHOD_SUMMARY("method.summary"),
+ NAVBAR_BOTTOM("navbar.bottom"),
+ NAVBAR_BOTTOM_FIRSTROW("navbar.bottom.firstrow"),
+ NAVBAR_TOP("navbar.top"),
+ NAVBAR_TOP_FIRSTROW("navbar.top.firstrow"),
+ NESTED_CLASSES_INHERITANCE("nested.classes.inherited.from.class."),
+ NESTED_CLASS_SUMMARY("nested.class.summary"),
+ OVERVIEW_DESCRIPTION("overview.description"),
+ PACKAGE_DESCRIPTION("package.description"),
+ PROPERTY_DETAIL("property.detail"),
+ PROPERTIES_INHERITANCE("properties.inherited.from.class."),
+ PROPERTY_SUMMARY("property.summary"),
+ SKIP_NAVBAR_BOTTOM("skip.navbar.bottom"),
+ SKIP_NAVBAR_TOP("skip.navbar.top"),
+ UNNAMED_PACKAGE_ANCHOR("unnamed.package");
+
+ private final String value;
+
+ SectionName(String sName) {
+ this.value = sName;
+ }
+
+ public String getName() {
+ return this.value;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java
new file mode 100644
index 00000000000..764810f3902
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java
@@ -0,0 +1,301 @@
+/*
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+import java.util.*;
+
+import javax.lang.model.element.TypeElement;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter;
+import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter.SerialFieldWriter;
+import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter.SerialMethodWriter;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+
+/**
+ * Generate the Serialized Form Information Page.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Atul M Dambalkar
+ */
+public class SerializedFormWriterImpl extends SubWriterHolderWriter
+ implements SerializedFormWriter {
+
+ Set visibleClasses;
+
+ /**
+ * HTML tree for main tag.
+ */
+ private HtmlTree mainTree = HtmlTree.MAIN();
+
+ /**
+ * @param configuration the configuration data for the doclet
+ * @throws IOException
+ * @throws DocletAbortException
+ */
+ public SerializedFormWriterImpl(ConfigurationImpl configuration)
+ throws IOException {
+ super(configuration, DocPaths.SERIALIZED_FORM);
+ visibleClasses = configuration.root.getIncludedClasses();
+ }
+
+ /**
+ * Get the given header.
+ *
+ * @param header the header to write
+ * @return the body content tree
+ */
+ public Content getHeader(String header) {
+ HtmlTree bodyTree = getBody(true, getWindowTitle(header));
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
+ ? HtmlTree.HEADER()
+ : bodyTree;
+ addTop(htmlTree);
+ addNavLinks(true, htmlTree);
+ if (configuration.allowTag(HtmlTag.HEADER)) {
+ bodyTree.addContent(htmlTree);
+ }
+ Content h1Content = new StringContent(header);
+ Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+ HtmlStyle.title, h1Content);
+ Content div = HtmlTree.DIV(HtmlStyle.header, heading);
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ mainTree.addContent(div);
+ } else {
+ bodyTree.addContent(div);
+ }
+ return bodyTree;
+ }
+
+ /**
+ * Get the serialized form summaries header.
+ *
+ * @return the serialized form summary header tree
+ */
+ public Content getSerializedSummariesHeader() {
+ HtmlTree ul = new HtmlTree(HtmlTag.UL);
+ ul.addStyle(HtmlStyle.blockList);
+ return ul;
+ }
+
+ /**
+ * Get the package serialized form header.
+ *
+ * @return the package serialized form header tree
+ */
+ public Content getPackageSerializedHeader() {
+ HtmlTree htmlTree;
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ htmlTree = HtmlTree.SECTION();
+ } else {
+ htmlTree = new HtmlTree(HtmlTag.LI);
+ htmlTree.addStyle(HtmlStyle.blockList);
+ }
+ return htmlTree;
+ }
+
+ /**
+ * Get the given package header.
+ *
+ * @param packageName the package header to write
+ * @return a content tree for the package header
+ */
+ public Content getPackageHeader(String packageName) {
+ Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
+ packageLabel);
+ heading.addContent(getSpace());
+ heading.addContent(packageName);
+ return heading;
+ }
+
+ /**
+ * Get the serialized class header.
+ *
+ * @return a content tree for the serialized class header
+ */
+ public Content getClassSerializedHeader() {
+ HtmlTree ul = new HtmlTree(HtmlTag.UL);
+ ul.addStyle(HtmlStyle.blockList);
+ return ul;
+ }
+
+ /**
+ * Checks if a class is generated and is visible.
+ *
+ * @param typeElement the class being processed.
+ * @return true if the class, that is being processed, is generated and is visible.
+ */
+ public boolean isVisibleClass(TypeElement typeElement) {
+ return visibleClasses.contains(typeElement) && configuration.isGeneratedDoc(typeElement);
+ }
+
+ /**
+ * Get the serializable class heading.
+ *
+ * @param typeElement the class being processed
+ * @return a content tree for the class header
+ */
+ public Content getClassHeader(TypeElement typeElement) {
+ Content classLink = (isVisibleClass(typeElement))
+ ? getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.DEFAULT, typeElement)
+ .label(configuration.getClassName(typeElement)))
+ : new StringContent(utils.getFullyQualifiedName(typeElement));
+ Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(
+ utils.getFullyQualifiedName(typeElement)));
+ Content superClassLink = typeElement.getSuperclass() != null
+ ? getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.SERIALIZED_FORM,
+ typeElement.getSuperclass()))
+ : null;
+
+ //Print the heading.
+ Content className = superClassLink == null ?
+ configuration.getResource(
+ "doclet.Class_0_implements_serializable", classLink) :
+ configuration.getResource(
+ "doclet.Class_0_extends_implements_serializable", classLink,
+ superClassLink);
+ li.addContent(HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
+ className));
+ return li;
+ }
+
+ /**
+ * Get the serial UID info header.
+ *
+ * @return a content tree for the serial uid info header
+ */
+ public Content getSerialUIDInfoHeader() {
+ HtmlTree dl = new HtmlTree(HtmlTag.DL);
+ dl.addStyle(HtmlStyle.nameValue);
+ return dl;
+ }
+
+ /**
+ * Adds the serial UID info.
+ *
+ * @param header the header that will show up before the UID.
+ * @param serialUID the serial UID to print.
+ * @param serialUidTree the serial UID content tree to which the serial UID
+ * content will be added
+ */
+ public void addSerialUIDInfo(String header, String serialUID,
+ Content serialUidTree) {
+ Content headerContent = new StringContent(header);
+ serialUidTree.addContent(HtmlTree.DT(headerContent));
+ Content serialContent = new StringContent(serialUID);
+ serialUidTree.addContent(HtmlTree.DD(serialContent));
+ }
+
+ /**
+ * Get the class serialize content header.
+ *
+ * @return a content tree for the class serialize content header
+ */
+ public Content getClassContentHeader() {
+ HtmlTree ul = new HtmlTree(HtmlTag.UL);
+ ul.addStyle(HtmlStyle.blockList);
+ return ul;
+ }
+
+ /**
+ * Get the serialized content tree section.
+ *
+ * @param serializedTreeContent the serialized content tree to be added
+ * @return a div content tree
+ */
+ public Content getSerializedContent(Content serializedTreeContent) {
+ HtmlTree divContent = HtmlTree.DIV(HtmlStyle.serializedFormContainer,
+ serializedTreeContent);
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ mainTree.addContent(divContent);
+ return mainTree;
+ } else {
+ return divContent;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addPackageSerializedTree(Content serializedSummariesTree,
+ Content packageSerializedTree) {
+ serializedSummariesTree.addContent((configuration.allowTag(HtmlTag.SECTION))
+ ? HtmlTree.LI(HtmlStyle.blockList, packageSerializedTree)
+ : packageSerializedTree);
+ }
+
+ /**
+ * Add the footer.
+ *
+ * @param serializedTree the serialized tree to be added
+ */
+ public void addFooter(Content serializedTree) {
+ Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER))
+ ? HtmlTree.FOOTER()
+ : serializedTree;
+ addNavLinks(false, htmlTree);
+ addBottom(htmlTree);
+ if (configuration.allowTag(HtmlTag.FOOTER)) {
+ serializedTree.addContent(htmlTree);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void printDocument(Content serializedTree) throws IOException {
+ printHtmlDocument(null, true, serializedTree);
+ }
+
+ /**
+ * Return an instance of a SerialFieldWriter.
+ *
+ * @return an instance of a SerialFieldWriter.
+ */
+ public SerialFieldWriter getSerialFieldWriter(TypeElement typeElement) {
+ return new HtmlSerialFieldWriter(this, typeElement);
+ }
+
+ /**
+ * Return an instance of a SerialMethodWriter.
+ *
+ * @return an instance of a SerialMethodWriter.
+ */
+ public SerialMethodWriter getSerialMethodWriter(TypeElement typeElement) {
+ return new HtmlSerialMethodWriter(this, typeElement);
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java
new file mode 100644
index 00000000000..81189d6ee61
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+import java.util.*;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder;
+
+
+/**
+ * Generate only one index file for all the Member Names with Indexing in
+ * Unicode Order. The name of the generated file is "index-all.html" and it is
+ * generated in current or the destination directory.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @see java.lang.Character
+ * @author Atul M Dambalkar
+ * @author Bhavesh Patel (Modified)
+ */
+public class SingleIndexWriter extends AbstractIndexWriter {
+
+ private Set elements;
+
+ /**
+ * Construct the SingleIndexWriter with filename "index-all.html" and the
+ * {@link IndexBuilder}
+ *
+ * @param filename Name of the index file to be generated.
+ * @param indexbuilder Unicode based Index from {@link IndexBuilder}
+ */
+ public SingleIndexWriter(ConfigurationImpl configuration,
+ DocPath filename,
+ IndexBuilder indexbuilder) throws IOException {
+ super(configuration, filename, indexbuilder);
+ }
+
+ /**
+ * Generate single index file, for all Unicode characters.
+ *
+ * @param indexbuilder IndexBuilder built by {@link IndexBuilder}
+ * @throws DocletAbortException
+ */
+ public static void generate(ConfigurationImpl configuration,
+ IndexBuilder indexbuilder) {
+ SingleIndexWriter indexgen;
+ DocPath filename = DocPaths.INDEX_ALL;
+ try {
+ indexgen = new SingleIndexWriter(configuration,
+ filename, indexbuilder);
+ indexgen.generateIndexFile();
+ indexgen.close();
+ } catch (IOException exc) {
+ configuration.standardmessage.error(
+ "doclet.exception_encountered",
+ exc.toString(), filename);
+ throw new DocletAbortException(exc);
+ }
+ }
+
+ /**
+ * Generate the contents of each index file, with Header, Footer,
+ * Member Field, Method and Constructor Description.
+ */
+ protected void generateIndexFile() throws IOException {
+ String title = configuration.getText("doclet.Window_Single_Index");
+ HtmlTree body = getBody(true, getWindowTitle(title));
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
+ ? HtmlTree.HEADER()
+ : body;
+ addTop(htmlTree);
+ addNavLinks(true, htmlTree);
+ if (configuration.allowTag(HtmlTag.HEADER)) {
+ body.addContent(htmlTree);
+ }
+ HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
+ divTree.addStyle(HtmlStyle.contentContainer);
+ elements = new TreeSet<>(indexbuilder.getIndexMap().keySet());
+ elements.addAll(configuration.tagSearchIndexKeys);
+ addLinksForIndexes(divTree);
+ for (Character unicode : elements) {
+ if (configuration.tagSearchIndexMap.get(unicode) == null) {
+ addContents(unicode, indexbuilder.getMemberList(unicode), divTree);
+ } else if (indexbuilder.getMemberList(unicode) == null) {
+ addSearchContents(unicode, configuration.tagSearchIndexMap.get(unicode), divTree);
+ } else {
+ addContents(unicode, indexbuilder.getMemberList(unicode),
+ configuration.tagSearchIndexMap.get(unicode), divTree);
+ }
+ }
+ addLinksForIndexes(divTree);
+ body.addContent((configuration.allowTag(HtmlTag.MAIN))
+ ? HtmlTree.MAIN(divTree)
+ : divTree);
+ if (configuration.allowTag(HtmlTag.FOOTER)) {
+ htmlTree = HtmlTree.FOOTER();
+ }
+ addNavLinks(false, htmlTree);
+ addBottom(htmlTree);
+ if (configuration.allowTag(HtmlTag.FOOTER)) {
+ body.addContent(htmlTree);
+ }
+ createSearchIndexFiles();
+ printHtmlDocument(null, true, body);
+ }
+
+ /**
+ * Add links for all the Index Files per unicode character.
+ *
+ * @param contentTree the content tree to which the links for indexes will be added
+ */
+ protected void addLinksForIndexes(Content contentTree) {
+ for (Object ch : elements) {
+ String unicode = ch.toString();
+ contentTree.addContent(
+ getHyperLink(getNameForIndex(unicode),
+ new StringContent(unicode)));
+ contentTree.addContent(getSpace());
+ }
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java
new file mode 100644
index 00000000000..0396188d8be
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java
@@ -0,0 +1,295 @@
+/*
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+import javax.tools.FileObject;
+
+import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.internal.doclets.formats.html.markup.DocType;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocument;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
+import jdk.javadoc.internal.doclets.toolkit.util.Utils;
+
+/**
+ * Converts Java Source Code to HTML.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Jamie Ho
+ * @author Bhavesh Patel (Modified)
+ */
+public class SourceToHTMLConverter {
+
+ /**
+ * The number of trailing blank lines at the end of the page.
+ * This is inserted so that anchors at the bottom of small pages
+ * can be reached.
+ */
+ private static final int NUM_BLANK_LINES = 60;
+
+ /**
+ * New line to be added to the documentation.
+ */
+ private static final String NEW_LINE = DocletConstants.NL;
+
+ private final ConfigurationImpl configuration;
+ private final Utils utils;
+
+ private final DocletEnvironment rootDoc;
+
+ private DocPath outputdir;
+
+ /**
+ * Relative path from the documentation root to the file that is being
+ * generated.
+ */
+ private DocPath relativePath = DocPath.empty;
+
+ private SourceToHTMLConverter(ConfigurationImpl configuration, DocletEnvironment rd,
+ DocPath outputdir) {
+ this.configuration = configuration;
+ this.utils = configuration.utils;
+ this.rootDoc = rd;
+ this.outputdir = outputdir;
+ }
+
+ /**
+ * Translate the TypeElements in the given DocletEnvironment to HTML representation.
+ *
+ * @param configuration the configuration.
+ * @param root the DocletEnvironment to convert.
+ * @param outputdir the name of the directory to output to.
+ */
+ public static void convertRoot(ConfigurationImpl configuration, DocletEnvironment root,
+ DocPath outputdir) {
+ new SourceToHTMLConverter(configuration, root, outputdir).generate();
+ }
+
+ void generate() {
+ if (rootDoc == null || outputdir == null) {
+ return;
+ }
+ for (PackageElement pkg : utils.getSpecifiedPackages()) {
+ // If -nodeprecated option is set and the package is marked as deprecated,
+ // do not convert the package files to HTML.
+ if (!(configuration.nodeprecated && utils.isDeprecated(pkg)))
+ convertPackage(pkg, outputdir);
+ }
+ for (TypeElement te : utils.getSpecifiedClasses()) {
+ // If -nodeprecated option is set and the class is marked as deprecated
+ // or the containing package is deprecated, do not convert the
+ // package files to HTML.
+ if (!(configuration.nodeprecated &&
+ (utils.isDeprecated(te) || utils.isDeprecated(utils.containingPackage(te)))))
+ convertClass(te, outputdir);
+ }
+ }
+
+ /**
+ * Convert the Classes in the given Package to an HTML.
+ *
+ * @param pkg the Package to convert.
+ * @param outputdir the name of the directory to output to.
+ */
+ public void convertPackage(PackageElement pkg, DocPath outputdir) {
+ if (pkg == null) {
+ return;
+ }
+ for (Element te : utils.getAllClasses(pkg)) {
+ // If -nodeprecated option is set and the class is marked as deprecated,
+ // do not convert the package files to HTML. We do not check for
+ // containing package deprecation since it is already check in
+ // the calling method above.
+ if (!(configuration.nodeprecated && utils.isDeprecated(te)))
+ convertClass((TypeElement)te, outputdir);
+ }
+ }
+
+ /**
+ * Convert the given Class to an HTML.
+ *
+ * @param te the class to convert.
+ * @param outputdir the name of the directory to output to.
+ */
+ public void convertClass(TypeElement te, DocPath outputdir) {
+ if (te == null) {
+ return;
+ }
+ try {
+ FileObject fo = utils.getFileObject(te);
+ if (fo == null)
+ return;
+ Reader r = fo.openReader(true);
+ int lineno = 1;
+ String line;
+ relativePath = DocPaths.SOURCE_OUTPUT
+ .resolve(DocPath.forPackage(utils, te))
+ .invert();
+ Content body = getHeader();
+ Content pre = new HtmlTree(HtmlTag.PRE);
+ try (LineNumberReader reader = new LineNumberReader(r)) {
+ while ((line = reader.readLine()) != null) {
+ addLineNo(pre, lineno);
+ addLine(pre, line, lineno);
+ lineno++;
+ }
+ }
+ addBlankLines(pre);
+ Content div = HtmlTree.DIV(HtmlStyle.sourceContainer, pre);
+ body.addContent((configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN(div) : div);
+ writeToFile(body, outputdir.resolve(DocPath.forClass(utils, te)));
+ } catch (IOException e) {
+ throw new DocletAbortException(e);
+ }
+ }
+
+ /**
+ * Write the output to the file.
+ *
+ * @param body the documentation content to be written to the file.
+ * @param path the path for the file.
+ */
+ private void writeToFile(Content body, DocPath path) throws IOException {
+ Content htmlDocType = configuration.isOutputHtml5()
+ ? DocType.HTML5
+ : DocType.TRANSITIONAL;
+ Content head = new HtmlTree(HtmlTag.HEAD);
+ head.addContent(HtmlTree.TITLE(new StringContent(
+ configuration.getText("doclet.Window_Source_title"))));
+ head.addContent(getStyleSheetProperties());
+ Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
+ head, body);
+ Content htmlDocument = new HtmlDocument(htmlDocType, htmlTree);
+ configuration.message.notice("doclet.Generating_0", path.getPath());
+ DocFile df = DocFile.createFileForOutput(configuration, path);
+ try (Writer w = df.openWriter()) {
+ htmlDocument.write(w, true);
+ }
+
+ }
+
+ /**
+ * Returns a link to the stylesheet file.
+ *
+ * @return an HtmlTree for the lINK tag which provides the stylesheet location
+ */
+ public HtmlTree getStyleSheetProperties() {
+ String filename = configuration.stylesheetfile;
+ DocPath stylesheet;
+ if (filename.length() > 0) {
+ DocFile file = DocFile.createFileForInput(configuration, filename);
+ stylesheet = DocPath.create(file.getName());
+ } else {
+ stylesheet = DocPaths.STYLESHEET;
+ }
+ DocPath p = relativePath.resolve(stylesheet);
+ HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", p.getPath(), "Style");
+ return link;
+ }
+
+ /**
+ * Get the header.
+ *
+ * @return the header content for the HTML file
+ */
+ private static Content getHeader() {
+ return new HtmlTree(HtmlTag.BODY);
+ }
+
+ /**
+ * Add the line numbers for the source code.
+ *
+ * @param pre the content tree to which the line number will be added
+ * @param lineno The line number
+ */
+ private static void addLineNo(Content pre, int lineno) {
+ HtmlTree span = new HtmlTree(HtmlTag.SPAN);
+ span.addStyle(HtmlStyle.sourceLineNo);
+ if (lineno < 10) {
+ span.addContent("00" + Integer.toString(lineno));
+ } else if (lineno < 100) {
+ span.addContent("0" + Integer.toString(lineno));
+ } else {
+ span.addContent(Integer.toString(lineno));
+ }
+ pre.addContent(span);
+ }
+
+ /**
+ * Add a line from source to the HTML file that is generated.
+ *
+ * @param pre the content tree to which the line will be added.
+ * @param line the string to format.
+ * @param currentLineNo the current number.
+ */
+ private void addLine(Content pre, String line, int currentLineNo) {
+ if (line != null) {
+ Content anchor = HtmlTree.A(configuration.htmlVersion,
+ "line." + Integer.toString(currentLineNo),
+ new StringContent(utils.replaceTabs(line)));
+ pre.addContent(anchor);
+ pre.addContent(NEW_LINE);
+ }
+ }
+
+ /**
+ * Add trailing blank lines at the end of the page.
+ *
+ * @param pre the content tree to which the blank lines will be added.
+ */
+ private static void addBlankLines(Content pre) {
+ for (int i = 0; i < NUM_BLANK_LINES; i++) {
+ pre.addContent(NEW_LINE);
+ }
+ }
+
+ /**
+ * Given a Doc
, return an anchor name for it.
+ *
+ * @param d the Doc
to check.
+ * @return the name of the anchor.
+ */
+ public static String getAnchorName(Utils utils, Element e) {
+ return "line." + utils.getLineNumber(e);
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java
new file mode 100644
index 00000000000..f73407cd5e2
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Set;
+import java.util.TreeSet;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder;
+
+
+/**
+ * Generate Separate Index Files for all the member names with Indexing in
+ * Unicode Order. This will create "index-files" directory in the current or
+ * destination directory and will generate separate file for each unicode index.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @see java.lang.Character
+ * @author Atul M Dambalkar
+ * @author Bhavesh Patel (Modified)
+ */
+public class SplitIndexWriter extends AbstractIndexWriter {
+
+ /**
+ * Previous unicode character index in the built index.
+ */
+ protected int prev;
+
+ /**
+ * Next unicode character in the built index.
+ */
+ protected int next;
+
+ private List indexElements;
+
+ /**
+ * Construct the SplitIndexWriter. Uses path to this file and relative path
+ * from this file.
+ *
+ * @param path Path to the file which is getting generated.
+ * @param indexbuilder Unicode based Index from {@link IndexBuilder}
+ */
+ public SplitIndexWriter(ConfigurationImpl configuration,
+ DocPath path,
+ IndexBuilder indexbuilder,
+ Collection elements,
+ int prev, int next) throws IOException {
+ super(configuration, path, indexbuilder);
+ this.indexElements = new ArrayList<>(elements);
+ this.prev = prev;
+ this.next = next;
+ }
+
+ /**
+ * Generate separate index files, for each Unicode character, listing all
+ * the members starting with the particular unicode character.
+ *
+ * @param indexbuilder IndexBuilder built by {@link IndexBuilder}
+ * @throws DocletAbortException
+ */
+ public static void generate(ConfigurationImpl configuration,
+ IndexBuilder indexbuilder) {
+ SplitIndexWriter indexgen;
+ DocPath filename = DocPath.empty;
+ DocPath path = DocPaths.INDEX_FILES;
+ try {
+ Set keys = new TreeSet<>(indexbuilder.getIndexMap().keySet());
+ keys.addAll(configuration.tagSearchIndexKeys);
+ ListIterator li = new ArrayList<>(keys).listIterator();
+ while (li.hasNext()) {
+ Object ch = li.next();
+ filename = DocPaths.indexN(li.nextIndex());
+ indexgen = new SplitIndexWriter(configuration,
+ path.resolve(filename),
+ indexbuilder, keys, li.previousIndex(), li.nextIndex());
+ indexgen.generateIndexFile((Character) ch);
+ if (!li.hasNext()) {
+ indexgen.createSearchIndexFiles();
+ }
+ indexgen.close();
+ }
+ } catch (IOException exc) {
+ configuration.standardmessage.error(
+ "doclet.exception_encountered",
+ exc.toString(), filename.getPath());
+ throw new DocletAbortException(exc);
+ }
+ }
+
+ /**
+ * Generate the contents of each index file, with Header, Footer,
+ * Member Field, Method and Constructor Description.
+ *
+ * @param unicode Unicode character referring to the character for the
+ * index.
+ */
+ protected void generateIndexFile(Character unicode) throws IOException {
+ String title = configuration.getText("doclet.Window_Split_Index",
+ unicode.toString());
+ HtmlTree body = getBody(true, getWindowTitle(title));
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
+ ? HtmlTree.HEADER()
+ : body;
+ addTop(htmlTree);
+ addNavLinks(true, htmlTree);
+ if (configuration.allowTag(HtmlTag.HEADER)) {
+ body.addContent(htmlTree);
+ }
+ HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
+ divTree.addStyle(HtmlStyle.contentContainer);
+ addLinksForIndexes(divTree);
+ if (configuration.tagSearchIndexMap.get(unicode) == null) {
+ addContents(unicode, indexbuilder.getMemberList(unicode), divTree);
+ } else if (indexbuilder.getMemberList(unicode) == null) {
+ addSearchContents(unicode, configuration.tagSearchIndexMap.get(unicode), divTree);
+ } else {
+ addContents(unicode, indexbuilder.getMemberList(unicode),
+ configuration.tagSearchIndexMap.get(unicode), divTree);
+ }
+ addLinksForIndexes(divTree);
+ body.addContent((configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN(divTree) : divTree);
+ if (configuration.allowTag(HtmlTag.FOOTER)) {
+ htmlTree = HtmlTree.FOOTER();
+ }
+ addNavLinks(false, htmlTree);
+ addBottom(htmlTree);
+ if (configuration.allowTag(HtmlTag.FOOTER)) {
+ body.addContent(htmlTree);
+ }
+ printHtmlDocument(null, true, body);
+ }
+
+ /**
+ * Add links for all the Index Files per unicode character.
+ *
+ * @param contentTree the content tree to which the links for indexes will be added
+ */
+ protected void addLinksForIndexes(Content contentTree) {
+ for (int i = 0; i < indexElements.size(); i++) {
+ int j = i + 1;
+ contentTree.addContent(getHyperLink(DocPaths.indexN(j),
+ new StringContent(indexElements.get(i).toString())));
+ contentTree.addContent(getSpace());
+ }
+ }
+
+ /**
+ * Get link to the previous unicode character.
+ *
+ * @return a content tree for the link
+ */
+ public Content getNavLinkPrevious() {
+ Content prevletterLabel = getResource("doclet.Prev_Letter");
+ if (prev == -1) {
+ return HtmlTree.LI(prevletterLabel);
+ }
+ else {
+ Content prevLink = getHyperLink(DocPaths.indexN(prev),
+ prevletterLabel);
+ return HtmlTree.LI(prevLink);
+ }
+ }
+
+ /**
+ * Get link to the next unicode character.
+ *
+ * @return a content tree for the link
+ */
+ public Content getNavLinkNext() {
+ Content nextletterLabel = getResource("doclet.Next_Letter");
+ if (next == -1) {
+ return HtmlTree.LI(nextletterLabel);
+ }
+ else {
+ Content nextLink = getHyperLink(DocPaths.indexN(next),
+ nextletterLabel);
+ return HtmlTree.LI(nextLink);
+ }
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java
new file mode 100644
index 00000000000..11888eb26db
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java
@@ -0,0 +1,368 @@
+/*
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.*;
+import java.util.*;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+
+import com.sun.source.doctree.DocTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.MethodTypes;
+
+/**
+ * This abstract class exists to provide functionality needed in the
+ * the formatting of member information. Since AbstractSubWriter and its
+ * subclasses control this, they would be the logical place to put this.
+ * However, because each member type has its own subclass, subclassing
+ * can not be used effectively to change formatting. The concrete
+ * class subclass of this class can be subclassed to change formatting.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @see AbstractMemberWriter
+ * @see ClassWriterImpl
+ *
+ * @author Robert Field
+ * @author Atul M Dambalkar
+ * @author Bhavesh Patel (Modified)
+ */
+public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
+
+ /**
+ * The HTML tree for main tag.
+ */
+ protected HtmlTree mainTree = HtmlTree.MAIN();
+
+ public SubWriterHolderWriter(ConfigurationImpl configuration, DocPath filename)
+ throws IOException {
+ super(configuration, filename);
+ }
+
+ /**
+ * Add the summary header.
+ *
+ * @param mw the writer for the member being documented
+ * @param typeElement the te to be documented
+ * @param memberTree the content tree to which the summary header will be added
+ */
+ public void addSummaryHeader(AbstractMemberWriter mw, TypeElement typeElement,
+ Content memberTree) {
+ mw.addSummaryAnchor(typeElement, memberTree);
+ mw.addSummaryLabel(memberTree);
+ }
+
+ /**
+ * Get the summary table.
+ *
+ * @param mw the writer for the member being documented
+ * @param typeElement the te to be documented
+ * @param tableContents list of summary table contents
+ * @param showTabs true if the table needs to show tabs
+ * @return the content tree for the summary table
+ */
+ public Content getSummaryTableTree(AbstractMemberWriter mw, TypeElement typeElement,
+ List tableContents, boolean showTabs) {
+ Content caption;
+ if (showTabs) {
+ caption = getTableCaption(mw.methodTypes);
+ generateMethodTypesScript(mw.typeMap, mw.methodTypes);
+ }
+ else {
+ caption = getTableCaption(mw.getCaption());
+ }
+ Content table = (configuration.isOutputHtml5())
+ ? HtmlTree.TABLE(HtmlStyle.memberSummary, caption)
+ : HtmlTree.TABLE(HtmlStyle.memberSummary, mw.getTableSummary(), caption);
+ table.addContent(getSummaryTableHeader(mw.getSummaryTableHeader(typeElement), "col"));
+ for (Content tableContent : tableContents) {
+ table.addContent(tableContent);
+ }
+ return table;
+ }
+
+ /**
+ * Get the summary table caption.
+ *
+ * @param methodTypes set comprising of method types to show as table caption
+ * @return the caption for the summary table
+ */
+ public Content getTableCaption(Set methodTypes) {
+ Content tabbedCaption = new HtmlTree(HtmlTag.CAPTION);
+ for (MethodTypes type : methodTypes) {
+ Content captionSpan;
+ Content span;
+ if (type.isDefaultTab()) {
+ captionSpan = HtmlTree.SPAN(configuration.getResource(type.resourceKey()));
+ span = HtmlTree.SPAN(type.tabId(),
+ HtmlStyle.activeTableTab, captionSpan);
+ } else {
+ captionSpan = HtmlTree.SPAN(getMethodTypeLinks(type));
+ span = HtmlTree.SPAN(type.tabId(),
+ HtmlStyle.tableTab, captionSpan);
+ }
+ Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, getSpace());
+ span.addContent(tabSpan);
+ tabbedCaption.addContent(span);
+ }
+ return tabbedCaption;
+ }
+
+ /**
+ * Get the method type links for the table caption.
+ *
+ * @param methodType the method type to be displayed as link
+ * @return the content tree for the method type link
+ */
+ public Content getMethodTypeLinks(MethodTypes methodType) {
+ String jsShow = "javascript:show(" + methodType.value() +");";
+ HtmlTree link = HtmlTree.A(jsShow, configuration.getResource(methodType.resourceKey()));
+ return link;
+ }
+
+ /**
+ * Add the inherited summary header.
+ *
+ * @param mw the writer for the member being documented
+ * @param typeElement the te to be documented
+ * @param inheritedTree the content tree to which the inherited summary header will be added
+ */
+ public void addInheritedSummaryHeader(AbstractMemberWriter mw, TypeElement typeElement,
+ Content inheritedTree) {
+ mw.addInheritedSummaryAnchor(typeElement, inheritedTree);
+ mw.addInheritedSummaryLabel(typeElement, inheritedTree);
+ }
+
+ /**
+ * Add the index comment.
+ *
+ * @param member the member being documented
+ * @param contentTree the content tree to which the comment will be added
+ */
+ protected void addIndexComment(Element member, Content contentTree) {
+ List extends DocTree> tags = utils.getFirstSentenceTrees(member);
+ addIndexComment(member, tags, contentTree);
+ }
+
+ /**
+ * Add the index comment.
+ *
+ * @param member the member being documented
+ * @param firstSentenceTags the first sentence tags for the member to be documented
+ * @param tdSummary the content tree to which the comment will be added
+ */
+ protected void addIndexComment(Element member, List extends DocTree> firstSentenceTags,
+ Content tdSummary) {
+ List extends DocTree> deprs = utils.getBlockTags(member, DocTree.Kind.DEPRECATED);
+ Content div;
+ if (utils.isDeprecated(member)) {
+ Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
+ div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
+ div.addContent(getSpace());
+ if (!deprs.isEmpty()) {
+ addInlineDeprecatedComment(member, deprs.get(0), div);
+ }
+ tdSummary.addContent(div);
+ return;
+ } else {
+ Element te = member.getEnclosingElement();
+ if (te != null && utils.isTypeElement(te) && utils.isDeprecated(te)) {
+ Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
+ div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
+ div.addContent(getSpace());
+ tdSummary.addContent(div);
+ }
+ }
+ addSummaryComment(member, firstSentenceTags, tdSummary);
+ }
+
+ /**
+ * Add the summary type for the member.
+ *
+ * @param mw the writer for the member being documented
+ * @param member the member to be documented
+ * @param tdSummaryType the content tree to which the type will be added
+ */
+ public void addSummaryType(AbstractMemberWriter mw, Element member, Content tdSummaryType) {
+ mw.addSummaryType(member, tdSummaryType);
+ }
+
+ /**
+ * Add the summary link for the member.
+ *
+ * @param mw the writer for the member being documented
+ * @param member the member to be documented
+ * @param contentTree the content tree to which the link will be added
+ */
+ public void addSummaryLinkComment(AbstractMemberWriter mw, Element member, Content contentTree) {
+ List extends DocTree> tags = utils.getFirstSentenceTrees(member);
+ addSummaryLinkComment(mw, member, tags, contentTree);
+ }
+
+ /**
+ * Add the summary link comment.
+ *
+ * @param mw the writer for the member being documented
+ * @param member the member being documented
+ * @param firstSentenceTags the first sentence tags for the member to be documented
+ * @param tdSummary the content tree to which the comment will be added
+ */
+ public void addSummaryLinkComment(AbstractMemberWriter mw,
+ Element member, List extends DocTree> firstSentenceTags, Content tdSummary) {
+ addIndexComment(member, firstSentenceTags, tdSummary);
+ }
+
+ /**
+ * Add the inherited member summary.
+ *
+ * @param mw the writer for the member being documented
+ * @param typeElement the class being documented
+ * @param member the member being documented
+ * @param isFirst true if its the first link being documented
+ * @param linksTree the content tree to which the summary will be added
+ */
+ public void addInheritedMemberSummary(AbstractMemberWriter mw, TypeElement typeElement,
+ Element member, boolean isFirst, Content linksTree) {
+ if (! isFirst) {
+ linksTree.addContent(", ");
+ }
+ mw.addInheritedSummaryLink(typeElement, member, linksTree);
+ }
+
+ /**
+ * Get the document content header tree
+ *
+ * @return a content tree the document content header
+ */
+ public Content getContentHeader() {
+ HtmlTree div = new HtmlTree(HtmlTag.DIV);
+ div.addStyle(HtmlStyle.contentContainer);
+ return div;
+ }
+
+ /**
+ * Add the class content tree.
+ *
+ * @param contentTree content tree to which the class content will be added
+ * @param classContentTree class content tree which will be added to the content tree
+ */
+ public void addClassContentTree(Content contentTree, Content classContentTree) {
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ mainTree.addContent(classContentTree);
+ contentTree.addContent(mainTree);
+ } else {
+ contentTree.addContent(classContentTree);
+ }
+ }
+
+ /**
+ * Add the annotation content tree.
+ *
+ * @param contentTree content tree to which the annotation content will be added
+ * @param annotationContentTree annotation content tree which will be added to the content tree
+ */
+ public void addAnnotationContentTree(Content contentTree, Content annotationContentTree) {
+ addClassContentTree(contentTree, annotationContentTree);
+ }
+
+ /**
+ * Get the member header tree
+ *
+ * @return a content tree the member header
+ */
+ public Content getMemberTreeHeader() {
+ HtmlTree li = new HtmlTree(HtmlTag.LI);
+ li.addStyle(HtmlStyle.blockList);
+ return li;
+ }
+
+ /**
+ * Add the member tree.
+ *
+ * @param memberSummaryTree the content tree representing the member summary
+ * @param memberTree the content tree representing the member
+ */
+ public void addMemberTree(Content memberSummaryTree, Content memberTree) {
+ if (configuration.allowTag(HtmlTag.SECTION)) {
+ HtmlTree htmlTree = HtmlTree.SECTION(getMemberTree(memberTree));
+ memberSummaryTree.addContent(htmlTree);
+ } else {
+ memberSummaryTree.addContent(getMemberTree(memberTree));
+ }
+ }
+
+ /**
+ * Get the member tree
+ *
+ * @param contentTree the tree used to generate the complete member tree
+ * @return a content tree for the member
+ */
+ public Content getMemberTree(Content contentTree) {
+ Content ul = HtmlTree.UL(HtmlStyle.blockList, contentTree);
+ return ul;
+ }
+
+ /**
+ * Get the member summary tree
+ *
+ * @param contentTree the tree used to generate the member summary tree
+ * @return a content tree for the member summary
+ */
+ public Content getMemberSummaryTree(Content contentTree) {
+ return getMemberTree(HtmlStyle.summary, contentTree);
+ }
+
+ /**
+ * Get the member details tree
+ *
+ * @param contentTree the tree used to generate the member details tree
+ * @return a content tree for the member details
+ */
+ public Content getMemberDetailsTree(Content contentTree) {
+ return getMemberTree(HtmlStyle.details, contentTree);
+ }
+
+ /**
+ * Get the member tree
+ *
+ * @param style the style class to be added to the content tree
+ * @param contentTree the tree used to generate the complete member tree
+ */
+ public Content getMemberTree(HtmlStyle style, Content contentTree) {
+ Content div = HtmlTree.DIV(style, getMemberTree(contentTree));
+ return div;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java
new file mode 100644
index 00000000000..1ae644233b2
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java
@@ -0,0 +1,445 @@
+/*
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.util.List;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.SimpleElementVisitor9;
+
+import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.IndexTree;
+import com.sun.tools.javac.util.DefinedBy;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.builders.SerializedFormBuilder;
+import jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter;
+import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
+import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
+import jdk.javadoc.internal.doclets.toolkit.util.MessageRetriever;
+import jdk.javadoc.internal.doclets.toolkit.util.Utils;
+
+/**
+ * The taglet writer that writes HTML.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Jamie Ho
+ * @author Bhavesh Patel (Modified)
+ */
+
+public class TagletWriterImpl extends TagletWriter {
+
+ private final HtmlDocletWriter htmlWriter;
+ private final ConfigurationImpl configuration;
+ private final Utils utils;
+
+ public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence) {
+ super(isFirstSentence);
+ this.htmlWriter = htmlWriter;
+ configuration = htmlWriter.configuration;
+ this.utils = configuration.utils;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getOutputInstance() {
+ return new ContentBuilder();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Content codeTagOutput(Element element, DocTree tag) {
+ CommentHelper ch = utils.getCommentHelper(element);
+ String str = utils.normalizeNewlines(ch.getText(tag));
+ StringContent content = new StringContent(str);
+ Content result = HtmlTree.CODE(content);
+ return result;
+ }
+
+ protected Content indexTagOutput(Element element, DocTree tag) {
+ CommentHelper ch = utils.getCommentHelper(element);
+ IndexTree itt = (IndexTree)tag;
+
+ String tagText = ch.getText(itt.getSearchTerm());
+ if (tagText.charAt(0) == '"' && tagText.charAt(tagText.length() - 1) == '"') {
+ tagText = tagText.substring(1, tagText.length() - 1);
+ }
+ String desc = ch.getText(itt.getDescription());
+
+ String anchorName = htmlWriter.getName(tagText);
+ Content result = HtmlTree.A_ID(anchorName, new StringContent(tagText));
+ if (configuration.createindex && !tagText.isEmpty()) {
+ SearchIndexItem si = new SearchIndexItem();
+ si.setLabel(tagText);
+ si.setDescription(desc);
+ new SimpleElementVisitor9() {
+ @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL)
+ public Void visitPackage(PackageElement e, Void p) {
+ si.setUrl(DocPath.forPackage(e).getPath()
+ + "/" + DocPaths.PACKAGE_SUMMARY.getPath() + "#" + anchorName);
+ si.setHolder(utils.getSimpleName(element));
+ return null;
+ }
+
+ @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL)
+ public Void visitType(TypeElement e, Void p) {
+ si.setUrl(DocPath.forClass(utils, e).getPath() + "#" + anchorName);
+ si.setHolder(utils.getFullyQualifiedName(e));
+ return null;
+ }
+
+ @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL)
+ public Void visitVariable(VariableElement e, Void p) {
+ TypeElement te = utils.getEnclosingTypeElement(e);
+ si.setUrl(DocPath.forClass(utils, te).getPath() + "#" + anchorName);
+ si.setHolder(utils.getFullyQualifiedName(e) + "." + utils.getSimpleName(e));
+ return null;
+ }
+
+ @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL)
+ protected Void defaultAction(Element e, Void p) {
+ TypeElement te = utils.getEnclosingTypeElement(e);
+ si.setUrl(DocPath.forClass(utils, te).getPath() + "#" + anchorName);
+ si.setHolder(utils.getFullyQualifiedName(e));
+ return null;
+ }
+ }.visit(element);
+ si.setCategory(configuration.getResource("doclet.SearchTags").toString());
+ configuration.tagSearchIndex.add(si);
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getDocRootOutput() {
+ String path;
+ if (htmlWriter.pathToRoot.isEmpty())
+ path = ".";
+ else
+ path = htmlWriter.pathToRoot.getPath();
+ return new StringContent(path);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content deprecatedTagOutput(Element element) {
+ ContentBuilder result = new ContentBuilder();
+ CommentHelper ch = utils.getCommentHelper(element);
+ List extends DocTree> deprs = utils.getBlockTags(element, DocTree.Kind.DEPRECATED);
+ if (utils.isTypeElement(element)) {
+ if (utils.isDeprecated(element)) {
+ result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel,
+ new StringContent(configuration.getText("doclet.Deprecated"))));
+ result.addContent(RawHtml.nbsp);
+ if (!deprs.isEmpty()) {
+ List extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0));
+ if (!commentTags.isEmpty()) {
+ result.addContent(commentTagsToOutput(null, element, commentTags, false));
+ }
+ }
+ }
+ } else {
+ if (utils.isDeprecated(element)) {
+ result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel,
+ new StringContent(configuration.getText("doclet.Deprecated"))));
+ result.addContent(RawHtml.nbsp);
+ if (!deprs.isEmpty()) {
+ List extends DocTree> bodyTags = ch.getBody(configuration, deprs.get(0));
+ Content body = commentTagsToOutput(null, element, bodyTags, false);
+ if (!body.isEmpty())
+ result.addContent(HtmlTree.SPAN(HtmlStyle.deprecationComment, body));
+ }
+ } else {
+ if (utils.isDeprecated(utils.getEnclosingTypeElement(element))) {
+ result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel,
+ new StringContent(configuration.getText("doclet.Deprecated"))));
+ result.addContent(RawHtml.nbsp);
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Content literalTagOutput(Element element, DocTree tag) {
+ CommentHelper ch = utils.getCommentHelper(element);
+ Content result = new StringContent(utils.normalizeNewlines(ch.getText(tag)));
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public MessageRetriever getMsgRetriever() {
+ return configuration.message;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getParamHeader(String header) {
+ HtmlTree result = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.paramLabel,
+ new StringContent(header)));
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content paramTagOutput(Element element, DocTree paramTag, String paramName) {
+ ContentBuilder body = new ContentBuilder();
+ CommentHelper ch = utils.getCommentHelper(element);
+ body.addContent(HtmlTree.CODE(new RawHtml(paramName)));
+ body.addContent(" - ");
+ List extends DocTree> description = ch.getDescription(configuration, paramTag);
+ body.addContent(htmlWriter.commentTagsToContent(paramTag, element, description, false));
+ HtmlTree result = HtmlTree.DD(body);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content propertyTagOutput(Element element, DocTree tag, String prefix) {
+ Content body = new ContentBuilder();
+ CommentHelper ch = utils.getCommentHelper(element);
+ body.addContent(new RawHtml(prefix));
+ body.addContent(" ");
+ body.addContent(HtmlTree.CODE(new RawHtml(ch.getText(tag))));
+ body.addContent(".");
+ Content result = HtmlTree.P(body);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content returnTagOutput(Element element, DocTree returnTag) {
+ ContentBuilder result = new ContentBuilder();
+ CommentHelper ch = utils.getCommentHelper(element);
+ result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.returnLabel,
+ new StringContent(configuration.getText("doclet.Returns")))));
+ result.addContent(HtmlTree.DD(htmlWriter.commentTagsToContent(
+ returnTag, element, ch.getDescription(configuration, returnTag), false)));
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content seeTagOutput(Element holder, List extends DocTree> seeTags) {
+ ContentBuilder body = new ContentBuilder();
+ if (!seeTags.isEmpty()) {
+ for (DocTree dt : seeTags) {
+ appendSeparatorIfNotEmpty(body);
+ body.addContent(htmlWriter.seeTagToContent(holder, dt));
+ }
+ }
+ if (utils.isVariableElement(holder) && ((VariableElement)holder).getConstantValue() != null &&
+ htmlWriter instanceof ClassWriterImpl) {
+ //Automatically add link to constant values page for constant fields.
+ appendSeparatorIfNotEmpty(body);
+ DocPath constantsPath =
+ htmlWriter.pathToRoot.resolve(DocPaths.CONSTANT_VALUES);
+ String whichConstant =
+ ((ClassWriterImpl) htmlWriter).getTypeElement().getQualifiedName() + "." +
+ utils.getSimpleName(holder);
+ DocLink link = constantsPath.fragment(whichConstant);
+ body.addContent(htmlWriter.getHyperLink(link,
+ new StringContent(configuration.getText("doclet.Constants_Summary"))));
+ }
+ if (utils.isClass(holder) && utils.isSerializable((TypeElement)holder)) {
+ //Automatically add link to serialized form page for serializable classes.
+ if (SerializedFormBuilder.serialInclude(utils, holder) &&
+ SerializedFormBuilder.serialInclude(utils, utils.containingPackage(holder))) {
+ appendSeparatorIfNotEmpty(body);
+ DocPath serialPath = htmlWriter.pathToRoot.resolve(DocPaths.SERIALIZED_FORM);
+ DocLink link = serialPath.fragment(utils.getFullyQualifiedName(holder));
+ body.addContent(htmlWriter.getHyperLink(link,
+ new StringContent(configuration.getText("doclet.Serialized_Form"))));
+ }
+ }
+ if (body.isEmpty())
+ return body;
+
+ ContentBuilder result = new ContentBuilder();
+ result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.seeLabel,
+ new StringContent(configuration.getText("doclet.See_Also")))));
+ result.addContent(HtmlTree.DD(body));
+ return result;
+
+ }
+
+ private void appendSeparatorIfNotEmpty(ContentBuilder body) {
+ if (!body.isEmpty()) {
+ body.addContent(", ");
+ body.addContent(DocletConstants.NL);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content simpleTagOutput(Element element, List extends DocTree> simpleTags, String header) {
+ CommentHelper ch = utils.getCommentHelper(element);
+ ContentBuilder result = new ContentBuilder();
+ result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.simpleTagLabel, new RawHtml(header))));
+ ContentBuilder body = new ContentBuilder();
+ boolean many = false;
+ for (DocTree simpleTag : simpleTags) {
+ if (many) {
+ body.addContent(", ");
+ }
+ List extends DocTree> bodyTags = ch.getBody(configuration, simpleTag);
+ body.addContent(htmlWriter.commentTagsToContent(simpleTag, element, bodyTags, false));
+ many = true;
+ }
+ result.addContent(HtmlTree.DD(body));
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content simpleTagOutput(Element element, DocTree simpleTag, String header) {
+ ContentBuilder result = new ContentBuilder();
+ result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.simpleTagLabel, new RawHtml(header))));
+ CommentHelper ch = utils.getCommentHelper(element);
+ List extends DocTree> description = ch.getDescription(configuration, simpleTag);
+ Content body = htmlWriter.commentTagsToContent(simpleTag, element, description, false);
+ result.addContent(HtmlTree.DD(body));
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content getThrowsHeader() {
+ HtmlTree result = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.throwsLabel,
+ new StringContent(configuration.getText("doclet.Throws"))));
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content throwsTagOutput(Element element, DocTree throwsTag) {
+ ContentBuilder body = new ContentBuilder();
+ CommentHelper ch = utils.getCommentHelper(element);
+ Element exception = ch.getException(configuration, throwsTag);
+ Content excName;
+ if (exception == null) {
+ excName = new RawHtml(ch.getExceptionName(throwsTag).toString());
+ } else if (exception.asType() == null) {
+ excName = new RawHtml(utils.getFullyQualifiedName(exception));
+ } else {
+ LinkInfoImpl link = new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER,
+ exception.asType());
+ link.excludeTypeBounds = true;
+ excName = htmlWriter.getLink(link);
+ }
+ body.addContent(HtmlTree.CODE(excName));
+ List extends DocTree> description = ch.getDescription(configuration, throwsTag);
+ Content desc = htmlWriter.commentTagsToContent(throwsTag, element, description, false);
+ if (desc != null && !desc.isEmpty()) {
+ body.addContent(" - ");
+ body.addContent(desc);
+ }
+ HtmlTree result = HtmlTree.DD(body);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content throwsTagOutput(TypeMirror throwsType) {
+ HtmlTree result = HtmlTree.DD(HtmlTree.CODE(htmlWriter.getLink(
+ new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER, throwsType))));
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content valueTagOutput(VariableElement field, String constantVal, boolean includeLink) {
+ return includeLink ?
+ htmlWriter.getDocLink(LinkInfoImpl.Kind.VALUE_TAG, field,
+ constantVal, false) : new RawHtml(constantVal);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content commentTagsToOutput(DocTree holderTag, List extends DocTree> tags) {
+ return commentTagsToOutput(holderTag, null, tags, false);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content commentTagsToOutput(Element holder, List extends DocTree> tags) {
+ return commentTagsToOutput(null, holder, tags, false);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Content commentTagsToOutput(DocTree holderTag,
+ Element holder, List extends DocTree> tags, boolean isFirstSentence) {
+ return htmlWriter.commentTagsToContent(holderTag, holder,
+ tags, isFirstSentence);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Configuration configuration() {
+ return configuration;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java
new file mode 100644
index 00000000000..0987cc2d825
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.IOException;
+import java.util.SortedSet;
+
+import javax.lang.model.element.PackageElement;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+
+/**
+ * Generate Class Hierarchy page for all the Classes in this run. Use
+ * ClassTree for building the Tree. The name of
+ * the generated file is "overview-tree.html" and it is generated in the
+ * current or the destination directory.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Atul M Dambalkar
+ * @author Bhavesh Patel (Modified)
+ */
+public class TreeWriter extends AbstractTreeWriter {
+
+ /**
+ * Packages in this run.
+ */
+ SortedSet packages;
+
+ /**
+ * True if there are no packages specified on the command line,
+ * False otherwise.
+ */
+ private boolean classesonly;
+
+ /**
+ * Constructor to construct TreeWriter object.
+ *
+ * @param configuration the current configuration of the doclet.
+ * @param filename String filename
+ * @param classtree the tree being built.
+ */
+ public TreeWriter(ConfigurationImpl configuration,
+ DocPath filename, ClassTree classtree) throws IOException {
+ super(configuration, filename, classtree);
+ packages = configuration.packages;
+ classesonly = packages.isEmpty();
+ }
+
+ /**
+ * Create a TreeWriter object and use it to generate the
+ * "overview-tree.html" file.
+ *
+ * @param classtree the class tree being documented.
+ * @throws DocletAbortException
+ */
+ public static void generate(ConfigurationImpl configuration,
+ ClassTree classtree) {
+ TreeWriter treegen;
+ DocPath filename = DocPaths.OVERVIEW_TREE;
+ try {
+ treegen = new TreeWriter(configuration, filename, classtree);
+ treegen.generateTreeFile();
+ treegen.close();
+ } catch (IOException exc) {
+ configuration.standardmessage.error(
+ "doclet.exception_encountered",
+ exc.toString(), filename);
+ throw new DocletAbortException(exc);
+ }
+ }
+
+ /**
+ * Generate the interface hierarchy and class hierarchy.
+ */
+ public void generateTreeFile() throws IOException {
+ HtmlTree body = getTreeHeader();
+ Content headContent = getResource("doclet.Hierarchy_For_All_Packages");
+ Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false,
+ HtmlStyle.title, headContent);
+ Content div = HtmlTree.DIV(HtmlStyle.header, heading);
+ addPackageTreeLinks(div);
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
+ ? HtmlTree.MAIN()
+ : body;
+ htmlTree.addContent(div);
+ HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
+ divTree.addStyle(HtmlStyle.contentContainer);
+ addTree(classtree.baseClasses(), "doclet.Class_Hierarchy", divTree);
+ addTree(classtree.baseInterfaces(), "doclet.Interface_Hierarchy", divTree);
+ addTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy", divTree);
+ addTree(classtree.baseEnums(), "doclet.Enum_Hierarchy", divTree, true);
+ htmlTree.addContent(divTree);
+ if (configuration.allowTag(HtmlTag.MAIN)) {
+ body.addContent(htmlTree);
+ }
+ if (configuration.allowTag(HtmlTag.FOOTER)) {
+ htmlTree = HtmlTree.FOOTER();
+ } else {
+ htmlTree = body;
+ }
+ addNavLinks(false, htmlTree);
+ addBottom(htmlTree);
+ if (configuration.allowTag(HtmlTag.FOOTER)) {
+ body.addContent(htmlTree);
+ }
+ printHtmlDocument(null, true, body);
+ }
+
+ /**
+ * Add the links to all the package tree files.
+ *
+ * @param contentTree the content tree to which the links will be added
+ */
+ protected void addPackageTreeLinks(Content contentTree) {
+ //Do nothing if only unnamed package is used
+ if (isUnnamedPackage()) {
+ return;
+ }
+ if (!classesonly) {
+ Content span = HtmlTree.SPAN(HtmlStyle.packageHierarchyLabel,
+ getResource("doclet.Package_Hierarchies"));
+ contentTree.addContent(span);
+ HtmlTree ul = new HtmlTree(HtmlTag.UL);
+ ul.addStyle(HtmlStyle.horizontal);
+ int i = 0;
+ for (PackageElement pkg : packages) {
+ // If the package name length is 0 or if -nodeprecated option
+ // is set and the package is marked as deprecated, do not include
+ // the page in the list of package hierarchies.
+ if (pkg.isUnnamed() ||
+ (configuration.nodeprecated && utils.isDeprecated(pkg))) {
+ i++;
+ continue;
+ }
+ DocPath link = pathString(pkg, DocPaths.PACKAGE_TREE);
+ Content li = HtmlTree.LI(getHyperLink(link,
+ new StringContent(utils.getPackageName(pkg))));
+ if (i < packages.size() - 1) {
+ li.addContent(", ");
+ }
+ ul.addContent(li);
+ i++;
+ }
+ contentTree.addContent(ul);
+ }
+ }
+
+ /**
+ * Get the tree header.
+ *
+ * @return a content tree for the tree header
+ */
+ protected HtmlTree getTreeHeader() {
+ String title = configuration.getText("doclet.Window_Class_Hierarchy");
+ HtmlTree bodyTree = getBody(true, getWindowTitle(title));
+ HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
+ ? HtmlTree.HEADER()
+ : bodyTree;
+ addTop(htmlTree);
+ addNavLinks(true, htmlTree);
+ if (configuration.allowTag(HtmlTag.HEADER)) {
+ bodyTree.addContent(htmlTree);
+ }
+ return bodyTree;
+ }
+
+ private boolean isUnnamedPackage() {
+ return packages.size() == 1 && packages.first().isUnnamed();
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/WriterFactoryImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/WriterFactoryImpl.java
new file mode 100644
index 00000000000..cce4052b9b3
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/WriterFactoryImpl.java
@@ -0,0 +1,238 @@
+/*
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html;
+
+import java.io.IOException;
+
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.TypeMirror;
+
+import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeFieldWriter;
+import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeOptionalMemberWriter;
+import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeRequiredMemberWriter;
+import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter;
+import jdk.javadoc.internal.doclets.toolkit.ClassWriter;
+import jdk.javadoc.internal.doclets.toolkit.ConstantsSummaryWriter;
+import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
+import jdk.javadoc.internal.doclets.toolkit.PackageSummaryWriter;
+import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter;
+import jdk.javadoc.internal.doclets.toolkit.WriterFactory;
+import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
+import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
+
+import static jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap.Kind.*;
+
+/**
+ * The factory that returns HTML writers.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Jamie Ho
+ */
+public class WriterFactoryImpl implements WriterFactory {
+
+ private final ConfigurationImpl configuration;
+ public WriterFactoryImpl(ConfigurationImpl configuration) {
+ this.configuration = configuration;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ConstantsSummaryWriter getConstantsSummaryWriter() throws Exception {
+ return new ConstantsSummaryWriterImpl(configuration);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public PackageSummaryWriter getPackageSummaryWriter(PackageElement packageElement,
+ PackageElement prevPkg, PackageElement nextPkg) throws Exception {
+ return new PackageWriterImpl(configuration, packageElement, prevPkg, nextPkg);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ClassWriter getClassWriter(TypeElement typeElement, TypeElement prevClass,
+ TypeElement nextClass, ClassTree classTree) throws IOException {
+ return new ClassWriterImpl(configuration, typeElement, prevClass, nextClass, classTree);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public AnnotationTypeWriter getAnnotationTypeWriter(TypeElement annotationType,
+ TypeMirror prevType, TypeMirror nextType) throws Exception {
+ return new AnnotationTypeWriterImpl(configuration, annotationType, prevType, nextType);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public AnnotationTypeFieldWriter
+ getAnnotationTypeFieldWriter(AnnotationTypeWriter annotationTypeWriter) throws Exception {
+ TypeElement te = annotationTypeWriter.getAnnotationTypeElement();
+ return new AnnotationTypeFieldWriterImpl(
+ (SubWriterHolderWriter) annotationTypeWriter, te);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public AnnotationTypeOptionalMemberWriter
+ getAnnotationTypeOptionalMemberWriter(
+ AnnotationTypeWriter annotationTypeWriter) throws Exception {
+ TypeElement te = annotationTypeWriter.getAnnotationTypeElement();
+ return new AnnotationTypeOptionalMemberWriterImpl(
+ (SubWriterHolderWriter) annotationTypeWriter, te);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public AnnotationTypeRequiredMemberWriter
+ getAnnotationTypeRequiredMemberWriter(AnnotationTypeWriter annotationTypeWriter) throws Exception {
+ TypeElement te = annotationTypeWriter.getAnnotationTypeElement();
+ return new AnnotationTypeRequiredMemberWriterImpl(
+ (SubWriterHolderWriter) annotationTypeWriter, te);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public EnumConstantWriterImpl getEnumConstantWriter(ClassWriter classWriter)
+ throws Exception {
+ return new EnumConstantWriterImpl((SubWriterHolderWriter) classWriter,
+ classWriter.getTypeElement());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public FieldWriterImpl getFieldWriter(ClassWriter classWriter)
+ throws Exception {
+ return new FieldWriterImpl((SubWriterHolderWriter) classWriter, classWriter.getTypeElement());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public PropertyWriterImpl getPropertyWriter(ClassWriter classWriter)
+ throws Exception {
+ return new PropertyWriterImpl((SubWriterHolderWriter) classWriter,
+ classWriter.getTypeElement());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public MethodWriterImpl getMethodWriter(ClassWriter classWriter)
+ throws Exception {
+ return new MethodWriterImpl((SubWriterHolderWriter) classWriter, classWriter.getTypeElement());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ConstructorWriterImpl getConstructorWriter(ClassWriter classWriter)
+ throws Exception {
+ return new ConstructorWriterImpl((SubWriterHolderWriter) classWriter,
+ classWriter.getTypeElement());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public MemberSummaryWriter getMemberSummaryWriter(
+ ClassWriter classWriter, VisibleMemberMap.Kind memberType)
+ throws Exception {
+ switch (memberType) {
+ case CONSTRUCTORS:
+ return getConstructorWriter(classWriter);
+ case ENUM_CONSTANTS:
+ return getEnumConstantWriter(classWriter);
+ case FIELDS:
+ return getFieldWriter(classWriter);
+ case PROPERTIES:
+ return getPropertyWriter(classWriter);
+ case INNER_CLASSES:
+ return new NestedClassWriterImpl((SubWriterHolderWriter)
+ classWriter, classWriter.getTypeElement());
+ case METHODS:
+ return getMethodWriter(classWriter);
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public MemberSummaryWriter getMemberSummaryWriter(
+ AnnotationTypeWriter annotationTypeWriter, VisibleMemberMap.Kind memberType)
+ throws Exception {
+ switch (memberType) {
+ case ANNOTATION_TYPE_FIELDS:
+ return (AnnotationTypeFieldWriterImpl)
+ getAnnotationTypeFieldWriter(annotationTypeWriter);
+ case ANNOTATION_TYPE_MEMBER_OPTIONAL:
+ return (AnnotationTypeOptionalMemberWriterImpl)
+ getAnnotationTypeOptionalMemberWriter(annotationTypeWriter);
+ case ANNOTATION_TYPE_MEMBER_REQUIRED:
+ return (AnnotationTypeRequiredMemberWriterImpl)
+ getAnnotationTypeRequiredMemberWriter(annotationTypeWriter);
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public SerializedFormWriter getSerializedFormWriter() throws Exception {
+ return new SerializedFormWriterImpl(configuration);
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Comment.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Comment.java
new file mode 100644
index 00000000000..0adfc088106
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Comment.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html.markup;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
+
+/**
+ * Class for generating a comment for HTML pages of javadoc output.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Bhavesh Patel
+ */
+public class Comment extends Content {
+
+ private String commentText;
+
+ /**
+ * Constructor to construct a Comment object.
+ *
+ * @param comment comment text for the comment
+ */
+ public Comment(String comment) {
+ commentText = nullCheck(comment);
+ }
+
+ /**
+ * This method is not supported by the class.
+ *
+ * @param content content that needs to be added
+ * @throws DocletAbortException this method will always throw a
+ * DocletAbortException because it
+ * is not supported.
+ */
+ public void addContent(Content content) {
+ throw new DocletAbortException("not supported");
+ }
+
+ /**
+ * This method is not supported by the class.
+ *
+ * @param stringContent string content that needs to be added
+ * @throws DocletAbortException this method will always throw a
+ * DocletAbortException because it
+ * is not supported.
+ */
+ public void addContent(String stringContent) {
+ throw new DocletAbortException("not supported");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isEmpty() {
+ return commentText.isEmpty();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean write(Writer out, boolean atNewline) throws IOException {
+ if (!atNewline)
+ out.write(DocletConstants.NL);
+ out.write("" + DocletConstants.NL);
+ return true;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/ContentBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/ContentBuilder.java
new file mode 100644
index 00000000000..64ceef82473
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/ContentBuilder.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html.markup;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import jdk.javadoc.internal.doclets.toolkit.Content;
+
+/**
+ * A sequence of Content nodes.
+ */
+public class ContentBuilder extends Content {
+ protected List contents = Collections.emptyList();
+
+ @Override
+ public void addContent(Content content) {
+ nullCheck(content);
+ ensureMutableContents();
+ if (content instanceof ContentBuilder) {
+ contents.addAll(((ContentBuilder) content).contents);
+ } else
+ contents.add(content);
+ }
+
+ @Override
+ public void addContent(String text) {
+ if (text.isEmpty())
+ return;
+ ensureMutableContents();
+ Content c = contents.isEmpty() ? null : contents.get(contents.size() - 1);
+ StringContent sc;
+ if (c != null && c instanceof StringContent) {
+ sc = (StringContent) c;
+ } else {
+ contents.add(sc = new StringContent());
+ }
+ sc.addContent(text);
+ }
+
+ @Override
+ public boolean write(Writer writer, boolean atNewline) throws IOException {
+ for (Content content: contents) {
+ atNewline = content.write(writer, atNewline);
+ }
+ return atNewline;
+ }
+
+ @Override
+ public boolean isEmpty() {
+ for (Content content: contents) {
+ if (!content.isEmpty())
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int charCount() {
+ int n = 0;
+ for (Content c : contents)
+ n += c.charCount();
+ return n;
+ }
+
+ private void ensureMutableContents() {
+ if (contents.isEmpty())
+ contents = new ArrayList<>();
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/DocType.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/DocType.java
new file mode 100644
index 00000000000..469ee40743f
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/DocType.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html.markup;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
+
+/**
+ * Class for generating document type for HTML pages of javadoc output.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Bhavesh Patel
+ */
+public class DocType extends Content {
+
+ private String docType;
+
+ public static final DocType TRANSITIONAL =
+ new DocType("Transitional", "http://www.w3.org/TR/html4/loose.dtd");
+
+ public static final DocType HTML5 = new DocType();
+
+ /**
+ * Constructor to construct a DocType object.
+ *
+ * @param type the doctype to be added
+ * @param dtd the dtd of the doctype
+ */
+ private DocType(String type, String dtd) {
+ docType = "" + DocletConstants.NL;
+ }
+
+ /**
+ * Constructor to construct a DocType object.
+ */
+ private DocType() {
+ docType = "" + DocletConstants.NL;
+ }
+
+ /**
+ * This method is not supported by the class.
+ *
+ * @param content content that needs to be added
+ * @throws DocletAbortException this method will always throw a
+ * DocletAbortException because it
+ * is not supported.
+ */
+ public void addContent(Content content) {
+ throw new DocletAbortException("not supported");
+ }
+
+ /**
+ * This method is not supported by the class.
+ *
+ * @param stringContent string content that needs to be added
+ * @throws DocletAbortException this method will always throw a
+ * DocletAbortException because it
+ * is not supported.
+ */
+ public void addContent(String stringContent) {
+ throw new DocletAbortException("not supported");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isEmpty() {
+ return (docType.length() == 0);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean write(Writer out, boolean atNewline) throws IOException {
+ out.write(docType);
+ return true; // guaranteed by constructor
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlAttr.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlAttr.java
new file mode 100644
index 00000000000..69ae2aa5c0e
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlAttr.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html.markup;
+
+import jdk.javadoc.internal.doclets.toolkit.util.Utils;
+
+/**
+ * Enum representing HTML tag attributes.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Bhavesh Patel
+ */
+public enum HtmlAttr {
+ ALT,
+ CLASS,
+ CLEAR,
+ COLS,
+ CONTENT,
+ DISABLED,
+ HREF,
+ HTTP_EQUIV("http-equiv"),
+ ID,
+ LANG,
+ NAME,
+ ONLOAD,
+ REL,
+ ROLE,
+ ROWS,
+ SCOPE,
+ SCROLLING,
+ SRC,
+ SUMMARY,
+ TARGET,
+ TITLE,
+ TYPE,
+ VALUE,
+ WIDTH;
+
+ private final String value;
+
+ public enum Role {
+
+ BANNER,
+ CONTENTINFO,
+ MAIN,
+ NAVIGATION,
+ REGION;
+
+ private final String role;
+
+ Role() {
+ role = Utils.toLowerCase(name());
+ }
+
+ public String toString() {
+ return role;
+ }
+ }
+
+ HtmlAttr() {
+ this.value = Utils.toLowerCase(name());
+ }
+
+ HtmlAttr(String name) {
+ this.value = name;
+ }
+
+ public String toString() {
+ return value;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlConstants.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlConstants.java
new file mode 100644
index 00000000000..b1e03e3e49b
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlConstants.java
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html.markup;
+
+import jdk.javadoc.internal.doclets.toolkit.Content;
+
+/**
+ * Stores constants for Html Doclet.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Bhavesh Patel
+ */
+public class HtmlConstants {
+
+ /**
+ * Marker to identify start of top navigation bar.
+ */
+ public static final Content START_OF_TOP_NAVBAR =
+ new Comment("========= START OF TOP NAVBAR =======");
+
+ /**
+ * Marker to identify start of bottom navigation bar.
+ */
+ public static final Content START_OF_BOTTOM_NAVBAR =
+ new Comment("======= START OF BOTTOM NAVBAR ======");
+
+ /**
+ * Marker to identify end of top navigation bar.
+ */
+ public static final Content END_OF_TOP_NAVBAR =
+ new Comment("========= END OF TOP NAVBAR =========");
+
+ /**
+ * Marker to identify end of bottom navigation bar.
+ */
+ public static final Content END_OF_BOTTOM_NAVBAR =
+ new Comment("======== END OF BOTTOM NAVBAR =======");
+
+ /**
+ * Marker to identify start of class data.
+ */
+ public static final Content START_OF_CLASS_DATA =
+ new Comment("======== START OF CLASS DATA ========");
+
+ /**
+ * Marker to identify end of class data.
+ */
+ public static final Content END_OF_CLASS_DATA =
+ new Comment("========= END OF CLASS DATA =========");
+
+ /**
+ * Marker to identify start of nested class summary.
+ */
+ public static final Content START_OF_NESTED_CLASS_SUMMARY =
+ new Comment("======== NESTED CLASS SUMMARY ========");
+
+ /**
+ * Marker to identify start of annotation type optional member summary.
+ */
+ public static final Content START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY =
+ new Comment("=========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY ===========");
+
+ /**
+ * Marker to identify start of annotation type required member summary.
+ */
+ public static final Content START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY =
+ new Comment("=========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY ===========");
+
+ /**
+ * Marker to identify start of annotation type required member summary.
+ */
+ public static final Content START_OF_ANNOTATION_TYPE_FIELD_SUMMARY =
+ new Comment("=========== ANNOTATION TYPE FIELD SUMMARY ===========");
+
+ /**
+ * Marker to identify start of constructor summary.
+ */
+ public static final Content START_OF_CONSTRUCTOR_SUMMARY =
+ new Comment("======== CONSTRUCTOR SUMMARY ========");
+
+ /**
+ * Marker to identify start of enum constants summary.
+ */
+ public static final Content START_OF_ENUM_CONSTANT_SUMMARY =
+ new Comment("=========== ENUM CONSTANT SUMMARY ===========");
+
+ /**
+ * Marker to identify start of field summary.
+ */
+ public static final Content START_OF_FIELD_SUMMARY =
+ new Comment("=========== FIELD SUMMARY ===========");
+
+ /**
+ * Marker to identify start of properties summary.
+ */
+ public static final Content START_OF_PROPERTY_SUMMARY =
+ new Comment("=========== PROPERTY SUMMARY ===========");
+
+ /**
+ * Marker to identify start of method summary.
+ */
+ public static final Content START_OF_METHOD_SUMMARY =
+ new Comment("========== METHOD SUMMARY ===========");
+
+ /**
+ * Marker to identify start of annotation type details.
+ */
+ public static final Content START_OF_ANNOTATION_TYPE_DETAILS =
+ new Comment("============ ANNOTATION TYPE MEMBER DETAIL ===========");
+
+ /**
+ * Marker to identify start of annotation type field details.
+ */
+ public static final Content START_OF_ANNOTATION_TYPE_FIELD_DETAILS =
+ new Comment("============ ANNOTATION TYPE FIELD DETAIL ===========");
+
+ /**
+ * Marker to identify start of method details.
+ */
+ public static final Content START_OF_METHOD_DETAILS =
+ new Comment("============ METHOD DETAIL ==========");
+
+ /**
+ * Marker to identify start of field details.
+ */
+ public static final Content START_OF_FIELD_DETAILS =
+ new Comment("============ FIELD DETAIL ===========");
+
+ /**
+ * Marker to identify start of property details.
+ */
+ public static final Content START_OF_PROPERTY_DETAILS =
+ new Comment("============ PROPERTY DETAIL ===========");
+
+ /**
+ * Marker to identify start of constructor details.
+ */
+ public static final Content START_OF_CONSTRUCTOR_DETAILS =
+ new Comment("========= CONSTRUCTOR DETAIL ========");
+
+ /**
+ * Marker to identify start of enum constants details.
+ */
+ public static final Content START_OF_ENUM_CONSTANT_DETAILS =
+ new Comment("============ ENUM CONSTANT DETAIL ===========");
+
+ /**
+ * Html tag for the page title heading.
+ */
+ public static final HtmlTag TITLE_HEADING = HtmlTag.H1;
+
+ /**
+ * Html tag for the class page title heading.
+ */
+ public static final HtmlTag CLASS_PAGE_HEADING = HtmlTag.H2;
+
+ /**
+ * Html tag for the content heading.
+ */
+ public static final HtmlTag CONTENT_HEADING = HtmlTag.H2;
+
+ /**
+ * Html tag for the package name heading.
+ */
+ public static final HtmlTag PACKAGE_HEADING = HtmlTag.H2;
+
+ /**
+ * Html tag for the member summary heading.
+ */
+ public static final HtmlTag SUMMARY_HEADING = HtmlTag.H3;
+
+ /**
+ * Html tag for the inherited member summary heading.
+ */
+ public static final HtmlTag INHERITED_SUMMARY_HEADING = HtmlTag.H3;
+
+ /**
+ * Html tag for the member details heading.
+ */
+ public static final HtmlTag DETAILS_HEADING = HtmlTag.H3;
+
+ /**
+ * Html tag for the serialized member heading.
+ */
+ public static final HtmlTag SERIALIZED_MEMBER_HEADING = HtmlTag.H3;
+
+ /**
+ * Html tag for the member heading.
+ */
+ public static final HtmlTag MEMBER_HEADING = HtmlTag.H4;
+
+ /**
+ * Default charset for HTML.
+ */
+ public static final String HTML_DEFAULT_CHARSET = "utf-8";
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocWriter.java
new file mode 100644
index 00000000000..d7aec841525
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocWriter.java
@@ -0,0 +1,361 @@
+/*
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html.markup;
+
+import java.io.*;
+import java.util.*;
+
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+
+import jdk.javadoc.internal.doclets.formats.html.ConfigurationImpl;
+import jdk.javadoc.internal.doclets.formats.html.SectionName;
+import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
+import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+
+
+/**
+ * Class for the Html Format Code Generation specific to JavaDoc.
+ * This Class contains methods related to the Html Code Generation which
+ * are used by the Sub-Classes in the package jdk.javadoc.internal.tool.standard.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Atul M Dambalkar
+ * @author Robert Field
+ */
+public abstract class HtmlDocWriter extends HtmlWriter {
+
+ public static final String CONTENT_TYPE = "text/html";
+
+ DocPath pathToRoot;
+
+ /**
+ * Constructor. Initializes the destination file name through the super
+ * class HtmlWriter.
+ *
+ * @param filename String file name.
+ */
+ public HtmlDocWriter(Configuration configuration, DocPath filename)
+ throws IOException {
+ super(configuration, filename);
+ this.pathToRoot = filename.parent().invert();
+ configuration.message.notice("doclet.Generating_0",
+ DocFile.createFileForOutput(configuration, filename).getPath());
+ }
+
+ /**
+ * Accessor for configuration.
+ */
+ public abstract Configuration configuration();
+
+ public Content getHyperLink(DocPath link, String label) {
+ return getHyperLink(link, new StringContent(label), false, "", "", "");
+ }
+
+ /**
+ * Get Html Hyper Link Content.
+ *
+ * @param where Position of the link in the file. Character '#' is not
+ * needed.
+ * @param label Tag for the link.
+ * @return a content tree for the hyper link
+ */
+ public Content getHyperLink(String where,
+ Content label) {
+ return getHyperLink(getDocLink(where), label, "", "");
+ }
+
+ /**
+ * Get Html Hyper Link Content.
+ *
+ * @param sectionName The section name to which the link will be created.
+ * @param label Tag for the link.
+ * @return a content tree for the hyper link
+ */
+ public Content getHyperLink(SectionName sectionName,
+ Content label) {
+ return getHyperLink(getDocLink(sectionName), label, "", "");
+ }
+
+ /**
+ * Get Html Hyper Link Content.
+ *
+ * @param sectionName The section name combined with where to which the link
+ * will be created.
+ * @param where The fragment combined with sectionName to which the link
+ * will be created.
+ * @param label Tag for the link.
+ * @return a content tree for the hyper link
+ */
+ public Content getHyperLink(SectionName sectionName, String where,
+ Content label) {
+ return getHyperLink(getDocLink(sectionName, where), label, "", "");
+ }
+
+ /**
+ * Get the link.
+ *
+ * @param where Position of the link in the file.
+ * @return a DocLink object for the hyper link
+ */
+ public DocLink getDocLink(String where) {
+ return DocLink.fragment(getName(where));
+ }
+
+ /**
+ * Get the link.
+ *
+ * @param sectionName The section name to which the link will be created.
+ * @return a DocLink object for the hyper link
+ */
+ public DocLink getDocLink(SectionName sectionName) {
+ return DocLink.fragment(sectionName.getName());
+ }
+
+ /**
+ * Get the link.
+ *
+ * @param sectionName The section name combined with where to which the link
+ * will be created.
+ * @param where The fragment combined with sectionName to which the link
+ * will be created.
+ * @return a DocLink object for the hyper link
+ */
+ public DocLink getDocLink(SectionName sectionName, String where) {
+ return DocLink.fragment(sectionName.getName() + getName(where));
+ }
+
+ /**
+ * Convert the name to a valid HTML name.
+ *
+ * @param name the name that needs to be converted to valid HTML name.
+ * @return a valid HTML name string.
+ */
+ public String getName(String name) {
+ StringBuilder sb = new StringBuilder();
+ char ch;
+ /* The HTML 4 spec at http://www.w3.org/TR/html4/types.html#h-6.2 mentions
+ * that the name/id should begin with a letter followed by other valid characters.
+ * The HTML 5 spec (draft) is more permissive on names/ids where the only restriction
+ * is that it should be at least one character long and should not contain spaces.
+ * The spec draft is @ http://www.w3.org/html/wg/drafts/html/master/dom.html#the-id-attribute.
+ *
+ * For HTML 4, we need to check for non-characters at the beginning of the name and
+ * substitute it accordingly, "_" and "$" can appear at the beginning of a member name.
+ * The method substitutes "$" with "Z:Z:D" and will prefix "_" with "Z:Z".
+ */
+ for (int i = 0; i < name.length(); i++) {
+ ch = name.charAt(i);
+ switch (ch) {
+ case '(':
+ case ')':
+ case '<':
+ case '>':
+ case ',':
+ sb.append('-');
+ break;
+ case ' ':
+ case '[':
+ break;
+ case ']':
+ sb.append(":A");
+ break;
+ // Any appearance of $ needs to be substituted with ":D" and not with hyphen
+ // since a field name "P$$ and a method P(), both valid member names, can end
+ // up as "P--". A member name beginning with $ needs to be substituted with
+ // "Z:Z:D".
+ case '$':
+ if (i == 0)
+ sb.append("Z:Z");
+ sb.append(":D");
+ break;
+ // A member name beginning with _ needs to be prefixed with "Z:Z" since valid anchor
+ // names can only begin with a letter.
+ case '_':
+ if (i == 0)
+ sb.append("Z:Z");
+ sb.append(ch);
+ break;
+ default:
+ sb.append(ch);
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Get Html hyperlink.
+ *
+ * @param link path of the file.
+ * @param label Tag for the link.
+ * @return a content tree for the hyper link
+ */
+ public Content getHyperLink(DocPath link, Content label) {
+ return getHyperLink(link, label, "", "");
+ }
+
+ public Content getHyperLink(DocLink link, Content label) {
+ return getHyperLink(link, label, "", "");
+ }
+
+ public Content getHyperLink(DocPath link,
+ Content label, boolean strong,
+ String stylename, String title, String target) {
+ return getHyperLink(new DocLink(link), label, strong,
+ stylename, title, target);
+ }
+
+ public Content getHyperLink(DocLink link,
+ Content label, boolean strong,
+ String stylename, String title, String target) {
+ Content body = label;
+ if (strong) {
+ body = HtmlTree.SPAN(HtmlStyle.typeNameLink, body);
+ }
+ if (stylename != null && stylename.length() != 0) {
+ HtmlTree t = new HtmlTree(HtmlTag.FONT, body);
+ t.addAttr(HtmlAttr.CLASS, stylename);
+ body = t;
+ }
+ HtmlTree l = HtmlTree.A(link.toString(), body);
+ if (title != null && title.length() != 0) {
+ l.addAttr(HtmlAttr.TITLE, title);
+ }
+ if (target != null && target.length() != 0) {
+ l.addAttr(HtmlAttr.TARGET, target);
+ }
+ return l;
+ }
+
+ /**
+ * Get Html Hyper Link.
+ *
+ * @param link String name of the file.
+ * @param label Tag for the link.
+ * @param title String that describes the link's content for accessibility.
+ * @param target Target frame.
+ * @return a content tree for the hyper link.
+ */
+ public Content getHyperLink(DocPath link, Content label, String title, String target) {
+ return getHyperLink(new DocLink(link), label, title, target);
+ }
+
+ public Content getHyperLink(DocLink link, Content label, String title, String target) {
+ HtmlTree anchor = HtmlTree.A(link.toString(), label);
+ if (title != null && title.length() != 0) {
+ anchor.addAttr(HtmlAttr.TITLE, title);
+ }
+ if (target != null && target.length() != 0) {
+ anchor.addAttr(HtmlAttr.TARGET, target);
+ }
+ return anchor;
+ }
+
+ /**
+ * Get the enclosed name of the package
+ *
+ * @param te TypeElement
+ * @return the name
+ */
+ public String getEnclosingPackageName(TypeElement te) {
+
+ PackageElement encl = configuration.utils.containingPackage(te);
+ return (encl.isUnnamed()) ? "" : (encl.getQualifiedName() + ".");
+ }
+
+ public boolean getMemberDetailsListPrinted() {
+ return memberDetailsListPrinted;
+ }
+
+ /**
+ * Print the frames version of the Html file header.
+ * Called only when generating an HTML frames file.
+ *
+ * @param title Title of this HTML document
+ * @param configuration the configuration object
+ * @param body the body content tree to be added to the HTML document
+ */
+ public void printFramesDocument(String title, ConfigurationImpl configuration,
+ HtmlTree body) throws IOException {
+ Content htmlDocType = configuration.isOutputHtml5()
+ ? DocType.HTML5
+ : DocType.TRANSITIONAL;
+ Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
+ Content head = new HtmlTree(HtmlTag.HEAD);
+ head.addContent(getGeneratedBy(!configuration.notimestamp));
+ Content windowTitle = HtmlTree.TITLE(new StringContent(title));
+ head.addContent(windowTitle);
+ Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE,
+ (configuration.charset.length() > 0) ?
+ configuration.charset : HtmlConstants.HTML_DEFAULT_CHARSET);
+ head.addContent(meta);
+ head.addContent(getStyleSheetProperties(configuration));
+ head.addContent(getFramesJavaScript());
+ Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
+ head, body);
+ Content htmlDocument = new HtmlDocument(htmlDocType,
+ htmlComment, htmlTree);
+ write(htmlDocument);
+ }
+
+ /**
+ * Returns a link to the stylesheet file.
+ *
+ * @return an HtmlTree for the lINK tag which provides the stylesheet location
+ */
+ public HtmlTree getStyleSheetProperties(ConfigurationImpl configuration) {
+ String stylesheetfile = configuration.stylesheetfile;
+ DocPath stylesheet;
+ if (stylesheetfile.isEmpty()) {
+ stylesheet = DocPaths.STYLESHEET;
+ } else {
+ DocFile file = DocFile.createFileForInput(configuration, stylesheetfile);
+ stylesheet = DocPath.create(file.getName());
+ }
+ HtmlTree link = HtmlTree.LINK("stylesheet", "text/css",
+ pathToRoot.resolve(stylesheet).getPath(),
+ "Style");
+ return link;
+ }
+
+ protected Comment getGeneratedBy(boolean timestamp) {
+ String text = "Generated by javadoc"; // marker string, deliberately not localized
+ if (timestamp) {
+ Calendar calendar = new GregorianCalendar(TimeZone.getDefault());
+ Date today = calendar.getTime();
+ text += " ("+ configuration.getDocletSpecificBuildDate() + ") on " + today;
+ }
+ return new Comment(text);
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocument.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocument.java
new file mode 100644
index 00000000000..8f995c7c772
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocument.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html.markup;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.*;
+
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+
+/**
+ * Class for generating an HTML document for javadoc output.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Bhavesh Patel
+ */
+public class HtmlDocument extends Content {
+
+ private List docContent = Collections.emptyList();
+
+ /**
+ * Constructor to construct an HTML document.
+ *
+ * @param docType document type for the HTML document
+ * @param docComment comment for the document
+ * @param htmlTree HTML tree of the document
+ */
+ public HtmlDocument(Content docType, Content docComment, Content htmlTree) {
+ docContent = new ArrayList<>();
+ addContent(nullCheck(docType));
+ addContent(nullCheck(docComment));
+ addContent(nullCheck(htmlTree));
+ }
+
+ /**
+ * Constructor to construct an HTML document.
+ *
+ * @param docType document type for the HTML document
+ * @param htmlTree HTML tree of the document
+ */
+ public HtmlDocument(Content docType, Content htmlTree) {
+ docContent = new ArrayList<>();
+ addContent(nullCheck(docType));
+ addContent(nullCheck(htmlTree));
+ }
+
+ /**
+ * Adds content for the HTML document.
+ *
+ * @param htmlContent html content to be added
+ */
+ public final void addContent(Content htmlContent) {
+ if (htmlContent.isValid())
+ docContent.add(htmlContent);
+ }
+
+ /**
+ * This method is not supported by the class.
+ *
+ * @param stringContent string content that needs to be added
+ * @throws DocletAbortException this method will always throw a
+ * DocletAbortException because it
+ * is not supported.
+ */
+ public void addContent(String stringContent) {
+ throw new DocletAbortException("not supported");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isEmpty() {
+ return (docContent.isEmpty());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean write(Writer out, boolean atNewline) throws IOException {
+ for (Content c : docContent)
+ atNewline = c.write(out, atNewline);
+ return atNewline;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java
new file mode 100644
index 00000000000..ccaf4769276
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlStyle.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html.markup;
+
+/**
+ * Enum representing HTML styles. The name map to values in the CSS file.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Bhavesh Patel
+ */
+public enum HtmlStyle {
+ aboutLanguage,
+ activeTableTab,
+ altColor,
+ bar,
+ block,
+ blockList,
+ blockListLast,
+ bottomNav,
+ circle,
+ classUseContainer,
+ colFirst,
+ colLast,
+ colOne,
+ constantsSummary,
+ constantValuesContainer,
+ contentContainer,
+ deprecatedContent,
+ deprecatedLabel,
+ deprecatedSummary,
+ deprecationComment,
+ description,
+ descfrmTypeLabel,
+ details,
+ docSummary,
+ emphasizedPhrase,
+ fixedNav,
+ header,
+ horizontal,
+ footer,
+ indexContainer,
+ indexNav,
+ inheritance,
+ interfaceName,
+ leftContainer,
+ leftTop,
+ leftBottom,
+ legalCopy,
+ mainContainer,
+ memberNameLabel,
+ memberNameLink,
+ memberSummary,
+ nameValue,
+ navBarCell1Rev,
+ navList,
+ navListSearch,
+ overrideSpecifyLabel,
+ overviewSummary,
+ packageHierarchyLabel,
+ paramLabel,
+ returnLabel,
+ rightContainer,
+ rightIframe,
+ rowColor,
+ searchTagLink,
+ seeLabel,
+ serializedFormContainer,
+ simpleTagLabel,
+ skipNav,
+ sourceContainer,
+ sourceLineNo,
+ subNav,
+ subNavList,
+ subTitle,
+ summary,
+ tabEnd,
+ tableTab,
+ throwsLabel,
+ title,
+ topNav,
+ typeNameLabel,
+ typeNameLink,
+ typeSummary,
+ useSummary
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTag.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTag.java
new file mode 100644
index 00000000000..3bc64ea959f
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTag.java
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html.markup;
+
+import jdk.javadoc.internal.doclets.toolkit.util.Utils;
+
+/**
+ * Enum representing HTML tags.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Bhavesh Patel
+ */
+public enum HtmlTag {
+ A(BlockType.INLINE, EndTag.END),
+ BLOCKQUOTE,
+ BODY(BlockType.OTHER, EndTag.END),
+ BR(BlockType.INLINE, EndTag.NOEND),
+ CAPTION,
+ CENTER(HtmlVersion.HTML4),
+ CODE(BlockType.INLINE, EndTag.END),
+ DD,
+ DIR(HtmlVersion.HTML4),
+ DIV,
+ DL,
+ DT,
+ EM(BlockType.INLINE, EndTag.END),
+ FONT(HtmlVersion.HTML4, BlockType.INLINE, EndTag.END),
+ FOOTER(HtmlVersion.HTML5),
+ H1,
+ H2,
+ H3,
+ H4,
+ H5,
+ H6,
+ HEAD(BlockType.OTHER, EndTag.END),
+ HEADER(HtmlVersion.HTML5),
+ HR(BlockType.BLOCK, EndTag.NOEND),
+ HTML(BlockType.OTHER, EndTag.END),
+ I(BlockType.INLINE, EndTag.END),
+ IFRAME(BlockType.OTHER, EndTag.END),
+ IMG(BlockType.INLINE, EndTag.NOEND),
+ INPUT(BlockType.BLOCK, EndTag.NOEND),
+ LI,
+ LISTING,
+ LINK(BlockType.OTHER, EndTag.NOEND),
+ MAIN(HtmlVersion.HTML5),
+ MENU,
+ META(BlockType.OTHER, EndTag.NOEND),
+ NAV(HtmlVersion.HTML5),
+ NOSCRIPT(BlockType.OTHER, EndTag.END),
+ OL,
+ P,
+ PRE,
+ SCRIPT(BlockType.OTHER, EndTag.END),
+ SECTION(HtmlVersion.HTML5),
+ SMALL(BlockType.INLINE, EndTag.END),
+ SPAN(BlockType.INLINE, EndTag.END),
+ STRONG(BlockType.INLINE, EndTag.END),
+ SUB(BlockType.INLINE, EndTag.END),
+ TABLE,
+ TBODY,
+ TD,
+ TH,
+ TITLE(BlockType.OTHER, EndTag.END),
+ TR,
+ TT(HtmlVersion.HTML4, BlockType.INLINE, EndTag.END),
+ UL;
+
+ public final BlockType blockType;
+ public final EndTag endTag;
+ public final String value;
+ public final HtmlVersion htmlVersion;
+
+ /**
+ * Enum representing the type of HTML element.
+ */
+ public static enum BlockType {
+ BLOCK,
+ INLINE,
+ OTHER
+ }
+
+ /**
+ * Enum representing HTML end tag requirement.
+ */
+ public static enum EndTag {
+ END,
+ NOEND
+ }
+
+ HtmlTag() {
+ this(HtmlVersion.ALL, BlockType.BLOCK, EndTag.END);
+ }
+
+ HtmlTag(HtmlVersion htmlVersion) {
+ this(htmlVersion, BlockType.BLOCK, EndTag.END);
+ }
+
+ HtmlTag(BlockType blockType, EndTag endTag ) {
+ this(HtmlVersion.ALL, blockType, endTag);
+ }
+
+ HtmlTag(HtmlVersion htmlVersion, BlockType blockType, EndTag endTag ) {
+ this.htmlVersion = htmlVersion;
+ this.blockType = blockType;
+ this.endTag = endTag;
+ this.value = Utils.toLowerCase(name());
+ }
+
+ /**
+ * Returns true if the end tag is required. This is specific to the standard
+ * doclet and does not exactly resemble the W3C specifications.
+ *
+ * @return true if end tag needs to be displayed else return false
+ */
+ public boolean endTagRequired() {
+ return (endTag == EndTag.END);
+ }
+
+ /**
+ * Returns true if the tag is allowed in the output HTML version of this javadoc run.
+ *
+ * @param htmlVer the output HTML version for this javadoc run
+ * @return true if the tag is allowed
+ */
+ public boolean allowTag(HtmlVersion htmlVer) {
+ return (this.htmlVersion == HtmlVersion.ALL || this.htmlVersion == htmlVer);
+ }
+
+ public String toString() {
+ return value;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java
new file mode 100644
index 00000000000..93b9071dcf7
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlTree.java
@@ -0,0 +1,978 @@
+/*
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html.markup;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr.Role;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
+
+/**
+ * Class for generating HTML tree for javadoc output.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Bhavesh Patel
+ */
+public class HtmlTree extends Content {
+
+ private HtmlTag htmlTag;
+ private Map attrs = Collections.emptyMap();
+ private List content = Collections.emptyList();
+ public static final Content EMPTY = new StringContent("");
+
+ /**
+ * Constructor to construct HtmlTree object.
+ *
+ * @param tag HTML tag for the HtmlTree object
+ */
+ public HtmlTree(HtmlTag tag) {
+ htmlTag = nullCheck(tag);
+ }
+
+ /**
+ * Constructor to construct HtmlTree object.
+ *
+ * @param tag HTML tag for the HtmlTree object
+ * @param contents contents to be added to the tree
+ */
+ public HtmlTree(HtmlTag tag, Content... contents) {
+ this(tag);
+ for (Content content: contents)
+ addContent(content);
+ }
+
+ /**
+ * Adds an attribute for the HTML tag.
+ *
+ * @param attrName name of the attribute
+ * @param attrValue value of the attribute
+ */
+ public void addAttr(HtmlAttr attrName, String attrValue) {
+ if (attrs.isEmpty())
+ attrs = new LinkedHashMap<>(3);
+ attrs.put(nullCheck(attrName), escapeHtmlChars(attrValue));
+ }
+
+ public void setTitle(Content body) {
+ addAttr(HtmlAttr.TITLE, stripHtml(body));
+ }
+
+ public void setRole(Role role) {
+ addAttr(HtmlAttr.ROLE, role.toString());
+ }
+
+ /**
+ * Adds a style for the HTML tag.
+ *
+ * @param style style to be added
+ */
+ public void addStyle(HtmlStyle style) {
+ addAttr(HtmlAttr.CLASS, style.toString());
+ }
+
+ /**
+ * Adds content for the HTML tag.
+ *
+ * @param tagContent tag content to be added
+ */
+ public void addContent(Content tagContent) {
+ if (tagContent instanceof ContentBuilder) {
+ for (Content content: ((ContentBuilder)tagContent).contents) {
+ addContent(content);
+ }
+ }
+ else if (tagContent == HtmlTree.EMPTY || tagContent.isValid()) {
+ if (content.isEmpty())
+ content = new ArrayList<>();
+ content.add(tagContent);
+ }
+ }
+
+ /**
+ * This method adds a string content to the htmltree. If the last content member
+ * added is a StringContent, append the string to that StringContent or else
+ * create a new StringContent and add it to the html tree.
+ *
+ * @param stringContent string content that needs to be added
+ */
+ public void addContent(String stringContent) {
+ if (!content.isEmpty()) {
+ Content lastContent = content.get(content.size() - 1);
+ if (lastContent instanceof StringContent)
+ lastContent.addContent(stringContent);
+ else
+ addContent(new StringContent(stringContent));
+ }
+ else
+ addContent(new StringContent(stringContent));
+ }
+
+ public int charCount() {
+ int n = 0;
+ for (Content c : content)
+ n += c.charCount();
+ return n;
+ }
+
+ /**
+ * Given a string, escape all special html characters and
+ * return the result.
+ *
+ * @param s The string to check.
+ * @return the original string with all of the HTML characters escaped.
+ */
+ private static String escapeHtmlChars(String s) {
+ for (int i = 0; i < s.length(); i++) {
+ char ch = s.charAt(i);
+ switch (ch) {
+ // only start building a new string if we need to
+ case '<': case '>': case '&':
+ StringBuilder sb = new StringBuilder(s.substring(0, i));
+ for ( ; i < s.length(); i++) {
+ ch = s.charAt(i);
+ switch (ch) {
+ case '<': sb.append("<"); break;
+ case '>': sb.append(">"); break;
+ case '&': sb.append("&"); break;
+ default: sb.append(ch); break;
+ }
+ }
+ return sb.toString();
+ }
+ }
+ return s;
+ }
+
+ /**
+ * A set of ASCII URI characters to be left unencoded.
+ */
+ public static final BitSet NONENCODING_CHARS = new BitSet(256);
+
+ static {
+ // alphabetic characters
+ for (int i = 'a'; i <= 'z'; i++) {
+ NONENCODING_CHARS.set(i);
+ }
+ for (int i = 'A'; i <= 'Z'; i++) {
+ NONENCODING_CHARS.set(i);
+ }
+ // numeric characters
+ for (int i = '0'; i <= '9'; i++) {
+ NONENCODING_CHARS.set(i);
+ }
+ // Reserved characters as per RFC 3986. These are set of delimiting characters.
+ String noEnc = ":/?#[]@!$&'()*+,;=";
+ // Unreserved characters as per RFC 3986 which should not be percent encoded.
+ noEnc += "-._~";
+ for (int i = 0; i < noEnc.length(); i++) {
+ NONENCODING_CHARS.set(noEnc.charAt(i));
+ }
+ }
+
+ private static String encodeURL(String url) {
+ StringBuilder sb = new StringBuilder();
+ for (byte c : url.getBytes(Charset.forName("UTF-8"))) {
+ if (NONENCODING_CHARS.get(c & 0xFF)) {
+ sb.append((char) c);
+ } else {
+ sb.append(String.format("%%%02X", c & 0xFF));
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Generates an HTML anchor tag.
+ *
+ * @param ref reference url for the anchor tag
+ * @param body content for the anchor tag
+ * @return an HtmlTree object
+ */
+ public static HtmlTree A(String ref, Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.A, nullCheck(body));
+ htmltree.addAttr(HtmlAttr.HREF, encodeURL(ref));
+ return htmltree;
+ }
+
+ /**
+ * Generates an HTML anchor tag with an id or a name attribute and content.
+ *
+ * @param htmlVersion the version of the generated HTML
+ * @param attr name or id attribute for the anchor tag
+ * @param body content for the anchor tag
+ * @return an HtmlTree object
+ */
+ public static HtmlTree A(HtmlVersion htmlVersion, String attr, Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.A);
+ htmltree.addAttr((htmlVersion == HtmlVersion.HTML4)
+ ? HtmlAttr.NAME
+ : HtmlAttr.ID,
+ nullCheck(attr));
+ htmltree.addContent(nullCheck(body));
+ return htmltree;
+ }
+
+ /**
+ * Generates an HTML anchor tag with id attribute and a body.
+ *
+ * @param id id for the anchor tag
+ * @param body body for the anchor tag
+ * @return an HtmlTree object
+ */
+ public static HtmlTree A_ID(String id, Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.A);
+ htmltree.addAttr(HtmlAttr.ID, nullCheck(id));
+ htmltree.addContent(nullCheck(body));
+ return htmltree;
+ }
+
+ /**
+ * Generates a CAPTION tag with some content.
+ *
+ * @param body content for the tag
+ * @return an HtmlTree object for the CAPTION tag
+ */
+ public static HtmlTree CAPTION(Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.CAPTION, nullCheck(body));
+ return htmltree;
+ }
+
+ /**
+ * Generates a CODE tag with some content.
+ *
+ * @param body content for the tag
+ * @return an HtmlTree object for the CODE tag
+ */
+ public static HtmlTree CODE(Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.CODE, nullCheck(body));
+ return htmltree;
+ }
+
+ /**
+ * Generates a DD tag with some content.
+ *
+ * @param body content for the tag
+ * @return an HtmlTree object for the DD tag
+ */
+ public static HtmlTree DD(Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.DD, nullCheck(body));
+ return htmltree;
+ }
+
+ /**
+ * Generates a DL tag with some content.
+ *
+ * @param body content for the tag
+ * @return an HtmlTree object for the DL tag
+ */
+ public static HtmlTree DL(Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.DL, nullCheck(body));
+ return htmltree;
+ }
+
+ /**
+ * Generates a DIV tag with the style class attributes. It also encloses
+ * a content.
+ *
+ * @param styleClass stylesheet class for the tag
+ * @param body content for the tag
+ * @return an HtmlTree object for the DIV tag
+ */
+ public static HtmlTree DIV(HtmlStyle styleClass, Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.DIV, nullCheck(body));
+ if (styleClass != null)
+ htmltree.addStyle(styleClass);
+ return htmltree;
+ }
+
+ /**
+ * Generates a DIV tag with some content.
+ *
+ * @param body content for the tag
+ * @return an HtmlTree object for the DIV tag
+ */
+ public static HtmlTree DIV(Content body) {
+ return DIV(null, body);
+ }
+
+ /**
+ * Generates a DT tag with some content.
+ *
+ * @param body content for the tag
+ * @return an HtmlTree object for the DT tag
+ */
+ public static HtmlTree DT(Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.DT, nullCheck(body));
+ return htmltree;
+ }
+
+ /**
+ * Generates a FOOTER tag with role attribute.
+ *
+ * @return an HtmlTree object for the FOOTER tag
+ */
+ public static HtmlTree FOOTER() {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.FOOTER);
+ htmltree.setRole(Role.CONTENTINFO);
+ return htmltree;
+ }
+
+ /**
+ * Generates a HEADER tag with role attribute.
+ *
+ * @return an HtmlTree object for the HEADER tag
+ */
+ public static HtmlTree HEADER() {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.HEADER);
+ htmltree.setRole(Role.BANNER);
+ return htmltree;
+ }
+
+ /**
+ * Generates a heading tag (h1 to h6) with the title and style class attributes. It also encloses
+ * a content.
+ *
+ * @param headingTag the heading tag to be generated
+ * @param printTitle true if title for the tag needs to be printed else false
+ * @param styleClass stylesheet class for the tag
+ * @param body content for the tag
+ * @return an HtmlTree object for the tag
+ */
+ public static HtmlTree HEADING(HtmlTag headingTag, boolean printTitle,
+ HtmlStyle styleClass, Content body) {
+ HtmlTree htmltree = new HtmlTree(headingTag, nullCheck(body));
+ if (printTitle)
+ htmltree.setTitle(body);
+ if (styleClass != null)
+ htmltree.addStyle(styleClass);
+ return htmltree;
+ }
+
+ /**
+ * Generates a heading tag (h1 to h6) with style class attribute. It also encloses
+ * a content.
+ *
+ * @param headingTag the heading tag to be generated
+ * @param styleClass stylesheet class for the tag
+ * @param body content for the tag
+ * @return an HtmlTree object for the tag
+ */
+ public static HtmlTree HEADING(HtmlTag headingTag, HtmlStyle styleClass, Content body) {
+ return HEADING(headingTag, false, styleClass, body);
+ }
+
+ /**
+ * Generates a heading tag (h1 to h6) with the title attribute. It also encloses
+ * a content.
+ *
+ * @param headingTag the heading tag to be generated
+ * @param printTitle true if the title for the tag needs to be printed else false
+ * @param body content for the tag
+ * @return an HtmlTree object for the tag
+ */
+ public static HtmlTree HEADING(HtmlTag headingTag, boolean printTitle, Content body) {
+ return HEADING(headingTag, printTitle, null, body);
+ }
+
+ /**
+ * Generates a heading tag (h1 to h6) with some content.
+ *
+ * @param headingTag the heading tag to be generated
+ * @param body content for the tag
+ * @return an HtmlTree object for the tag
+ */
+ public static HtmlTree HEADING(HtmlTag headingTag, Content body) {
+ return HEADING(headingTag, false, null, body);
+ }
+
+ /**
+ * Generates an HTML tag with lang attribute. It also adds head and body
+ * content to the HTML tree.
+ *
+ * @param lang language for the HTML document
+ * @param head head for the HTML tag
+ * @param body body for the HTML tag
+ * @return an HtmlTree object for the HTML tag
+ */
+ public static HtmlTree HTML(String lang, Content head, Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.HTML, nullCheck(head), nullCheck(body));
+ htmltree.addAttr(HtmlAttr.LANG, nullCheck(lang));
+ return htmltree;
+ }
+
+ /**
+ * Generates a IFRAME tag.
+ *
+ * @param src the url of the document to be shown in the frame
+ * @param name specifies the name of the frame
+ * @param title the title for the frame
+ * @return an HtmlTree object for the IFRAME tag
+ */
+ public static HtmlTree IFRAME(String src, String name, String title) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.IFRAME);
+ htmltree.addAttr(HtmlAttr.SRC, nullCheck(src));
+ htmltree.addAttr(HtmlAttr.NAME, nullCheck(name));
+ htmltree.addAttr(HtmlAttr.TITLE, nullCheck(title));
+ return htmltree;
+ }
+
+ /**
+ * Generates a INPUT tag with some id.
+ *
+ * @param type the type of input
+ * @param id id for the tag
+ * @return an HtmlTree object for the INPUT tag
+ */
+ public static HtmlTree INPUT(String type, String id) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.INPUT);
+ htmltree.addAttr(HtmlAttr.TYPE, nullCheck(type));
+ htmltree.addAttr(HtmlAttr.ID, nullCheck(id));
+ htmltree.addAttr(HtmlAttr.VALUE, " ");
+ htmltree.addAttr(HtmlAttr.DISABLED, "disabled");
+ return htmltree;
+ }
+
+ /**
+ * Generates a LI tag with some content.
+ *
+ * @param body content for the tag
+ * @return an HtmlTree object for the LI tag
+ */
+ public static HtmlTree LI(Content body) {
+ return LI(null, body);
+ }
+
+ /**
+ * Generates a LI tag with some content.
+ *
+ * @param styleClass style for the tag
+ * @param body content for the tag
+ * @return an HtmlTree object for the LI tag
+ */
+ public static HtmlTree LI(HtmlStyle styleClass, Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.LI, nullCheck(body));
+ if (styleClass != null)
+ htmltree.addStyle(styleClass);
+ return htmltree;
+ }
+
+ /**
+ * Generates a LINK tag with the rel, type, href and title attributes.
+ *
+ * @param rel relevance of the link
+ * @param type type of link
+ * @param href the path for the link
+ * @param title title for the link
+ * @return an HtmlTree object for the LINK tag
+ */
+ public static HtmlTree LINK(String rel, String type, String href, String title) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.LINK);
+ htmltree.addAttr(HtmlAttr.REL, nullCheck(rel));
+ htmltree.addAttr(HtmlAttr.TYPE, nullCheck(type));
+ htmltree.addAttr(HtmlAttr.HREF, nullCheck(href));
+ htmltree.addAttr(HtmlAttr.TITLE, nullCheck(title));
+ return htmltree;
+ }
+
+ /**
+ * Generates a MAIN tag with role attribute.
+ *
+ * @return an HtmlTree object for the MAIN tag
+ */
+ public static HtmlTree MAIN() {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.MAIN);
+ htmltree.setRole(Role.MAIN);
+ return htmltree;
+ }
+
+ /**
+ * Generates a MAIN tag with role attribute and some content.
+ *
+ * @param body content of the MAIN tag
+ * @return an HtmlTree object for the MAIN tag
+ */
+ public static HtmlTree MAIN(Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.MAIN, nullCheck(body));
+ htmltree.setRole(Role.MAIN);
+ return htmltree;
+ }
+
+ /**
+ * Generates a MAIN tag with role attribute, style attribute and some content.
+ *
+ * @param styleClass style of the MAIN tag
+ * @param body content of the MAIN tag
+ * @return an HtmlTree object for the MAIN tag
+ */
+ public static HtmlTree MAIN(HtmlStyle styleClass, Content body) {
+ HtmlTree htmltree = HtmlTree.MAIN(body);
+ if (styleClass != null) {
+ htmltree.addStyle(styleClass);
+ }
+ return htmltree;
+ }
+
+ /**
+ * Generates a META tag with the http-equiv, content and charset attributes.
+ *
+ * @param httpEquiv http equiv attribute for the META tag
+ * @param content type of content
+ * @param charSet character set used
+ * @return an HtmlTree object for the META tag
+ */
+ public static HtmlTree META(String httpEquiv, String content, String charSet) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.META);
+ String contentCharset = content + "; charset=" + charSet;
+ htmltree.addAttr(HtmlAttr.HTTP_EQUIV, nullCheck(httpEquiv));
+ htmltree.addAttr(HtmlAttr.CONTENT, contentCharset);
+ return htmltree;
+ }
+
+ /**
+ * Generates a META tag with the name and content attributes.
+ *
+ * @param name name attribute
+ * @param content type of content
+ * @return an HtmlTree object for the META tag
+ */
+ public static HtmlTree META(String name, String content) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.META);
+ htmltree.addAttr(HtmlAttr.NAME, nullCheck(name));
+ htmltree.addAttr(HtmlAttr.CONTENT, nullCheck(content));
+ return htmltree;
+ }
+
+ /**
+ * Generates a NAV tag with the role attribute.
+ *
+ * @return an HtmlTree object for the NAV tag
+ */
+ public static HtmlTree NAV() {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.NAV);
+ htmltree.setRole(Role.NAVIGATION);
+ return htmltree;
+ }
+
+ /**
+ * Generates a NOSCRIPT tag with some content.
+ *
+ * @param body content of the noscript tag
+ * @return an HtmlTree object for the NOSCRIPT tag
+ */
+ public static HtmlTree NOSCRIPT(Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.NOSCRIPT, nullCheck(body));
+ return htmltree;
+ }
+
+ /**
+ * Generates a P tag with some content.
+ *
+ * @param body content of the Paragraph tag
+ * @return an HtmlTree object for the P tag
+ */
+ public static HtmlTree P(Content body) {
+ return P(null, body);
+ }
+
+ /**
+ * Generates a P tag with some content.
+ *
+ * @param styleClass style of the Paragraph tag
+ * @param body content of the Paragraph tag
+ * @return an HtmlTree object for the P tag
+ */
+ public static HtmlTree P(HtmlStyle styleClass, Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.P, nullCheck(body));
+ if (styleClass != null)
+ htmltree.addStyle(styleClass);
+ return htmltree;
+ }
+
+ /**
+ * Generates a SCRIPT tag with the type and src attributes.
+ *
+ * @param type type of link
+ * @param src the path for the script
+ * @return an HtmlTree object for the SCRIPT tag
+ */
+ public static HtmlTree SCRIPT(String src) {
+ HtmlTree htmltree = HtmlTree.SCRIPT();
+ htmltree.addAttr(HtmlAttr.SRC, nullCheck(src));
+ return htmltree;
+ }
+
+ /**
+ * Generates a SCRIPT tag with the type attribute.
+ *
+ * @return an HtmlTree object for the SCRIPT tag
+ */
+ public static HtmlTree SCRIPT() {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.SCRIPT);
+ htmltree.addAttr(HtmlAttr.TYPE, "text/javascript");
+ return htmltree;
+ }
+
+ /**
+ * Generates a SECTION tag with role attribute.
+ *
+ * @return an HtmlTree object for the SECTION tag
+ */
+ public static HtmlTree SECTION() {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.SECTION);
+ htmltree.setRole(Role.REGION);
+ return htmltree;
+ }
+
+ /**
+ * Generates a SECTION tag with role attribute and some content.
+ *
+ * @param body content of the section tag
+ * @return an HtmlTree object for the SECTION tag
+ */
+ public static HtmlTree SECTION(Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.SECTION, nullCheck(body));
+ htmltree.setRole(Role.REGION);
+ return htmltree;
+ }
+
+ /**
+ * Generates a SMALL tag with some content.
+ *
+ * @param body content for the tag
+ * @return an HtmlTree object for the SMALL tag
+ */
+ public static HtmlTree SMALL(Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.SMALL, nullCheck(body));
+ return htmltree;
+ }
+
+ /**
+ * Generates a SPAN tag with some content.
+ *
+ * @param body content for the tag
+ * @return an HtmlTree object for the SPAN tag
+ */
+ public static HtmlTree SPAN(Content body) {
+ return SPAN(null, body);
+ }
+
+ /**
+ * Generates a SPAN tag with style class attribute and some content.
+ *
+ * @param styleClass style class for the tag
+ * @param body content for the tag
+ * @return an HtmlTree object for the SPAN tag
+ */
+ public static HtmlTree SPAN(HtmlStyle styleClass, Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.SPAN, nullCheck(body));
+ if (styleClass != null)
+ htmltree.addStyle(styleClass);
+ return htmltree;
+ }
+
+ /**
+ * Generates a SPAN tag with id and style class attributes. It also encloses
+ * a content.
+ *
+ * @param id the id for the tag
+ * @param styleClass stylesheet class for the tag
+ * @param body content for the tag
+ * @return an HtmlTree object for the SPAN tag
+ */
+ public static HtmlTree SPAN(String id, HtmlStyle styleClass, Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.SPAN, nullCheck(body));
+ htmltree.addAttr(HtmlAttr.ID, nullCheck(id));
+ if (styleClass != null)
+ htmltree.addStyle(styleClass);
+ return htmltree;
+ }
+
+ /**
+ * Generates a Table tag with style class and summary attributes and some content.
+ *
+ * @param styleClass style of the table
+ * @param summary summary for the table
+ * @param body content for the table
+ * @return an HtmlTree object for the TABLE tag
+ */
+ public static HtmlTree TABLE(HtmlStyle styleClass, String summary, Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.TABLE, nullCheck(body));
+ if (styleClass != null)
+ htmltree.addStyle(styleClass);
+ htmltree.addAttr(HtmlAttr.SUMMARY, nullCheck(summary));
+ return htmltree;
+ }
+
+ /**
+ * Generates a Table tag with style class attribute and some content.
+ *
+ * @param styleClass style of the table
+ * @param body content for the table
+ * @return an HtmlTree object for the TABLE tag
+ */
+ public static HtmlTree TABLE(HtmlStyle styleClass, Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.TABLE, nullCheck(body));
+ if (styleClass != null) {
+ htmltree.addStyle(styleClass);
+ }
+ return htmltree;
+ }
+
+ /**
+ * Generates a TD tag with style class attribute and some content.
+ *
+ * @param styleClass style for the tag
+ * @param body content for the tag
+ * @return an HtmlTree object for the TD tag
+ */
+ public static HtmlTree TD(HtmlStyle styleClass, Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.TD, nullCheck(body));
+ if (styleClass != null)
+ htmltree.addStyle(styleClass);
+ return htmltree;
+ }
+
+ /**
+ * Generates a TD tag for an HTML table with some content.
+ *
+ * @param body content for the tag
+ * @return an HtmlTree object for the TD tag
+ */
+ public static HtmlTree TD(Content body) {
+ return TD(null, body);
+ }
+
+ /**
+ * Generates a TH tag with style class and scope attributes and some content.
+ *
+ * @param styleClass style for the tag
+ * @param scope scope of the tag
+ * @param body content for the tag
+ * @return an HtmlTree object for the TH tag
+ */
+ public static HtmlTree TH(HtmlStyle styleClass, String scope, Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.TH, nullCheck(body));
+ if (styleClass != null)
+ htmltree.addStyle(styleClass);
+ htmltree.addAttr(HtmlAttr.SCOPE, nullCheck(scope));
+ return htmltree;
+ }
+
+ /**
+ * Generates a TH tag with scope attribute and some content.
+ *
+ * @param scope scope of the tag
+ * @param body content for the tag
+ * @return an HtmlTree object for the TH tag
+ */
+ public static HtmlTree TH(String scope, Content body) {
+ return TH(null, scope, body);
+ }
+
+ /**
+ * Generates a TITLE tag with some content.
+ *
+ * @param body content for the tag
+ * @return an HtmlTree object for the TITLE tag
+ */
+ public static HtmlTree TITLE(Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.TITLE, nullCheck(body));
+ return htmltree;
+ }
+
+ /**
+ * Generates a TR tag for an HTML table with some content.
+ *
+ * @param body content for the tag
+ * @return an HtmlTree object for the TR tag
+ */
+ public static HtmlTree TR(Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.TR, nullCheck(body));
+ return htmltree;
+ }
+
+ /**
+ * Generates a UL tag with the style class attribute and some content.
+ *
+ * @param styleClass style for the tag
+ * @param body content for the tag
+ * @return an HtmlTree object for the UL tag
+ */
+ public static HtmlTree UL(HtmlStyle styleClass, Content body) {
+ HtmlTree htmltree = new HtmlTree(HtmlTag.UL, nullCheck(body));
+ htmltree.addStyle(nullCheck(styleClass));
+ return htmltree;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isEmpty() {
+ return (!hasContent() && !hasAttrs());
+ }
+
+ /**
+ * Returns true if the HTML tree has content.
+ *
+ * @return true if the HTML tree has content else return false
+ */
+ public boolean hasContent() {
+ return (!content.isEmpty());
+ }
+
+ /**
+ * Returns true if the HTML tree has attributes.
+ *
+ * @return true if the HTML tree has attributes else return false
+ */
+ public boolean hasAttrs() {
+ return (!attrs.isEmpty());
+ }
+
+ /**
+ * Returns true if the HTML tree has a specific attribute.
+ *
+ * @param attrName name of the attribute to check within the HTML tree
+ * @return true if the HTML tree has the specified attribute else return false
+ */
+ public boolean hasAttr(HtmlAttr attrName) {
+ return (attrs.containsKey(attrName));
+ }
+
+ /**
+ * Returns true if the HTML tree is valid. This check is more specific to
+ * standard doclet and not exactly similar to W3C specifications. But it
+ * ensures HTML validation.
+ *
+ * @return true if the HTML tree is valid
+ */
+ public boolean isValid() {
+ switch (htmlTag) {
+ case A :
+ return (hasAttr(HtmlAttr.NAME) || hasAttr(HtmlAttr.ID) || (hasAttr(HtmlAttr.HREF) && hasContent()));
+ case BR :
+ return (!hasContent() && (!hasAttrs() || hasAttr(HtmlAttr.CLEAR)));
+ case IFRAME :
+ return (hasAttr(HtmlAttr.SRC) && !hasContent());
+ case HR :
+ case INPUT:
+ return (!hasContent());
+ case IMG :
+ return (hasAttr(HtmlAttr.SRC) && hasAttr(HtmlAttr.ALT) && !hasContent());
+ case LINK :
+ return (hasAttr(HtmlAttr.HREF) && !hasContent());
+ case META :
+ return (hasAttr(HtmlAttr.CONTENT) && !hasContent());
+ case SCRIPT :
+ return ((hasAttr(HtmlAttr.TYPE) && hasAttr(HtmlAttr.SRC) && !hasContent()) ||
+ (hasAttr(HtmlAttr.TYPE) && hasContent()));
+ default :
+ return hasContent();
+ }
+ }
+
+ /**
+ * Returns true if the element is an inline element.
+ *
+ * @return true if the HTML tag is an inline element
+ */
+ public boolean isInline() {
+ return (htmlTag.blockType == HtmlTag.BlockType.INLINE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean write(Writer out, boolean atNewline) throws IOException {
+ if (!isInline() && !atNewline)
+ out.write(DocletConstants.NL);
+ String tagString = htmlTag.toString();
+ out.write("<");
+ out.write(tagString);
+ Iterator iterator = attrs.keySet().iterator();
+ HtmlAttr key;
+ String value;
+ while (iterator.hasNext()) {
+ key = iterator.next();
+ value = attrs.get(key);
+ out.write(" ");
+ out.write(key.toString());
+ if (!value.isEmpty()) {
+ out.write("=\"");
+ out.write(value);
+ out.write("\"");
+ }
+ }
+ out.write(">");
+ boolean nl = false;
+ for (Content c : content)
+ nl = c.write(out, nl);
+ if (htmlTag.endTagRequired()) {
+ out.write("");
+ out.write(tagString);
+ out.write(">");
+ }
+ if (!isInline()) {
+ out.write(DocletConstants.NL);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Given a Content node, strips all html characters and
+ * return the result.
+ *
+ * @param body The content node to check.
+ * @return the plain text from the content node
+ *
+ */
+ private static String stripHtml(Content body) {
+ String rawString = body.toString();
+ // remove HTML tags
+ rawString = rawString.replaceAll("\\<.*?>", " ");
+ // consolidate multiple spaces between a word to a single space
+ rawString = rawString.replaceAll("\\b\\s{2,}\\b", " ");
+ // remove extra whitespaces
+ return rawString.trim();
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlVersion.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlVersion.java
new file mode 100644
index 00000000000..c3b3e6ded5e
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlVersion.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html.markup;
+
+/**
+ * Enum representing the version of HTML generated by javadoc.
+ *
+ * @author Bhavesh Patel
+ */
+public enum HtmlVersion {
+ HTML4,
+ HTML5,
+ ALL
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java
new file mode 100644
index 00000000000..589f342ef79
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java
@@ -0,0 +1,515 @@
+/*
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html.markup;
+
+import java.io.*;
+import java.util.*;
+
+import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
+import jdk.javadoc.internal.doclets.toolkit.util.MethodTypes;
+
+
+/**
+ * Class for the Html format code generation.
+ * Initializes PrintWriter with FileWriter, to enable print
+ * related methods to generate the code to the named File through FileWriter.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Atul M Dambalkar
+ * @author Bhavesh Patel (Modified)
+ */
+public class HtmlWriter {
+
+ /**
+ * The window title of this file
+ */
+ protected String winTitle;
+
+ /**
+ * The configuration
+ */
+ protected Configuration configuration;
+
+ /**
+ * The flag to indicate whether a member details list is printed or not.
+ */
+ protected boolean memberDetailsListPrinted;
+
+ /**
+ * Header for tables displaying packages and description..
+ */
+ protected final List packageTableHeader;
+
+ /**
+ * Summary for use tables displaying class and package use.
+ */
+ protected final String useTableSummary;
+
+ /**
+ * Column header for class docs displaying Modifier and Type header.
+ */
+ protected final String modifierTypeHeader;
+
+ public final Content overviewLabel;
+
+ public final Content defaultPackageLabel;
+
+ public final Content packageLabel;
+
+ public final Content useLabel;
+
+ public final Content prevLabel;
+
+ public final Content nextLabel;
+
+ public final Content prevclassLabel;
+
+ public final Content nextclassLabel;
+
+ public final Content summaryLabel;
+
+ public final Content detailLabel;
+
+ public final Content framesLabel;
+
+ public final Content noframesLabel;
+
+ public final Content treeLabel;
+
+ public final Content classLabel;
+
+ public final Content deprecatedLabel;
+
+ public final Content deprecatedPhrase;
+
+ public final Content allclassesLabel;
+
+ public final Content allpackagesLabel;
+
+ public final Content indexLabel;
+
+ public final Content helpLabel;
+
+ public final Content seeLabel;
+
+ public final Content descriptionLabel;
+
+ public final Content prevpackageLabel;
+
+ public final Content nextpackageLabel;
+
+ public final Content packagesLabel;
+
+ public final Content methodDetailsLabel;
+
+ public final Content annotationTypeDetailsLabel;
+
+ public final Content fieldDetailsLabel;
+
+ public final Content propertyDetailsLabel;
+
+ public final Content constructorDetailsLabel;
+
+ public final Content enumConstantsDetailsLabel;
+
+ public final Content specifiedByLabel;
+
+ public final Content overridesLabel;
+
+ public final Content descfrmClassLabel;
+
+ public final Content descfrmInterfaceLabel;
+
+ private final Writer writer;
+
+ protected Content script;
+
+
+ /**
+ * Constructor.
+ *
+ * @param path The directory path to be created for this file
+ * or null if none to be created.
+ * @exception IOException Exception raised by the FileWriter is passed on
+ * to next level.
+ * @exception UnsupportedEncodingException Exception raised by the
+ * OutputStreamWriter is passed on to next level.
+ */
+ public HtmlWriter(Configuration configuration, DocPath path)
+ throws IOException, UnsupportedEncodingException {
+ writer = DocFile.createFileForOutput(configuration, path).openWriter();
+ this.configuration = configuration;
+ this.memberDetailsListPrinted = false;
+ packageTableHeader = new ArrayList<>();
+ packageTableHeader.add(configuration.getText("doclet.Package"));
+ packageTableHeader.add(configuration.getText("doclet.Description"));
+ useTableSummary = configuration.getText("doclet.Use_Table_Summary",
+ configuration.getText("doclet.packages"));
+ modifierTypeHeader = configuration.getText("doclet.0_and_1",
+ configuration.getText("doclet.Modifier"),
+ configuration.getText("doclet.Type"));
+ overviewLabel = getResource("doclet.Overview");
+ defaultPackageLabel = new StringContent(DocletConstants.DEFAULT_PACKAGE_NAME);
+ packageLabel = getResource("doclet.Package");
+ useLabel = getResource("doclet.navClassUse");
+ prevLabel = getResource("doclet.Prev");
+ nextLabel = getResource("doclet.Next");
+ prevclassLabel = getNonBreakResource("doclet.Prev_Class");
+ nextclassLabel = getNonBreakResource("doclet.Next_Class");
+ summaryLabel = getResource("doclet.Summary");
+ detailLabel = getResource("doclet.Detail");
+ framesLabel = getResource("doclet.Frames");
+ noframesLabel = getNonBreakResource("doclet.No_Frames");
+ treeLabel = getResource("doclet.Tree");
+ classLabel = getResource("doclet.Class");
+ deprecatedLabel = getResource("doclet.navDeprecated");
+ deprecatedPhrase = getResource("doclet.Deprecated");
+ allclassesLabel = getNonBreakResource("doclet.All_Classes");
+ allpackagesLabel = getNonBreakResource("doclet.All_Packages");
+ indexLabel = getResource("doclet.Index");
+ helpLabel = getResource("doclet.Help");
+ seeLabel = getResource("doclet.See");
+ descriptionLabel = getResource("doclet.Description");
+ prevpackageLabel = getNonBreakResource("doclet.Prev_Package");
+ nextpackageLabel = getNonBreakResource("doclet.Next_Package");
+ packagesLabel = getResource("doclet.Packages");
+ methodDetailsLabel = getResource("doclet.Method_Detail");
+ annotationTypeDetailsLabel = getResource("doclet.Annotation_Type_Member_Detail");
+ fieldDetailsLabel = getResource("doclet.Field_Detail");
+ propertyDetailsLabel = getResource("doclet.Property_Detail");
+ constructorDetailsLabel = getResource("doclet.Constructor_Detail");
+ enumConstantsDetailsLabel = getResource("doclet.Enum_Constant_Detail");
+ specifiedByLabel = getResource("doclet.Specified_By");
+ overridesLabel = getResource("doclet.Overrides");
+ descfrmClassLabel = getResource("doclet.Description_From_Class");
+ descfrmInterfaceLabel = getResource("doclet.Description_From_Interface");
+ }
+
+ public void write(Content c) throws IOException {
+ c.write(writer, true);
+ }
+
+ public void close() throws IOException {
+ writer.close();
+ }
+
+ /**
+ * Get the configuration string as a content.
+ *
+ * @param key the key to look for in the configuration file
+ * @return a content tree for the text
+ */
+ public Content getResource(String key) {
+ return configuration.getResource(key);
+ }
+
+ /**
+ * Get the configuration string as a content, replacing spaces
+ * with non-breaking spaces.
+ *
+ * @param key the key to look for in the configuration file
+ * @return a content tree for the text
+ */
+ public Content getNonBreakResource(String key) {
+ String text = configuration.getText(key);
+ Content c = configuration.newContent();
+ int start = 0;
+ int p;
+ while ((p = text.indexOf(" ", start)) != -1) {
+ c.addContent(text.substring(start, p));
+ c.addContent(RawHtml.nbsp);
+ start = p + 1;
+ }
+ c.addContent(text.substring(start));
+ return c;
+ }
+
+ /**
+ * Get the configuration string as a content.
+ *
+ * @param key the key to look for in the configuration file
+ * @param o string or content argument added to configuration text
+ * @return a content tree for the text
+ */
+ public Content getResource(String key, Object o) {
+ return configuration.getResource(key, o);
+ }
+
+ /**
+ * Get the configuration string as a content.
+ *
+ * @param key the key to look for in the configuration file
+ * @param o1 string or content argument added to configuration text
+ * @param o2 string or content argument added to configuration text
+ * @return a content tree for the text
+ */
+ public Content getResource(String key, Object o0, Object o1) {
+ return configuration.getResource(key, o0, o1);
+ }
+
+ /**
+ * Returns an HtmlTree for the SCRIPT tag.
+ *
+ * @return an HtmlTree for the SCRIPT tag
+ */
+ protected HtmlTree getWinTitleScript(){
+ HtmlTree script = HtmlTree.SCRIPT();
+ if(winTitle != null && winTitle.length() > 0) {
+ String scriptCode = "" + DocletConstants.NL;
+ RawHtml scriptContent = new RawHtml(scriptCode);
+ script.addContent(scriptContent);
+ }
+ return script;
+ }
+
+ /**
+ * Returns a String with escaped special JavaScript characters.
+ *
+ * @param s String that needs to be escaped
+ * @return a valid escaped JavaScript string
+ */
+ private static String escapeJavaScriptChars(String s) {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < s.length(); i++) {
+ char ch = s.charAt(i);
+ switch (ch) {
+ case '\b':
+ sb.append("\\b");
+ break;
+ case '\t':
+ sb.append("\\t");
+ break;
+ case '\n':
+ sb.append("\\n");
+ break;
+ case '\f':
+ sb.append("\\f");
+ break;
+ case '\r':
+ sb.append("\\r");
+ break;
+ case '"':
+ sb.append("\\\"");
+ break;
+ case '\'':
+ sb.append("\\\'");
+ break;
+ case '\\':
+ sb.append("\\\\");
+ break;
+ default:
+ if (ch < 32 || ch >= 127) {
+ sb.append(String.format("\\u%04X", (int)ch));
+ } else {
+ sb.append(ch);
+ }
+ break;
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Returns a content tree for the SCRIPT tag for the main page(index.html).
+ *
+ * @return a content for the SCRIPT tag
+ */
+ protected Content getFramesJavaScript() {
+ HtmlTree script = HtmlTree.SCRIPT();
+ String scriptCode = DocletConstants.NL +
+ " targetPage = \"\" + window.location.search;" + DocletConstants.NL +
+ " if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL +
+ " targetPage = targetPage.substring(1);" + DocletConstants.NL +
+ " if (targetPage.indexOf(\":\") != -1 || (targetPage != \"\" && !validURL(targetPage)))" + DocletConstants.NL +
+ " targetPage = \"undefined\";" + DocletConstants.NL +
+ " function validURL(url) {" + DocletConstants.NL +
+ " try {" + DocletConstants.NL +
+ " url = decodeURIComponent(url);" + DocletConstants.NL +
+ " }" + DocletConstants.NL +
+ " catch (error) {" + DocletConstants.NL +
+ " return false;" + DocletConstants.NL +
+ " }" + DocletConstants.NL +
+ " var pos = url.indexOf(\".html\");" + DocletConstants.NL +
+ " if (pos == -1 || pos != url.length - 5)" + DocletConstants.NL +
+ " return false;" + DocletConstants.NL +
+ " var allowNumber = false;" + DocletConstants.NL +
+ " var allowSep = false;" + DocletConstants.NL +
+ " var seenDot = false;" + DocletConstants.NL +
+ " for (var i = 0; i < url.length - 5; i++) {" + DocletConstants.NL +
+ " var ch = url.charAt(i);" + DocletConstants.NL +
+ " if ('a' <= ch && ch <= 'z' ||" + DocletConstants.NL +
+ " 'A' <= ch && ch <= 'Z' ||" + DocletConstants.NL +
+ " ch == '$' ||" + DocletConstants.NL +
+ " ch == '_' ||" + DocletConstants.NL +
+ " ch.charCodeAt(0) > 127) {" + DocletConstants.NL +
+ " allowNumber = true;" + DocletConstants.NL +
+ " allowSep = true;" + DocletConstants.NL +
+ " } else if ('0' <= ch && ch <= '9'" + DocletConstants.NL +
+ " || ch == '-') {" + DocletConstants.NL +
+ " if (!allowNumber)" + DocletConstants.NL +
+ " return false;" + DocletConstants.NL +
+ " } else if (ch == '/' || ch == '.') {" + DocletConstants.NL +
+ " if (!allowSep)" + DocletConstants.NL +
+ " return false;" + DocletConstants.NL +
+ " allowNumber = false;" + DocletConstants.NL +
+ " allowSep = false;" + DocletConstants.NL +
+ " if (ch == '.')" + DocletConstants.NL +
+ " seenDot = true;" + DocletConstants.NL +
+ " if (ch == '/' && seenDot)" + DocletConstants.NL +
+ " return false;" + DocletConstants.NL +
+ " } else {" + DocletConstants.NL +
+ " return false;"+ DocletConstants.NL +
+ " }" + DocletConstants.NL +
+ " }" + DocletConstants.NL +
+ " return true;" + DocletConstants.NL +
+ " }" + DocletConstants.NL;
+ RawHtml scriptContent = new RawHtml(scriptCode);
+ script.addContent(scriptContent);
+ return script;
+ }
+
+ /**
+ * Returns an HtmlTree for the BODY tag.
+ *
+ * @param includeScript set true if printing windowtitle script
+ * @param title title for the window
+ * @return an HtmlTree for the BODY tag
+ */
+ public HtmlTree getBody(boolean includeScript, String title) {
+ HtmlTree body = new HtmlTree(HtmlTag.BODY);
+ // Set window title string which is later printed
+ this.winTitle = title;
+ // Don't print windowtitle script for overview-frame, allclasses-frame
+ // and package-frame
+ if (includeScript) {
+ this.script = getWinTitleScript();
+ body.addContent(script);
+ Content noScript = HtmlTree.NOSCRIPT(
+ HtmlTree.DIV(getResource("doclet.No_Script_Message")));
+ body.addContent(noScript);
+ }
+ return body;
+ }
+
+ /**
+ * Generated javascript variables for the document.
+ *
+ * @param typeMap map comprising of method and type relationship
+ * @param methodTypes set comprising of all methods types for this class
+ */
+ public void generateMethodTypesScript(Map typeMap,
+ Set methodTypes) {
+ String sep = "";
+ StringBuilder vars = new StringBuilder("var methods = {");
+ for (Map.Entry entry : typeMap.entrySet()) {
+ vars.append(sep);
+ sep = ",";
+ vars.append("\"")
+ .append(entry.getKey())
+ .append("\":")
+ .append(entry.getValue());
+ }
+ vars.append("};").append(DocletConstants.NL);
+ sep = "";
+ vars.append("var tabs = {");
+ for (MethodTypes entry : methodTypes) {
+ vars.append(sep);
+ sep = ",";
+ vars.append(entry.value())
+ .append(":")
+ .append("[")
+ .append("\"")
+ .append(entry.tabId())
+ .append("\"")
+ .append(sep)
+ .append("\"")
+ .append(configuration.getText(entry.resourceKey()))
+ .append("\"]");
+ }
+ vars.append("};")
+ .append(DocletConstants.NL);
+ addStyles(HtmlStyle.altColor, vars);
+ addStyles(HtmlStyle.rowColor, vars);
+ addStyles(HtmlStyle.tableTab, vars);
+ addStyles(HtmlStyle.activeTableTab, vars);
+ script.addContent(new RawHtml(vars.toString()));
+ }
+
+ /**
+ * Adds javascript style variables to the document.
+ *
+ * @param style style to be added as a javascript variable
+ * @param vars variable string to which the style variable will be added
+ */
+ public void addStyles(HtmlStyle style, StringBuilder vars) {
+ vars.append("var ").append(style).append(" = \"").append(style)
+ .append("\";").append(DocletConstants.NL);
+ }
+
+ /**
+ * Returns an HtmlTree for the TITLE tag.
+ *
+ * @return an HtmlTree for the TITLE tag
+ */
+ public HtmlTree getTitle() {
+ HtmlTree title = HtmlTree.TITLE(new StringContent(winTitle));
+ return title;
+ }
+
+ public String codeText(String text) {
+ return "" + text + "
";
+ }
+
+ /**
+ * Return " ", non-breaking space.
+ */
+ public Content getSpace() {
+ return RawHtml.nbsp;
+ }
+
+ /*
+ * Returns a header for Modifier and Type column of a table.
+ */
+ public String getModifierTypeHeader() {
+ return modifierTypeHeader;
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java
new file mode 100644
index 00000000000..fe425dd743a
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html.markup;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
+
+/**
+ * Class for generating raw HTML content to be added to HTML pages of javadoc output.
+ *
+ * This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Bhavesh Patel
+ */
+public class RawHtml extends Content {
+
+ private String rawHtmlContent;
+
+ public static final Content nbsp = new RawHtml(" ");
+
+ /**
+ * Constructor to construct a RawHtml object.
+ *
+ * @param rawHtml raw HTML text to be added
+ */
+ public RawHtml(String rawHtml) {
+ rawHtmlContent = nullCheck(rawHtml);
+ }
+
+ /**
+ * This method is not supported by the class.
+ *
+ * @param content content that needs to be added
+ * @throws DocletAbortException this method will always throw a
+ * DocletAbortException because it
+ * is not supported.
+ */
+ public void addContent(Content content) {
+ throw new DocletAbortException("not supported");
+ }
+
+ /**
+ * This method is not supported by the class.
+ *
+ * @param stringContent string content that needs to be added
+ * @throws DocletAbortException this method will always throw a
+ * DocletAbortException because it
+ * is not supported.
+ */
+ public void addContent(String stringContent) {
+ throw new DocletAbortException("not supported");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isEmpty() {
+ return rawHtmlContent.isEmpty();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return rawHtmlContent;
+ }
+
+ private enum State { TEXT, ENTITY, TAG, STRING }
+
+ @Override
+ public int charCount() {
+ return charCount(rawHtmlContent);
+ }
+
+ static int charCount(String htmlText) {
+ State state = State.TEXT;
+ int count = 0;
+ for (int i = 0; i < htmlText.length(); i++) {
+ char c = htmlText.charAt(i);
+ switch (state) {
+ case TEXT:
+ switch (c) {
+ case '<':
+ state = State.TAG;
+ break;
+ case '&':
+ state = State.ENTITY;
+ count++;
+ break;
+ default:
+ count++;
+ }
+ break;
+
+ case ENTITY:
+ if (!Character.isLetterOrDigit(c))
+ state = State.TEXT;
+ break;
+
+ case TAG:
+ switch (c) {
+ case '"':
+ state = State.STRING;
+ break;
+ case '>':
+ state = State.TEXT;
+ break;
+ }
+ break;
+
+ case STRING:
+ switch (c) {
+ case '"':
+ state = State.TAG;
+ break;
+ }
+ }
+ }
+ return count;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean write(Writer out, boolean atNewline) throws IOException {
+ out.write(rawHtmlContent);
+ return rawHtmlContent.endsWith(DocletConstants.NL);
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/StringContent.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/StringContent.java
new file mode 100644
index 00000000000..6b7c7dde2ed
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/StringContent.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html.markup;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
+
+/**
+ * Class for generating string content for HTML tags of javadoc output.
+ *
+ *
This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.
+ *
+ * @author Bhavesh Patel
+ */
+public class StringContent extends Content {
+
+ private StringBuilder stringContent;
+
+ /**
+ * Constructor to construct StringContent object.
+ */
+ public StringContent() {
+ stringContent = new StringBuilder();
+ }
+
+ /**
+ * Constructor to construct StringContent object with some initial content.
+ *
+ * @param initialContent initial content for the object
+ */
+ public StringContent(String initialContent) {
+ stringContent = new StringBuilder();
+ appendChars(initialContent);
+ }
+
+ /**
+ * This method is not supported by the class.
+ *
+ * @param content content that needs to be added
+ * @throws DocletAbortException this method will always throw a
+ * DocletAbortException because it
+ * is not supported.
+ */
+ @Override
+ public void addContent(Content content) {
+ throw new DocletAbortException("not supported");
+ }
+
+ /**
+ * Adds content for the StringContent object. The method escapes
+ * HTML characters for the string content that is added.
+ *
+ * @param strContent string content to be added
+ */
+ @Override
+ public void addContent(String strContent) {
+ appendChars(strContent);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isEmpty() {
+ return (stringContent.length() == 0);
+ }
+
+ @Override
+ public int charCount() {
+ return RawHtml.charCount(stringContent.toString());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return stringContent.toString();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean write(Writer out, boolean atNewline) throws IOException {
+ String s = stringContent.toString();
+ out.write(s);
+ return s.endsWith(DocletConstants.NL);
+ }
+
+ private void appendChars(String s) {
+ for (int i = 0; i < s.length(); i++) {
+ char ch = s.charAt(i);
+ switch (ch) {
+ case '<': stringContent.append("<"); break;
+ case '>': stringContent.append(">"); break;
+ case '&': stringContent.append("&"); break;
+ default: stringContent.append(ch); break;
+ }
+ }
+ }
+}
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/package-info.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/package-info.java
new file mode 100644
index 00000000000..41069a3939c
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/package-info.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ This package contains classes that write HTML markup tags.
+
+
This is NOT part of any supported API.
+ If you write code that depends on this, you do so at your own risk.
+ This code and its internal interfaces are subject to change or
+ deletion without notice.
+ */
+
+package jdk.javadoc.internal.doclets.formats.html.markup;
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/package-info.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/package-info.java
new file mode 100644
index 00000000000..6219b40bdc2
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/package-info.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * This is the default HTML doclet provided with the JDK.
+ *
+ *
+ * This is NOT part of any supported API. If you write code that depends on this, you do so at
+ * your own risk. This code and its internal interfaces are subject to change or deletion without
+ * notice.
+ */
+package jdk.javadoc.internal.doclets.formats.html;
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/glass.png b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/glass.png
new file mode 100644
index 00000000000..a7f591f467a
Binary files /dev/null and b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/glass.png differ
diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/jquery/external/jquery/jquery.js b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/jquery/external/jquery/jquery.js
new file mode 100644
index 00000000000..c5c648255c1
--- /dev/null
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/jquery/external/jquery/jquery.js
@@ -0,0 +1,9789 @@
+/*!
+ * jQuery JavaScript Library v1.10.2
+ * http://jquery.com/
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ *
+ * Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors
+ * Released under the MIT license
+ * http://jquery.org/license
+ *
+ * Date: 2013-07-03T13:48Z
+ */
+(function( window, undefined ) {
+
+// Can't do this because several apps including ASP.NET trace
+// the stack via arguments.caller.callee and Firefox dies if
+// you try to trace through "use strict" call chains. (#13335)
+// Support: Firefox 18+
+//"use strict";
+var
+ // The deferred used on DOM ready
+ readyList,
+
+ // A central reference to the root jQuery(document)
+ rootjQuery,
+
+ // Support: IE<10
+ // For `typeof xmlNode.method` instead of `xmlNode.method !== undefined`
+ core_strundefined = typeof undefined,
+
+ // Use the correct document accordingly with window argument (sandbox)
+ location = window.location,
+ document = window.document,
+ docElem = document.documentElement,
+
+ // Map over jQuery in case of overwrite
+ _jQuery = window.jQuery,
+
+ // Map over the $ in case of overwrite
+ _$ = window.$,
+
+ // [[Class]] -> type pairs
+ class2type = {},
+
+ // List of deleted data cache ids, so we can reuse them
+ core_deletedIds = [],
+
+ core_version = "1.10.2",
+
+ // Save a reference to some core methods
+ core_concat = core_deletedIds.concat,
+ core_push = core_deletedIds.push,
+ core_slice = core_deletedIds.slice,
+ core_indexOf = core_deletedIds.indexOf,
+ core_toString = class2type.toString,
+ core_hasOwn = class2type.hasOwnProperty,
+ core_trim = core_version.trim,
+
+ // Define a local copy of jQuery
+ jQuery = function( selector, context ) {
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.fn.init( selector, context, rootjQuery );
+ },
+
+ // Used for matching numbers
+ core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,
+
+ // Used for splitting on whitespace
+ core_rnotwhite = /\S+/g,
+
+ // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
+ rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
+
+ // A simple way to check for HTML strings
+ // Prioritize #id over to avoid XSS via location.hash (#9521)
+ // Strict HTML recognition (#11290: must start with <)
+ rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
+
+ // Match a standalone tag
+ rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
+
+ // JSON RegExp
+ rvalidchars = /^[\],:{}\s]*$/,
+ rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
+ rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
+ rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,
+
+ // Matches dashed string for camelizing
+ rmsPrefix = /^-ms-/,
+ rdashAlpha = /-([\da-z])/gi,
+
+ // Used by jQuery.camelCase as callback to replace()
+ fcamelCase = function( all, letter ) {
+ return letter.toUpperCase();
+ },
+
+ // The ready event handler
+ completed = function( event ) {
+
+ // readyState === "complete" is good enough for us to call the dom ready in oldIE
+ if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) {
+ detach();
+ jQuery.ready();
+ }
+ },
+ // Clean-up method for dom ready events
+ detach = function() {
+ if ( document.addEventListener ) {
+ document.removeEventListener( "DOMContentLoaded", completed, false );
+ window.removeEventListener( "load", completed, false );
+
+ } else {
+ document.detachEvent( "onreadystatechange", completed );
+ window.detachEvent( "onload", completed );
+ }
+ };
+
+jQuery.fn = jQuery.prototype = {
+ // The current version of jQuery being used
+ jquery: core_version,
+
+ constructor: jQuery,
+ init: function( selector, context, rootjQuery ) {
+ var match, elem;
+
+ // HANDLE: $(""), $(null), $(undefined), $(false)
+ if ( !selector ) {
+ return this;
+ }
+
+ // Handle HTML strings
+ if ( typeof selector === "string" ) {
+ if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
+ // Assume that strings that start and end with <> are HTML and skip the regex check
+ match = [ null, selector, null ];
+
+ } else {
+ match = rquickExpr.exec( selector );
+ }
+
+ // Match html or make sure no context is specified for #id
+ if ( match && (match[1] || !context) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[1] ) {
+ context = context instanceof jQuery ? context[0] : context;
+
+ // scripts is true for back-compat
+ jQuery.merge( this, jQuery.parseHTML(
+ match[1],
+ context && context.nodeType ? context.ownerDocument || context : document,
+ true
+ ) );
+
+ // HANDLE: $(html, props)
+ if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
+ for ( match in context ) {
+ // Properties of context are called as methods if possible
+ if ( jQuery.isFunction( this[ match ] ) ) {
+ this[ match ]( context[ match ] );
+
+ // ...and otherwise set as attributes
+ } else {
+ this.attr( match, context[ match ] );
+ }
+ }
+ }
+
+ return this;
+
+ // HANDLE: $(#id)
+ } else {
+ elem = document.getElementById( match[2] );
+
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ if ( elem && elem.parentNode ) {
+ // Handle the case where IE and Opera return items
+ // by name instead of ID
+ if ( elem.id !== match[2] ) {
+ return rootjQuery.find( selector );
+ }
+
+ // Otherwise, we inject the element directly into the jQuery object
+ this.length = 1;
+ this[0] = elem;
+ }
+
+ this.context = document;
+ this.selector = selector;
+ return this;
+ }
+
+ // HANDLE: $(expr, $(...))
+ } else if ( !context || context.jquery ) {
+ return ( context || rootjQuery ).find( selector );
+
+ // HANDLE: $(expr, context)
+ // (which is just equivalent to: $(context).find(expr)
+ } else {
+ return this.constructor( context ).find( selector );
+ }
+
+ // HANDLE: $(DOMElement)
+ } else if ( selector.nodeType ) {
+ this.context = this[0] = selector;
+ this.length = 1;
+ return this;
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if ( jQuery.isFunction( selector ) ) {
+ return rootjQuery.ready( selector );
+ }
+
+ if ( selector.selector !== undefined ) {
+ this.selector = selector.selector;
+ this.context = selector.context;
+ }
+
+ return jQuery.makeArray( selector, this );
+ },
+
+ // Start with an empty selector
+ selector: "",
+
+ // The default length of a jQuery object is 0
+ length: 0,
+
+ toArray: function() {
+ return core_slice.call( this );
+ },
+
+ // Get the Nth element in the matched element set OR
+ // Get the whole matched element set as a clean array
+ get: function( num ) {
+ return num == null ?
+
+ // Return a 'clean' array
+ this.toArray() :
+
+ // Return just the object
+ ( num < 0 ? this[ this.length + num ] : this[ num ] );
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems ) {
+
+ // Build a new jQuery matched element set
+ var ret = jQuery.merge( this.constructor(), elems );
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+ ret.context = this.context;
+
+ // Return the newly-formed element set
+ return ret;
+ },
+
+ // Execute a callback for every element in the matched set.
+ // (You can seed the arguments with an array of args, but this is
+ // only used internally.)
+ each: function( callback, args ) {
+ return jQuery.each( this, callback, args );
+ },
+
+ ready: function( fn ) {
+ // Add the callback
+ jQuery.ready.promise().done( fn );
+
+ return this;
+ },
+
+ slice: function() {
+ return this.pushStack( core_slice.apply( this, arguments ) );
+ },
+
+ first: function() {
+ return this.eq( 0 );
+ },
+
+ last: function() {
+ return this.eq( -1 );
+ },
+
+ eq: function( i ) {
+ var len = this.length,
+ j = +i + ( i < 0 ? len : 0 );
+ return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map(this, function( elem, i ) {
+ return callback.call( elem, i, elem );
+ }));
+ },
+
+ end: function() {
+ return this.prevObject || this.constructor(null);
+ },
+
+ // For internal use only.
+ // Behaves like an Array's method, not like a jQuery method.
+ push: core_push,
+ sort: [].sort,
+ splice: [].splice
+};
+
+// Give the init function the jQuery prototype for later instantiation
+jQuery.fn.init.prototype = jQuery.fn;
+
+jQuery.extend = jQuery.fn.extend = function() {
+ var src, copyIsArray, copy, name, options, clone,
+ target = arguments[0] || {},
+ i = 1,
+ length = arguments.length,
+ deep = false;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
+ target = {};
+ }
+
+ // extend jQuery itself if only one argument is passed
+ if ( length === i ) {
+ target = this;
+ --i;
+ }
+
+ for ( ; i < length; i++ ) {
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null ) {
+ // Extend the base object
+ for ( name in options ) {
+ src = target[ name ];
+ copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy ) {
+ continue;
+ }
+
+ // Recurse if we're merging plain objects or arrays
+ if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
+ if ( copyIsArray ) {
+ copyIsArray = false;
+ clone = src && jQuery.isArray(src) ? src : [];
+
+ } else {
+ clone = src && jQuery.isPlainObject(src) ? src : {};
+ }
+
+ // Never move original objects, clone them
+ target[ name ] = jQuery.extend( deep, clone, copy );
+
+ // Don't bring in undefined values
+ } else if ( copy !== undefined ) {
+ target[ name ] = copy;
+ }
+ }
+ }
+ }
+
+ // Return the modified object
+ return target;
+};
+
+jQuery.extend({
+ // Unique for each copy of jQuery on the page
+ // Non-digits removed to match rinlinejQuery
+ expando: "jQuery" + ( core_version + Math.random() ).replace( /\D/g, "" ),
+
+ noConflict: function( deep ) {
+ if ( window.$ === jQuery ) {
+ window.$ = _$;
+ }
+
+ if ( deep && window.jQuery === jQuery ) {
+ window.jQuery = _jQuery;
+ }
+
+ return jQuery;
+ },
+
+ // Is the DOM ready to be used? Set to true once it occurs.
+ isReady: false,
+
+ // A counter to track how many items to wait for before
+ // the ready event fires. See #6781
+ readyWait: 1,
+
+ // Hold (or release) the ready event
+ holdReady: function( hold ) {
+ if ( hold ) {
+ jQuery.readyWait++;
+ } else {
+ jQuery.ready( true );
+ }
+ },
+
+ // Handle when the DOM is ready
+ ready: function( wait ) {
+
+ // Abort if there are pending holds or we're already ready
+ if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
+ return;
+ }
+
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( !document.body ) {
+ return setTimeout( jQuery.ready );
+ }
+
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If a normal DOM Ready event fired, decrement, and wait if need be
+ if ( wait !== true && --jQuery.readyWait > 0 ) {
+ return;
+ }
+
+ // If there are functions bound, to execute
+ readyList.resolveWith( document, [ jQuery ] );
+
+ // Trigger any bound ready events
+ if ( jQuery.fn.trigger ) {
+ jQuery( document ).trigger("ready").off("ready");
+ }
+ },
+
+ // See test/unit/core.js for details concerning isFunction.
+ // Since version 1.3, DOM methods and functions like alert
+ // aren't supported. They return false on IE (#2968).
+ isFunction: function( obj ) {
+ return jQuery.type(obj) === "function";
+ },
+
+ isArray: Array.isArray || function( obj ) {
+ return jQuery.type(obj) === "array";
+ },
+
+ isWindow: function( obj ) {
+ /* jshint eqeqeq: false */
+ return obj != null && obj == obj.window;
+ },
+
+ isNumeric: function( obj ) {
+ return !isNaN( parseFloat(obj) ) && isFinite( obj );
+ },
+
+ type: function( obj ) {
+ if ( obj == null ) {
+ return String( obj );
+ }
+ return typeof obj === "object" || typeof obj === "function" ?
+ class2type[ core_toString.call(obj) ] || "object" :
+ typeof obj;
+ },
+
+ isPlainObject: function( obj ) {
+ var key;
+
+ // Must be an Object.
+ // Because of IE, we also have to check the presence of the constructor property.
+ // Make sure that DOM nodes and window objects don't pass through, as well
+ if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
+ return false;
+ }
+
+ try {
+ // Not own constructor property must be Object
+ if ( obj.constructor &&
+ !core_hasOwn.call(obj, "constructor") &&
+ !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
+ return false;
+ }
+ } catch ( e ) {
+ // IE8,9 Will throw exceptions on certain host objects #9897
+ return false;
+ }
+
+ // Support: IE<9
+ // Handle iteration over inherited properties before own properties.
+ if ( jQuery.support.ownLast ) {
+ for ( key in obj ) {
+ return core_hasOwn.call( obj, key );
+ }
+ }
+
+ // Own properties are enumerated firstly, so to speed up,
+ // if last one is own, then all properties are own.
+ for ( key in obj ) {}
+
+ return key === undefined || core_hasOwn.call( obj, key );
+ },
+
+ isEmptyObject: function( obj ) {
+ var name;
+ for ( name in obj ) {
+ return false;
+ }
+ return true;
+ },
+
+ error: function( msg ) {
+ throw new Error( msg );
+ },
+
+ // data: string of html
+ // context (optional): If specified, the fragment will be created in this context, defaults to document
+ // keepScripts (optional): If true, will include scripts passed in the html string
+ parseHTML: function( data, context, keepScripts ) {
+ if ( !data || typeof data !== "string" ) {
+ return null;
+ }
+ if ( typeof context === "boolean" ) {
+ keepScripts = context;
+ context = false;
+ }
+ context = context || document;
+
+ var parsed = rsingleTag.exec( data ),
+ scripts = !keepScripts && [];
+
+ // Single tag
+ if ( parsed ) {
+ return [ context.createElement( parsed[1] ) ];
+ }
+
+ parsed = jQuery.buildFragment( [ data ], context, scripts );
+ if ( scripts ) {
+ jQuery( scripts ).remove();
+ }
+ return jQuery.merge( [], parsed.childNodes );
+ },
+
+ parseJSON: function( data ) {
+ // Attempt to parse using the native JSON parser first
+ if ( window.JSON && window.JSON.parse ) {
+ return window.JSON.parse( data );
+ }
+
+ if ( data === null ) {
+ return data;
+ }
+
+ if ( typeof data === "string" ) {
+
+ // Make sure leading/trailing whitespace is removed (IE can't handle it)
+ data = jQuery.trim( data );
+
+ if ( data ) {
+ // Make sure the incoming data is actual JSON
+ // Logic borrowed from http://json.org/json2.js
+ if ( rvalidchars.test( data.replace( rvalidescape, "@" )
+ .replace( rvalidtokens, "]" )
+ .replace( rvalidbraces, "")) ) {
+
+ return ( new Function( "return " + data ) )();
+ }
+ }
+ }
+
+ jQuery.error( "Invalid JSON: " + data );
+ },
+
+ // Cross-browser xml parsing
+ parseXML: function( data ) {
+ var xml, tmp;
+ if ( !data || typeof data !== "string" ) {
+ return null;
+ }
+ try {
+ if ( window.DOMParser ) { // Standard
+ tmp = new DOMParser();
+ xml = tmp.parseFromString( data , "text/xml" );
+ } else { // IE
+ xml = new ActiveXObject( "Microsoft.XMLDOM" );
+ xml.async = "false";
+ xml.loadXML( data );
+ }
+ } catch( e ) {
+ xml = undefined;
+ }
+ if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
+ jQuery.error( "Invalid XML: " + data );
+ }
+ return xml;
+ },
+
+ noop: function() {},
+
+ // Evaluates a script in a global context
+ // Workarounds based on findings by Jim Driscoll
+ // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
+ globalEval: function( data ) {
+ if ( data && jQuery.trim( data ) ) {
+ // We use execScript on Internet Explorer
+ // We use an anonymous function so that context is window
+ // rather than jQuery in Firefox
+ ( window.execScript || function( data ) {
+ window[ "eval" ].call( window, data );
+ } )( data );
+ }
+ },
+
+ // Convert dashed to camelCase; used by the css and data modules
+ // Microsoft forgot to hump their vendor prefix (#9572)
+ camelCase: function( string ) {
+ return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
+ },
+
+ nodeName: function( elem, name ) {
+ return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
+ },
+
+ // args is for internal usage only
+ each: function( obj, callback, args ) {
+ var value,
+ i = 0,
+ length = obj.length,
+ isArray = isArraylike( obj );
+
+ if ( args ) {
+ if ( isArray ) {
+ for ( ; i < length; i++ ) {
+ value = callback.apply( obj[ i ], args );
+
+ if ( value === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( i in obj ) {
+ value = callback.apply( obj[ i ], args );
+
+ if ( value === false ) {
+ break;
+ }
+ }
+ }
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if ( isArray ) {
+ for ( ; i < length; i++ ) {
+ value = callback.call( obj[ i ], i, obj[ i ] );
+
+ if ( value === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( i in obj ) {
+ value = callback.call( obj[ i ], i, obj[ i ] );
+
+ if ( value === false ) {
+ break;
+ }
+ }
+ }
+ }
+
+ return obj;
+ },
+
+ // Use native String.trim function wherever possible
+ trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
+ function( text ) {
+ return text == null ?
+ "" :
+ core_trim.call( text );
+ } :
+
+ // Otherwise use our own trimming functionality
+ function( text ) {
+ return text == null ?
+ "" :
+ ( text + "" ).replace( rtrim, "" );
+ },
+
+ // results is for internal usage only
+ makeArray: function( arr, results ) {
+ var ret = results || [];
+
+ if ( arr != null ) {
+ if ( isArraylike( Object(arr) ) ) {
+ jQuery.merge( ret,
+ typeof arr === "string" ?
+ [ arr ] : arr
+ );
+ } else {
+ core_push.call( ret, arr );
+ }
+ }
+
+ return ret;
+ },
+
+ inArray: function( elem, arr, i ) {
+ var len;
+
+ if ( arr ) {
+ if ( core_indexOf ) {
+ return core_indexOf.call( arr, elem, i );
+ }
+
+ len = arr.length;
+ i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
+
+ for ( ; i < len; i++ ) {
+ // Skip accessing in sparse arrays
+ if ( i in arr && arr[ i ] === elem ) {
+ return i;
+ }
+ }
+ }
+
+ return -1;
+ },
+
+ merge: function( first, second ) {
+ var l = second.length,
+ i = first.length,
+ j = 0;
+
+ if ( typeof l === "number" ) {
+ for ( ; j < l; j++ ) {
+ first[ i++ ] = second[ j ];
+ }
+ } else {
+ while ( second[j] !== undefined ) {
+ first[ i++ ] = second[ j++ ];
+ }
+ }
+
+ first.length = i;
+
+ return first;
+ },
+
+ grep: function( elems, callback, inv ) {
+ var retVal,
+ ret = [],
+ i = 0,
+ length = elems.length;
+ inv = !!inv;
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( ; i < length; i++ ) {
+ retVal = !!callback( elems[ i ], i );
+ if ( inv !== retVal ) {
+ ret.push( elems[ i ] );
+ }
+ }
+
+ return ret;
+ },
+
+ // arg is for internal usage only
+ map: function( elems, callback, arg ) {
+ var value,
+ i = 0,
+ length = elems.length,
+ isArray = isArraylike( elems ),
+ ret = [];
+
+ // Go through the array, translating each of the items to their
+ if ( isArray ) {
+ for ( ; i < length; i++ ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+
+ // Go through every key on the object,
+ } else {
+ for ( i in elems ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+ }
+
+ // Flatten any nested arrays
+ return core_concat.apply( [], ret );
+ },
+
+ // A global GUID counter for objects
+ guid: 1,
+
+ // Bind a function to a context, optionally partially applying any
+ // arguments.
+ proxy: function( fn, context ) {
+ var args, proxy, tmp;
+
+ if ( typeof context === "string" ) {
+ tmp = fn[ context ];
+ context = fn;
+ fn = tmp;
+ }
+
+ // Quick check to determine if target is callable, in the spec
+ // this throws a TypeError, but we will just return undefined.
+ if ( !jQuery.isFunction( fn ) ) {
+ return undefined;
+ }
+
+ // Simulated bind
+ args = core_slice.call( arguments, 2 );
+ proxy = function() {
+ return fn.apply( context || this, args.concat( core_slice.call( arguments ) ) );
+ };
+
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ proxy.guid = fn.guid = fn.guid || jQuery.guid++;
+
+ return proxy;
+ },
+
+ // Multifunctional method to get and set values of a collection
+ // The value/s can optionally be executed if it's a function
+ access: function( elems, fn, key, value, chainable, emptyGet, raw ) {
+ var i = 0,
+ length = elems.length,
+ bulk = key == null;
+
+ // Sets many values
+ if ( jQuery.type( key ) === "object" ) {
+ chainable = true;
+ for ( i in key ) {
+ jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
+ }
+
+ // Sets one value
+ } else if ( value !== undefined ) {
+ chainable = true;
+
+ if ( !jQuery.isFunction( value ) ) {
+ raw = true;
+ }
+
+ if ( bulk ) {
+ // Bulk operations run against the entire set
+ if ( raw ) {
+ fn.call( elems, value );
+ fn = null;
+
+ // ...except when executing function values
+ } else {
+ bulk = fn;
+ fn = function( elem, key, value ) {
+ return bulk.call( jQuery( elem ), value );
+ };
+ }
+ }
+
+ if ( fn ) {
+ for ( ; i < length; i++ ) {
+ fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
+ }
+ }
+ }
+
+ return chainable ?
+ elems :
+
+ // Gets
+ bulk ?
+ fn.call( elems ) :
+ length ? fn( elems[0], key ) : emptyGet;
+ },
+
+ now: function() {
+ return ( new Date() ).getTime();
+ },
+
+ // A method for quickly swapping in/out CSS properties to get correct calculations.
+ // Note: this method belongs to the css module but it's needed here for the support module.
+ // If support gets modularized, this method should be moved back to the css module.
+ swap: function( elem, options, callback, args ) {
+ var ret, name,
+ old = {};
+
+ // Remember the old values, and insert the new ones
+ for ( name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ ret = callback.apply( elem, args || [] );
+
+ // Revert the old values
+ for ( name in options ) {
+ elem.style[ name ] = old[ name ];
+ }
+
+ return ret;
+ }
+});
+
+jQuery.ready.promise = function( obj ) {
+ if ( !readyList ) {
+
+ readyList = jQuery.Deferred();
+
+ // Catch cases where $(document).ready() is called after the browser event has already occurred.
+ // we once tried to use readyState "interactive" here, but it caused issues like the one
+ // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
+ if ( document.readyState === "complete" ) {
+ // Handle it asynchronously to allow scripts the opportunity to delay ready
+ setTimeout( jQuery.ready );
+
+ // Standards-based browsers support DOMContentLoaded
+ } else if ( document.addEventListener ) {
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", completed, false );
+
+ // A fallback to window.onload, that will always work
+ window.addEventListener( "load", completed, false );
+
+ // If IE event model is used
+ } else {
+ // Ensure firing before onload, maybe late but safe also for iframes
+ document.attachEvent( "onreadystatechange", completed );
+
+ // A fallback to window.onload, that will always work
+ window.attachEvent( "onload", completed );
+
+ // If IE and not a frame
+ // continually check to see if the document is ready
+ var top = false;
+
+ try {
+ top = window.frameElement == null && document.documentElement;
+ } catch(e) {}
+
+ if ( top && top.doScroll ) {
+ (function doScrollCheck() {
+ if ( !jQuery.isReady ) {
+
+ try {
+ // Use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ top.doScroll("left");
+ } catch(e) {
+ return setTimeout( doScrollCheck, 50 );
+ }
+
+ // detach all dom ready events
+ detach();
+
+ // and execute any waiting functions
+ jQuery.ready();
+ }
+ })();
+ }
+ }
+ }
+ return readyList.promise( obj );
+};
+
+// Populate the class2type map
+jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
+ class2type[ "[object " + name + "]" ] = name.toLowerCase();
+});
+
+function isArraylike( obj ) {
+ var length = obj.length,
+ type = jQuery.type( obj );
+
+ if ( jQuery.isWindow( obj ) ) {
+ return false;
+ }
+
+ if ( obj.nodeType === 1 && length ) {
+ return true;
+ }
+
+ return type === "array" || type !== "function" &&
+ ( length === 0 ||
+ typeof length === "number" && length > 0 && ( length - 1 ) in obj );
+}
+
+// All jQuery objects should point back to these
+rootjQuery = jQuery(document);
+/*!
+ * Sizzle CSS Selector Engine v1.10.2
+ * http://sizzlejs.com/
+ *
+ * Copyright 2013 jQuery Foundation, Inc. and other contributors
+ * Released under the MIT license
+ * http://jquery.org/license
+ *
+ * Date: 2013-07-03
+ */
+(function( window, undefined ) {
+
+var i,
+ support,
+ cachedruns,
+ Expr,
+ getText,
+ isXML,
+ compile,
+ outermostContext,
+ sortInput,
+
+ // Local document vars
+ setDocument,
+ document,
+ docElem,
+ documentIsHTML,
+ rbuggyQSA,
+ rbuggyMatches,
+ matches,
+ contains,
+
+ // Instance-specific data
+ expando = "sizzle" + -(new Date()),
+ preferredDoc = window.document,
+ dirruns = 0,
+ done = 0,
+ classCache = createCache(),
+ tokenCache = createCache(),
+ compilerCache = createCache(),
+ hasDuplicate = false,
+ sortOrder = function( a, b ) {
+ if ( a === b ) {
+ hasDuplicate = true;
+ return 0;
+ }
+ return 0;
+ },
+
+ // General-purpose constants
+ strundefined = typeof undefined,
+ MAX_NEGATIVE = 1 << 31,
+
+ // Instance methods
+ hasOwn = ({}).hasOwnProperty,
+ arr = [],
+ pop = arr.pop,
+ push_native = arr.push,
+ push = arr.push,
+ slice = arr.slice,
+ // Use a stripped-down indexOf if we can't use a native one
+ indexOf = arr.indexOf || function( elem ) {
+ var i = 0,
+ len = this.length;
+ for ( ; i < len; i++ ) {
+ if ( this[i] === elem ) {
+ return i;
+ }
+ }
+ return -1;
+ },
+
+ booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
+
+ // Regular expressions
+
+ // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
+ whitespace = "[\\x20\\t\\r\\n\\f]",
+ // http://www.w3.org/TR/css3-syntax/#characters
+ characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
+
+ // Loosely modeled on CSS identifier characters
+ // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
+ // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
+ identifier = characterEncoding.replace( "w", "w#" ),
+
+ // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
+ attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
+ "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
+
+ // Prefer arguments quoted,
+ // then not containing pseudos/brackets,
+ // then attribute selectors/non-parenthetical expressions,
+ // then anything else
+ // These preferences are here to reduce the number of selectors
+ // needing tokenize in the PSEUDO preFilter
+ pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)",
+
+ // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
+ rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
+
+ rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
+ rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
+
+ rsibling = new RegExp( whitespace + "*[+~]" ),
+ rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*)" + whitespace + "*\\]", "g" ),
+
+ rpseudo = new RegExp( pseudos ),
+ ridentifier = new RegExp( "^" + identifier + "$" ),
+
+ matchExpr = {
+ "ID": new RegExp( "^#(" + characterEncoding + ")" ),
+ "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
+ "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
+ "ATTR": new RegExp( "^" + attributes ),
+ "PSEUDO": new RegExp( "^" + pseudos ),
+ "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
+ "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
+ "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
+ "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
+ // For use in libraries implementing .is()
+ // We use this for POS matching in `select`
+ "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
+ whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
+ },
+
+ rnative = /^[^{]+\{\s*\[native \w/,
+
+ // Easily-parseable/retrievable ID or TAG or CLASS selectors
+ rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
+
+ rinputs = /^(?:input|select|textarea|button)$/i,
+ rheader = /^h\d$/i,
+
+ rescape = /'|\\/g,
+
+ // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
+ runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
+ funescape = function( _, escaped, escapedWhitespace ) {
+ var high = "0x" + escaped - 0x10000;
+ // NaN means non-codepoint
+ // Support: Firefox
+ // Workaround erroneous numeric interpretation of +"0x"
+ return high !== high || escapedWhitespace ?
+ escaped :
+ // BMP codepoint
+ high < 0 ?
+ String.fromCharCode( high + 0x10000 ) :
+ // Supplemental Plane codepoint (surrogate pair)
+ String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
+ };
+
+// Optimize for push.apply( _, NodeList )
+try {
+ push.apply(
+ (arr = slice.call( preferredDoc.childNodes )),
+ preferredDoc.childNodes
+ );
+ // Support: Android<4.0
+ // Detect silently failing push.apply
+ arr[ preferredDoc.childNodes.length ].nodeType;
+} catch ( e ) {
+ push = { apply: arr.length ?
+
+ // Leverage slice if possible
+ function( target, els ) {
+ push_native.apply( target, slice.call(els) );
+ } :
+
+ // Support: IE<9
+ // Otherwise append directly
+ function( target, els ) {
+ var j = target.length,
+ i = 0;
+ // Can't trust NodeList.length
+ while ( (target[j++] = els[i++]) ) {}
+ target.length = j - 1;
+ }
+ };
+}
+
+function Sizzle( selector, context, results, seed ) {
+ var match, elem, m, nodeType,
+ // QSA vars
+ i, groups, old, nid, newContext, newSelector;
+
+ if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
+ setDocument( context );
+ }
+
+ context = context || document;
+ results = results || [];
+
+ if ( !selector || typeof selector !== "string" ) {
+ return results;
+ }
+
+ if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
+ return [];
+ }
+
+ if ( documentIsHTML && !seed ) {
+
+ // Shortcuts
+ if ( (match = rquickExpr.exec( selector )) ) {
+ // Speed-up: Sizzle("#ID")
+ if ( (m = match[1]) ) {
+ if ( nodeType === 9 ) {
+ elem = context.getElementById( m );
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ if ( elem && elem.parentNode ) {
+ // Handle the case where IE, Opera, and Webkit return items
+ // by name instead of ID
+ if ( elem.id === m ) {
+ results.push( elem );
+ return results;
+ }
+ } else {
+ return results;
+ }
+ } else {
+ // Context is not a document
+ if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
+ contains( context, elem ) && elem.id === m ) {
+ results.push( elem );
+ return results;
+ }
+ }
+
+ // Speed-up: Sizzle("TAG")
+ } else if ( match[2] ) {
+ push.apply( results, context.getElementsByTagName( selector ) );
+ return results;
+
+ // Speed-up: Sizzle(".CLASS")
+ } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
+ push.apply( results, context.getElementsByClassName( m ) );
+ return results;
+ }
+ }
+
+ // QSA path
+ if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
+ nid = old = expando;
+ newContext = context;
+ newSelector = nodeType === 9 && selector;
+
+ // qSA works strangely on Element-rooted queries
+ // We can work around this by specifying an extra ID on the root
+ // and working up from there (Thanks to Andrew Dupont for the technique)
+ // IE 8 doesn't work on object elements
+ if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
+ groups = tokenize( selector );
+
+ if ( (old = context.getAttribute("id")) ) {
+ nid = old.replace( rescape, "\\$&" );
+ } else {
+ context.setAttribute( "id", nid );
+ }
+ nid = "[id='" + nid + "'] ";
+
+ i = groups.length;
+ while ( i-- ) {
+ groups[i] = nid + toSelector( groups[i] );
+ }
+ newContext = rsibling.test( selector ) && context.parentNode || context;
+ newSelector = groups.join(",");
+ }
+
+ if ( newSelector ) {
+ try {
+ push.apply( results,
+ newContext.querySelectorAll( newSelector )
+ );
+ return results;
+ } catch(qsaError) {
+ } finally {
+ if ( !old ) {
+ context.removeAttribute("id");
+ }
+ }
+ }
+ }
+ }
+
+ // All others
+ return select( selector.replace( rtrim, "$1" ), context, results, seed );
+}
+
+/**
+ * Create key-value caches of limited size
+ * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
+ * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
+ * deleting the oldest entry
+ */
+function createCache() {
+ var keys = [];
+
+ function cache( key, value ) {
+ // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
+ if ( keys.push( key += " " ) > Expr.cacheLength ) {
+ // Only keep the most recent entries
+ delete cache[ keys.shift() ];
+ }
+ return (cache[ key ] = value);
+ }
+ return cache;
+}
+
+/**
+ * Mark a function for special use by Sizzle
+ * @param {Function} fn The function to mark
+ */
+function markFunction( fn ) {
+ fn[ expando ] = true;
+ return fn;
+}
+
+/**
+ * Support testing using an element
+ * @param {Function} fn Passed the created div and expects a boolean result
+ */
+function assert( fn ) {
+ var div = document.createElement("div");
+
+ try {
+ return !!fn( div );
+ } catch (e) {
+ return false;
+ } finally {
+ // Remove from its parent by default
+ if ( div.parentNode ) {
+ div.parentNode.removeChild( div );
+ }
+ // release memory in IE
+ div = null;
+ }
+}
+
+/**
+ * Adds the same handler for all of the specified attrs
+ * @param {String} attrs Pipe-separated list of attributes
+ * @param {Function} handler The method that will be applied
+ */
+function addHandle( attrs, handler ) {
+ var arr = attrs.split("|"),
+ i = attrs.length;
+
+ while ( i-- ) {
+ Expr.attrHandle[ arr[i] ] = handler;
+ }
+}
+
+/**
+ * Checks document order of two siblings
+ * @param {Element} a
+ * @param {Element} b
+ * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
+ */
+function siblingCheck( a, b ) {
+ var cur = b && a,
+ diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
+ ( ~b.sourceIndex || MAX_NEGATIVE ) -
+ ( ~a.sourceIndex || MAX_NEGATIVE );
+
+ // Use IE sourceIndex if available on both nodes
+ if ( diff ) {
+ return diff;
+ }
+
+ // Check if b follows a
+ if ( cur ) {
+ while ( (cur = cur.nextSibling) ) {
+ if ( cur === b ) {
+ return -1;
+ }
+ }
+ }
+
+ return a ? 1 : -1;
+}
+
+/**
+ * Returns a function to use in pseudos for input types
+ * @param {String} type
+ */
+function createInputPseudo( type ) {
+ return function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return name === "input" && elem.type === type;
+ };
+}
+
+/**
+ * Returns a function to use in pseudos for buttons
+ * @param {String} type
+ */
+function createButtonPseudo( type ) {
+ return function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return (name === "input" || name === "button") && elem.type === type;
+ };
+}
+
+/**
+ * Returns a function to use in pseudos for positionals
+ * @param {Function} fn
+ */
+function createPositionalPseudo( fn ) {
+ return markFunction(function( argument ) {
+ argument = +argument;
+ return markFunction(function( seed, matches ) {
+ var j,
+ matchIndexes = fn( [], seed.length, argument ),
+ i = matchIndexes.length;
+
+ // Match elements found at the specified indexes
+ while ( i-- ) {
+ if ( seed[ (j = matchIndexes[i]) ] ) {
+ seed[j] = !(matches[j] = seed[j]);
+ }
+ }
+ });
+ });
+}
+
+/**
+ * Detect xml
+ * @param {Element|Object} elem An element or a document
+ */
+isXML = Sizzle.isXML = function( elem ) {
+ // documentElement is verified for cases where it doesn't yet exist
+ // (such as loading iframes in IE - #4833)
+ var documentElement = elem && (elem.ownerDocument || elem).documentElement;
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
+};
+
+// Expose support vars for convenience
+support = Sizzle.support = {};
+
+/**
+ * Sets document-related variables once based on the current document
+ * @param {Element|Object} [doc] An element or document object to use to set the document
+ * @returns {Object} Returns the current document
+ */
+setDocument = Sizzle.setDocument = function( node ) {
+ var doc = node ? node.ownerDocument || node : preferredDoc,
+ parent = doc.defaultView;
+
+ // If no document and documentElement is available, return
+ if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
+ return document;
+ }
+
+ // Set our document
+ document = doc;
+ docElem = doc.documentElement;
+
+ // Support tests
+ documentIsHTML = !isXML( doc );
+
+ // Support: IE>8
+ // If iframe document is assigned to "document" variable and if iframe has been reloaded,
+ // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
+ // IE6-8 do not support the defaultView property so parent will be undefined
+ if ( parent && parent.attachEvent && parent !== parent.top ) {
+ parent.attachEvent( "onbeforeunload", function() {
+ setDocument();
+ });
+ }
+
+ /* Attributes
+ ---------------------------------------------------------------------- */
+
+ // Support: IE<8
+ // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
+ support.attributes = assert(function( div ) {
+ div.className = "i";
+ return !div.getAttribute("className");
+ });
+
+ /* getElement(s)By*
+ ---------------------------------------------------------------------- */
+
+ // Check if getElementsByTagName("*") returns only elements
+ support.getElementsByTagName = assert(function( div ) {
+ div.appendChild( doc.createComment("") );
+ return !div.getElementsByTagName("*").length;
+ });
+
+ // Check if getElementsByClassName can be trusted
+ support.getElementsByClassName = assert(function( div ) {
+ div.innerHTML = "
";
+
+ // Support: Safari<4
+ // Catch class over-caching
+ div.firstChild.className = "i";
+ // Support: Opera<10
+ // Catch gEBCN failure to find non-leading classes
+ return div.getElementsByClassName("i").length === 2;
+ });
+
+ // Support: IE<10
+ // Check if getElementById returns elements by name
+ // The broken getElementById methods don't pick up programatically-set names,
+ // so use a roundabout getElementsByName test
+ support.getById = assert(function( div ) {
+ docElem.appendChild( div ).id = expando;
+ return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
+ });
+
+ // ID find and filter
+ if ( support.getById ) {
+ Expr.find["ID"] = function( id, context ) {
+ if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
+ var m = context.getElementById( id );
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ return m && m.parentNode ? [m] : [];
+ }
+ };
+ Expr.filter["ID"] = function( id ) {
+ var attrId = id.replace( runescape, funescape );
+ return function( elem ) {
+ return elem.getAttribute("id") === attrId;
+ };
+ };
+ } else {
+ // Support: IE6/7
+ // getElementById is not reliable as a find shortcut
+ delete Expr.find["ID"];
+
+ Expr.filter["ID"] = function( id ) {
+ var attrId = id.replace( runescape, funescape );
+ return function( elem ) {
+ var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
+ return node && node.value === attrId;
+ };
+ };
+ }
+
+ // Tag
+ Expr.find["TAG"] = support.getElementsByTagName ?
+ function( tag, context ) {
+ if ( typeof context.getElementsByTagName !== strundefined ) {
+ return context.getElementsByTagName( tag );
+ }
+ } :
+ function( tag, context ) {
+ var elem,
+ tmp = [],
+ i = 0,
+ results = context.getElementsByTagName( tag );
+
+ // Filter out possible comments
+ if ( tag === "*" ) {
+ while ( (elem = results[i++]) ) {
+ if ( elem.nodeType === 1 ) {
+ tmp.push( elem );
+ }
+ }
+
+ return tmp;
+ }
+ return results;
+ };
+
+ // Class
+ Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
+ if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
+ return context.getElementsByClassName( className );
+ }
+ };
+
+ /* QSA/matchesSelector
+ ---------------------------------------------------------------------- */
+
+ // QSA and matchesSelector support
+
+ // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
+ rbuggyMatches = [];
+
+ // qSa(:focus) reports false when true (Chrome 21)
+ // We allow this because of a bug in IE8/9 that throws an error
+ // whenever `document.activeElement` is accessed on an iframe
+ // So, we allow :focus to pass through QSA all the time to avoid the IE error
+ // See http://bugs.jquery.com/ticket/13378
+ rbuggyQSA = [];
+
+ if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
+ // Build QSA regex
+ // Regex strategy adopted from Diego Perini
+ assert(function( div ) {
+ // Select is set to empty string on purpose
+ // This is to test IE's treatment of not explicitly
+ // setting a boolean content attribute,
+ // since its presence should be enough
+ // http://bugs.jquery.com/ticket/12359
+ div.innerHTML = "