KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > tools > doclets > standard > AbstractTreeWriter


1 /* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  *
3  * This file is part of the debugger and core tools for the AspectJ(tm)
4  * programming language; see http://aspectj.org
5  *
6  * The contents of this file are subject to the Mozilla Public License
7  * Version 1.1 (the "License"); you may not use this file except in
8  * compliance with the License. You may obtain a copy of the License at
9  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is AspectJ.
17  *
18  * The Initial Developer of the Original Code is Xerox Corporation. Portions
19  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
20  * All Rights Reserved.
21  */

22
23 package org.aspectj.tools.doclets.standard;
24
25 import org.aspectj.ajdoc.AspectDoc;
26
27 import com.sun.javadoc.ClassDoc;
28 import com.sun.javadoc.PackageDoc;
29 import com.sun.tools.doclets.ClassTree;
30 import com.sun.tools.doclets.DocletAbortException;
31
32 import java.io.IOException JavaDoc;
33 import java.util.List JavaDoc;
34
35 public class AbstractTreeWriter
36     extends com.sun.tools.doclets.standard.AbstractTreeWriter
37 {
38
39     protected boolean seenAspect = false;
40     protected boolean aspectMode = false;
41     
42     protected AbstractTreeWriter(String JavaDoc filename, ClassTree classtree)
43         throws IOException JavaDoc, DocletAbortException {
44         super(filename, classtree);
45     }
46     
47     protected AbstractTreeWriter(String JavaDoc path, String JavaDoc filename,
48                                  ClassTree classtree, PackageDoc pkg)
49         throws IOException JavaDoc, DocletAbortException {
50         super(path, filename, classtree, pkg);
51     }
52    
53     protected void generateLevelInfo(ClassDoc parent, List JavaDoc list) {
54         if (list.size() > 0) {
55             ul();
56             for (int i = 0; i < list.size(); i++) {
57                 ClassDoc local = (ClassDoc)list.get(i);
58                 boolean isAspect = local instanceof org.aspectj.ajdoc.AspectDoc;
59                 if (aspectMode) {
60                     if (!local.qualifiedTypeName().equals("java.lang.Object")
61                         && !isAspect) {
62                         continue;
63                     }
64                 } else if (isAspect) {
65                     continue;
66                 }
67                 printPartialInfo(local);
68                 printExtendsImplements(parent, local);
69                 generateLevelInfo(local, classtree.subs(local));
70             }
71             ulEnd();
72         }
73     }
74
75     protected void printExtendsImplements(ClassDoc parent, ClassDoc cd) {
76         super.printExtendsImplements(parent, cd);
77         if (cd instanceof AspectDoc) {
78             printDominationInfo(((AspectDoc)cd).dominatees(), "dominates");
79             printDominationInfo(((AspectDoc)cd).dominators(), "dominated by");
80         }
81     }
82
83     protected void printDominationInfo(AspectDoc[] aspects,
84                                        String JavaDoc whosOnTop) {
85         if (aspects != null && aspects.length > 0) {
86             print(" (" + whosOnTop + " ");
87             for (int i = 0; i < aspects.length; i++) {
88                 if (i > 0) print(", ");
89                 printPreQualifiedClassLink(aspects[i]);
90             }
91             print(")");
92         }
93     }
94
95
96     protected void generateTree(List JavaDoc list, String JavaDoc heading) {
97         super.generateTree(list, heading);
98         if (heading.equals("doclet.Class_Hierarchy")) {
99             aspectMode = true;
100             generateTree(list, "doclet.Aspect_Hierarchy");
101             aspectMode = false;
102         }
103     }
104 }
105
Popular Tags