1 /* gnu.classpath.tools.gjdoc.PackageDocImpl
2 Copyright (C) 2001 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 package gnu.classpath.tools.gjdoc;
23 import com.sun.javadoc.*;
27 class PackageDocImpl extends DocImpl implements GjdocPackageDoc {
29 private String packageName;
30 private File packageDirectory;
32 private Set allClassesSet = new TreeSet();
33 private List ordinaryClassesList = new ArrayList();
34 private List exceptionsList = new ArrayList();
35 private List interfacesList = new ArrayList();
36 private List errorsList = new ArrayList();
38 private ClassDoc[] allClasses;
39 private ClassDoc[] ordinaryClasses;
40 private ClassDoc[] exceptions;
41 private ClassDoc[] interfaces;
42 private ClassDoc[] errors;
44 PackageDocImpl(String packageName) {
46 this.packageName=packageName;
49 public void addClass(ClassDoc classDoc) {
50 if (Main.getInstance().includeAccessLevel(((ClassDocImpl)classDoc).accessLevel)) {
51 allClassesSet.add(classDoc);
55 public void resolve() {
56 for (Iterator it=allClassesSet.iterator(); it.hasNext(); ) {
57 ClassDocImpl classDoc=(ClassDocImpl)it.next();
60 } catch (ParseException e) {
61 System.err.println("FIXME: add try-catch to force compilation"
65 if (classDoc.isInterface()) {
66 interfacesList.add(classDoc);
68 else if (classDoc.isException()) {
69 exceptionsList.add(classDoc);
71 else if (classDoc.isError()) {
72 errorsList.add(classDoc);
75 ordinaryClassesList.add(classDoc);
80 public void resolveComments() {
81 if (rawDocumentation!=null) {
82 this.tagMap=parseCommentTags(rawDocumentation.toCharArray(),
84 rawDocumentation.length(),
94 public String name() {
98 public ClassDoc[] allClasses()
100 if (null == this.allClasses) {
101 this.allClasses = toClassDocArray(allClassesSet);
103 return this.allClasses;
106 public ClassDoc[] ordinaryClasses()
108 if (null == this.ordinaryClasses) {
109 this.ordinaryClasses = toClassDocArray(ordinaryClassesList);
111 return this.ordinaryClasses;
115 public ClassDoc[] exceptions()
117 if (null == this.exceptions) {
118 this.exceptions = toClassDocArray(exceptionsList);
120 return this.exceptions;
123 public ClassDoc[] interfaces()
125 if (null == this.interfaces) {
126 this.interfaces = toClassDocArray(interfacesList);
128 return this.interfaces;
131 public ClassDoc[] errors()
133 if (null == this.errors) {
134 this.errors = toClassDocArray(errorsList);
139 private ClassDoc[] toClassDocArray(Collection classDocList)
141 ClassDoc[] result = (ClassDoc[])classDocList.toArray(new ClassDoc[classDocList.size()]);
146 public ClassDoc findClass(String name) {
147 return Main.getRootDoc().classNamed(packageName+"."+name);
150 public void dump(int level) {
151 Debug.log(level, "All classes:");
152 Debug.dumpArray(level, allClasses());
154 Debug.log(level, "Ordinary classes:");
155 Debug.dumpArray(level, ordinaryClasses());
159 public static final PackageDocImpl DEFAULT_PACKAGE = new PackageDocImpl("");
161 public boolean isPackage() {
165 public boolean isIncluded() {
169 void setIsIncluded(boolean b) {
173 private boolean isIncluded = false;
175 public String toString() {
179 public int compareTo(Object o) {
180 if (o!=null && o instanceof PackageDocImpl)
181 return name().compareTo(((PackageDocImpl)o).name());
186 public boolean equals(Object o) {
187 if (o!=null && o instanceof PackageDocImpl)
188 return name().equals(((PackageDocImpl)o).name());
194 * Sets the directory containing this package's source files.
196 public void setPackageDirectory(File packageDirectory) {
197 this.packageDirectory = packageDirectory;
201 * Gets the directory containing this package's source files.
203 public File packageDirectory() {
204 return this.packageDirectory;