1package jdiff;
2
3import java.io.*;
4import java.util.*;
5
6/**
7 * Class to represent a package, analogous to PackageDoc in the
8 * Javadoc doclet API.
9 *
10 * The method used for Collection comparison (compareTo) must make its
11 * comparison based upon everything that is known about this package.
12 *
13 * See the file LICENSE.txt for copyright details.
14 * @author Matthew Doar, mdoar@pobox.com
15 */
16class PackageAPI implements Comparable {
17
18    /** Full qualified name of the package. */
19    public String name_;
20
21    /** Classes within this package. */
22    public List classes_;  // ClassAPI[]
23
24    /** The doc block, default is null. */
25    public String doc_ = null;
26
27    /** Constructor. */
28    public PackageAPI(String name) {
29        name_ = name;
30        classes_ = new ArrayList(); // ClassAPI[]
31    }
32
33    /** Compare two PackageAPI objects by name. */
34    public int compareTo(Object o) {
35        PackageAPI oPackageAPI = (PackageAPI)o;
36        if (APIComparator.docChanged(doc_, oPackageAPI.doc_))
37            return -1;
38        return name_.compareTo(oPackageAPI.name_);
39    }
40
41    /**
42     * Tests two packages, using just the package name, used by indexOf().
43     */
44    public boolean equals(Object o) {
45        if (name_.compareTo(((PackageAPI)o).name_) == 0)
46            return true;
47        return false;
48    }
49}
50