KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > ide > Member


1 /*
2   Copyright (C) 2002-2003 Renaud Pawlak <renaud@aopsys.com>
3
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12   GNU Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public
15   License along with this program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17   USA */

18
19 package org.objectweb.jac.ide;
20
21 import org.objectweb.jac.util.Strings;
22
23
24 /**
25  * A member item of a class such as a field or a method.
26  */

27 public abstract class Member extends TypedElement implements Visibility {
28
29     Class JavaDoc parent;
30    
31     /**
32      * Get the value of parent.
33      * @return value of parent.
34      */

35     public Class JavaDoc getParent() {
36         return parent;
37     }
38    
39     /**
40      * Set the value of parent.
41      * @param v Value to assign to parent.
42      */

43     public void setParent(Class JavaDoc v) {
44         this.parent = v;
45     }
46       
47     public abstract String JavaDoc getPrototype();
48
49     /** Flag indicating if the member is static or not*/
50     boolean isStatic = false;
51     /** Returns value of isStatic field */
52     public boolean isStatic() {
53         return isStatic;
54     }
55     /** Sets value of isStatic field */
56     public void setStatic(boolean isStatic) {
57         this.isStatic = isStatic;
58     }
59
60     /**
61      * Returns a string of all the modifiers of a member item (field or
62      * method)
63      * @return a String with the modifiers, seperated by spaces
64      * @see #isStatic()
65      * @see #getVisibility()
66      */

67     public String JavaDoc getModifiers() {
68         String JavaDoc modifiers = "";
69         switch(visibility) {
70             case PUBLIC: modifiers = "public"; break;
71             case PROTECTED: modifiers = "protected"; break;
72             case PRIVATE: modifiers = "private"; break;
73         }
74         if (isStatic) {
75             modifiers += " static";
76         }
77         return modifiers;
78     }
79
80     public String JavaDoc getFullName() {
81         return parent.getFullName()+"."+getName();
82     }
83
84     public String JavaDoc getGenerationName() {
85         return Strings.toUSAscii(getName());
86     }
87
88     public String JavaDoc getGenerationFullName() {
89         return Strings.toUSAscii(getFullName());
90     }
91
92     public Project getProject() {
93         if (parent!=null)
94             return parent.getProject();
95         else
96             return null;
97     }
98
99     int visibility = PUBLIC;
100     public int getVisibility() {
101         return visibility;
102     }
103     public void setVisibility(int newVisibility) {
104         this.visibility = newVisibility;
105     }
106    
107 }
108
Popular Tags