0N/A/*
994N/A * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
553N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
553N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.tools.doclets.internal.toolkit.util;
0N/A
0N/Aimport com.sun.javadoc.*;
0N/Aimport java.util.*;
994N/Aimport com.sun.tools.doclets.internal.toolkit.Configuration;
0N/A
0N/A/**
994N/A * Build list of all the deprecated packages, classes, constructors, fields and methods.
0N/A *
0N/A * @author Atul M Dambalkar
0N/A */
0N/Apublic class DeprecatedAPIListBuilder {
0N/A
994N/A public static final int NUM_TYPES = 12;
0N/A
994N/A public static final int PACKAGE = 0;
994N/A public static final int INTERFACE = 1;
994N/A public static final int CLASS = 2;
994N/A public static final int ENUM = 3;
994N/A public static final int EXCEPTION = 4;
994N/A public static final int ERROR = 5;
994N/A public static final int ANNOTATION_TYPE = 6;
994N/A public static final int FIELD = 7;
994N/A public static final int METHOD = 8;
994N/A public static final int CONSTRUCTOR = 9;
994N/A public static final int ENUM_CONSTANT = 10;
994N/A public static final int ANNOTATION_TYPE_MEMBER = 11;
0N/A
0N/A /**
0N/A * List of deprecated type Lists.
0N/A */
73N/A private List<List<Doc>> deprecatedLists;
0N/A
0N/A
0N/A /**
0N/A * Constructor.
0N/A *
994N/A * @param configuration the current configuration of the doclet
0N/A */
994N/A public DeprecatedAPIListBuilder(Configuration configuration) {
73N/A deprecatedLists = new ArrayList<List<Doc>>();
0N/A for (int i = 0; i < NUM_TYPES; i++) {
73N/A deprecatedLists.add(i, new ArrayList<Doc>());
0N/A }
994N/A buildDeprecatedAPIInfo(configuration);
0N/A }
0N/A
0N/A /**
0N/A * Build the sorted list of all the deprecated APIs in this run.
994N/A * Build separate lists for deprecated packages, classes, constructors,
994N/A * methods and fields.
0N/A *
994N/A * @param configuration the current configuration of the doclet.
0N/A */
994N/A private void buildDeprecatedAPIInfo(Configuration configuration) {
994N/A PackageDoc[] packages = configuration.packages;
994N/A PackageDoc pkg;
994N/A for (int c = 0; c < packages.length; c++) {
994N/A pkg = packages[c];
994N/A if (Util.isDeprecated(pkg)) {
994N/A getList(PACKAGE).add(pkg);
994N/A }
994N/A }
994N/A ClassDoc[] classes = configuration.root.classes();
0N/A for (int i = 0; i < classes.length; i++) {
0N/A ClassDoc cd = classes[i];
0N/A if (Util.isDeprecated(cd)) {
0N/A if (cd.isOrdinaryClass()) {
0N/A getList(CLASS).add(cd);
0N/A } else if (cd.isInterface()) {
0N/A getList(INTERFACE).add(cd);
0N/A } else if (cd.isException()) {
0N/A getList(EXCEPTION).add(cd);
0N/A } else if (cd.isEnum()) {
0N/A getList(ENUM).add(cd);
0N/A } else if (cd.isError()) {
0N/A getList(ERROR).add(cd);
994N/A } else if (cd.isAnnotationType()) {
0N/A getList(ANNOTATION_TYPE).add(cd);
0N/A }
0N/A }
0N/A composeDeprecatedList(getList(FIELD), cd.fields());
0N/A composeDeprecatedList(getList(METHOD), cd.methods());
0N/A composeDeprecatedList(getList(CONSTRUCTOR), cd.constructors());
0N/A if (cd.isEnum()) {
0N/A composeDeprecatedList(getList(ENUM_CONSTANT), cd.enumConstants());
0N/A }
0N/A if (cd.isAnnotationType()) {
0N/A composeDeprecatedList(getList(ANNOTATION_TYPE_MEMBER),
994N/A ((AnnotationTypeDoc) cd).elements());
0N/A }
0N/A }
0N/A sortDeprecatedLists();
0N/A }
0N/A
0N/A /**
0N/A * Add the members into a single list of deprecated members.
0N/A *
0N/A * @param list List of all the particular deprecated members, e.g. methods.
0N/A * @param members members to be added in the list.
0N/A */
73N/A private void composeDeprecatedList(List<Doc> list, MemberDoc[] members) {
0N/A for (int i = 0; i < members.length; i++) {
0N/A if (Util.isDeprecated(members[i])) {
0N/A list.add(members[i]);
0N/A }
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Sort the deprecated lists for class kinds, fields, methods and
0N/A * constructors.
0N/A */
0N/A private void sortDeprecatedLists() {
0N/A for (int i = 0; i < NUM_TYPES; i++) {
0N/A Collections.sort(getList(i));
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Return the list of deprecated Doc objects of a given type.
0N/A *
0N/A * @param the constant representing the type of list being returned.
0N/A */
73N/A public List<Doc> getList(int type) {
73N/A return deprecatedLists.get(type);
0N/A }
0N/A
0N/A /**
0N/A * Return true if the list of a given type has size greater than 0.
0N/A *
0N/A * @param type the type of list being checked.
0N/A */
0N/A public boolean hasDocumentation(int type) {
73N/A return (deprecatedLists.get(type)).size() > 0;
0N/A }
0N/A}