KickJava   Java API By Example, From Geeks To Geeks.

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


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.AspectDoc;
25 import org.aspectj.ajdoc.ClassDoc;
26 import org.aspectj.ajdoc.IntroductionDoc;
27 import org.aspectj.compiler.crosscuts.ast.IntroducedDec;
28 import org.aspectj.compiler.crosscuts.ast.IntroducedSuperDec;
29
30 import java.util.ArrayList JavaDoc;
31 import java.util.Collection JavaDoc;
32
33 public abstract class IntroductionDocImpl
34     extends MemberDocImpl
35     implements IntroductionDoc {
36
37     /** Creats a new instance of IntroductionDoc from <code>o</code>. */
38     public static IntroductionDocImpl getInstance(AspectDoc ad, Object JavaDoc o) {
39         return factory.getInstance(ad, o);
40     }
41
42     /** The factory in charge of creating instances of IntroductionDocImpl. */
43     private final static Factory factory = new Factory();
44
45     private final Collection JavaDoc targets = new ArrayList JavaDoc();
46     
47     public void addTarget(ClassDoc cd) { targets.add(cd); }
48
49     protected IntroductionDocImpl(com.sun.javadoc.ClassDoc containingClass) {
50         super(containingClass);
51     }
52
53     //protected abstract Collection createTargets();
54

55     /**
56      * Returns the classes that are affected by this introduction.
57      *
58      * @return an array of ClassDoc representing the classes
59      * affected by this introduction.
60      */

61     public final ClassDoc[] targets() {
62         //if (targets == null) targets = createTargets();
63
return (ClassDoc[])targets.toArray(new ClassDoc[targets.size()]);
64     }
65
66     /**
67      * The class is in charge of creating
68      * instances of IntroductionDocImpl.
69      */

70     private final static class Factory {
71         public static IntroductionDocImpl getInstance(AspectDoc ad, Object JavaDoc o) {
72             if (o instanceof IntroducedSuperDec) {
73                 return new IntroducedSuperDocImpl(ad, (IntroducedSuperDec)o);
74             }
75             if (o instanceof IntroducedDec) {
76                 return new IntroducedDocImpl(ad, (IntroducedDec)o);
77             }
78             return null;
79         }
80     }
81
82     /** TODO */
83     public boolean weakEquals(Object JavaDoc md) {
84         return false; // TODO
85
}
86 }
87
Popular Tags