KickJava   Java API By Example, From Geeks To Geeks.

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


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.compiler.base.ast.Dec;
25 import org.aspectj.compiler.base.ast.FieldDec;
26
27 import com.sun.javadoc.ClassDoc;
28 import com.sun.javadoc.SerialFieldTag;
29
30 import java.lang.reflect.Modifier JavaDoc;
31
32 public class FieldDocImpl
33     extends MemberDocImpl
34     implements org.aspectj.ajdoc.FieldDoc {
35
36     /** The FieldDec that corresponds to this FieldDoc. */
37     private final FieldDec field;
38
39     /**
40      * The type of this field. This can't be set initially
41      * because the compiler doesn't resolve the types for
42      * introductions, yet, so we have to allow others to set it.
43      */

44     private org.aspectj.compiler.base.ast.Type type;
45
46     /**
47      * Sets the org.apectj.compiler.base.ast.Type used to return
48      * the com.sun.javadoc.Type.
49      *
50      * @param type the new org.aspectj.compiler.base.ast.Type used
51      * to find the com.sun.javadoc.Type.
52      * @hack This is only needed because of unresolved
53      * introduced fields.
54      */

55     public void setType(org.aspectj.compiler.base.ast.Type type) {
56         this.type = type;
57     }
58
59     public FieldDocImpl(ClassDoc containingClass, FieldDec field) {
60         super(containingClass);
61         this.field = field;
62         setType(field.getType());
63     }
64
65     protected Dec dec() {
66         return field;
67     }
68
69     
70     protected FieldDec fieldDec() {
71         return field;
72     }
73
74     /**
75      * Returns <code>true</code>.
76      *
77      * @return <code>true</code>.
78      */

79     public boolean isField() {
80         return true;
81     }
82
83     /**
84      * Returns the type of this field.
85      *
86      * @return the type of this field.
87      */

88     public com.sun.javadoc.Type type() {
89         return TypeImpl.getInstance(type);
90     }
91
92     /**
93      * Return <code>true</code> is this field is <code>volatile</code>.
94      *
95      * @return <code>true</code> is this field is <code>volatile</code>.
96      */

97     public boolean isVolatile() {
98         return Modifier.isVolatile(modifierSpecifier());
99     }
100
101     /**
102      * Return <code>true</code> is this field is <code>transient</code>.
103      *
104      * @return <code>true</code> is this field is <code>transient</code>.
105      */

106     public boolean isTransient() {
107         return Modifier.isTransient(modifierSpecifier());
108     }
109
110     /**
111      * Returns the serial field tags for this field.
112      *
113      * @return an array of SerialFieldTag representing the
114      * serial field tags for this field.
115      */

116     public SerialFieldTag[] serialFieldTags() {
117         return getComment().serialFieldTags();
118     }
119
120     /**
121      * Returns the name of the field.
122      *
123      * @return the name of the field.
124      */

125     public String JavaDoc toString() {
126         return name();
127     }
128
129     /**
130      * Returns <code>true</code> is <code>md</code> is a
131      * FieldDocImpl and has the same name.
132      *
133      * @return <code>true</code> is <code>md</code> is a
134      * FieldDocImpl and has the same name.
135      */

136     public boolean weakEquals(Object JavaDoc md) {
137         if (!(md instanceof FieldDocImpl)) return false;
138         return name().equals(((FieldDocImpl)md).name());
139     }
140 }
141
Popular Tags