KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > tools > ajdoc > IntroducedSuperDocImpl


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 package org.aspectj.tools.ajdoc;
23
24 import org.aspectj.ajdoc.IntroducedSuperDoc;
25 import org.aspectj.compiler.base.ast.Dec;
26 import org.aspectj.compiler.base.ast.TypeDs;
27 import org.aspectj.compiler.crosscuts.ast.IntroducedSuperDec;
28
29 import java.util.ArrayList JavaDoc;
30 import java.util.Collection JavaDoc;
31 import java.util.Collections JavaDoc;
32 import java.util.List JavaDoc;
33
34 public class IntroducedSuperDocImpl
35     extends IntroductionDocImpl
36     implements IntroducedSuperDoc {
37
38     /** The introduction to which we delegate. */
39     private final IntroducedSuperDec introducedSuperDec;
40
41     /** The types we introduce onto our targets. */
42     private final Collection JavaDoc types;
43
44     public IntroducedSuperDocImpl(com.sun.javadoc.ClassDoc containingClass,
45                                   IntroducedSuperDec introducedSuperDec) {
46         super(containingClass);
47         this.introducedSuperDec = introducedSuperDec;
48         types = createTypes();
49     }
50
51     protected Dec dec() {
52         return introducedSuperDec;
53     }
54
55     /**
56      * Returns <code>true</code> is this introduction
57      * places <code>implements</code> introductions on its
58      * targets.
59      *
60      * @return <code>true</code> is this introduction
61      * places <code>implements</code> introductions
62      * on its targets.
63      */

64     public boolean isImplements() {
65         return introducedSuperDec.getIsImplements();
66     }
67
68     /**
69      * Returns the types that this introduction introduces
70      * into it's targets type hierarchy.
71      *
72      * @return an array of org.aspectj.ajdoc.Type representing
73      * the types this introduction has introducted onto
74      * its targets type hierarchy.
75      */

76     public org.aspectj.ajdoc.Type[] types() {
77         return (org.aspectj.ajdoc.Type[])types.toArray
78             (new org.aspectj.ajdoc.Type[types.size()]);
79     }
80
81     /**
82      * Returns the name of the type introduction.
83      *
84      * @return the name.
85      */

86     public String JavaDoc name() { if (true) return ""; // XXX unimplemented
87
return (introducedSuperDec.getTypeDs().size() != 0)
88             ? ((org.aspectj.ajdoc.Type)introducedSuperDec.getTypeDs().
89                 get(0).getType()).typeName()
90             : "";
91         //TODO: This could fuck us up!!!
92
}
93
94     private final Collection JavaDoc createTypes() {
95         TypeDs typeds = introducedSuperDec.getTypeDs();
96         if (typeds == null) return Collections.EMPTY_LIST;
97         List JavaDoc list = new ArrayList JavaDoc();
98         for (int i = 0, N = typeds.size(); i < N; i++) {
99             list.add(ClassDocImpl.getInstance(typeds.get(i).getType().getTypeDec()));
100         }
101         return list;
102     }
103 }
104
Popular Tags