OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [tools/] [gnu/] [classpath/] [tools/] [gjdoc/] [ProgramElementDocImpl.java] - Blame information for rev 779

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 779 jeremybenn
/* gnu.classpath.tools.gjdoc.ProgramElementDocImpl
2
   Copyright (C) 2001 Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19
02111-1307 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
package gnu.classpath.tools.gjdoc;
39
 
40
import com.sun.javadoc.*;
41
import java.lang.reflect.Modifier;
42
 
43
public abstract class ProgramElementDocImpl extends DocImpl implements ProgramElementDoc {
44
 
45
   protected ClassDoc containingClass;
46
   protected PackageDoc containingPackage;
47
 
48
   protected boolean isFinal;
49
   protected boolean isStatic;
50
   protected int     accessLevel=ProgramElementDocImpl.ACCESS_PACKAGEPRIVATE;
51
 
52
   public static final int ACCESS_PUBLIC          = 0;
53
   public static final int ACCESS_PROTECTED       = 1;
54
   public static final int ACCESS_PACKAGEPRIVATE  = 2;
55
   public static final int ACCESS_PRIVATE         = 3;
56
 
57
   private static final String[] accessModifiers = { "public ", "protected ", "", "private "};
58
 
59
   public ProgramElementDocImpl(ClassDoc containingClass,
60
                                PackageDoc containingPackage,
61
                                SourcePosition position) {
62
      super(position);
63
      this.containingClass=containingClass;
64
      this.containingPackage=containingPackage;
65
   }
66
   public ProgramElementDocImpl(ClassDoc containingClass, SourcePosition position) {
67
      super(position);
68
      this.containingClass=containingClass;
69
      this.containingPackage=containingClass.containingPackage();
70
   }
71
   public ProgramElementDocImpl(ClassDoc containingClass,
72
                                PackageDoc containingPackage,
73
                                int accessLevel,
74
                                boolean isFinal,
75
                                boolean isStatic,
76
                                SourcePosition position) {
77
      super(position);
78
      this.containingClass=containingClass;
79
      this.containingPackage=containingPackage;
80
      this.accessLevel=accessLevel;
81
      this.isFinal=isFinal;
82
      this.isStatic=isStatic;
83
   }
84
 
85
   //Get the containing class of this program element.
86
   public ClassDoc containingClass() {
87
      return containingClass;
88
   }
89
 
90
   // Get the package that this program element is contained in.
91
   public PackageDoc containingPackage() {
92
      return containingPackage;
93
   }
94
 
95
   // Return true if this program element is final
96
   public boolean isFinal() {
97
      return isFinal;
98
   }
99
 
100
   // Return true if this program element is package private
101
   public boolean isPackagePrivate() {
102
      return accessLevel==ACCESS_PACKAGEPRIVATE;
103
   }
104
 
105
   // Return true if this program element is private
106
   public boolean isPrivate() {
107
      return accessLevel==ACCESS_PRIVATE;
108
   }
109
 
110
   // Return true if this program element is protected
111
   public boolean isProtected() {
112
      return accessLevel==ACCESS_PROTECTED;
113
   }
114
 
115
   // Return true if this program element is public
116
   public boolean isPublic() {
117
      return accessLevel==ACCESS_PUBLIC;
118
   }
119
 
120
   // Return true if this program element is static
121
   public boolean isStatic() {
122
      return isStatic;
123
   }
124
 
125
   // Get modifiers string.
126
   public String modifiers() {
127
      return
128
         (accessModifiers[accessLevel]+
129
          (isStatic()?"static ":"")+
130
          (isFinal()?"final ":"")).trim();
131
   }
132
 
133
   // Get the modifier specifier integer.
134
   public int modifierSpecifier() {
135
      return (isStatic()?Modifier.STATIC:0)
136
         | (isFinal()?Modifier.FINAL:0)
137
         | (isPublic()?Modifier.PUBLIC:0)
138
         | (isProtected()?Modifier.PROTECTED:0)
139
         | (isPrivate()?Modifier.PRIVATE:0)
140
//       | (isAbstract()?Modifier.ABSTRACT:0)
141
         ;
142
   }
143
 
144
   // Get the fully qualified name.
145
   public abstract String qualifiedName();
146
 
147
   protected boolean processModifier(String word) {
148
      if (word.equals("public")) {
149
         accessLevel=ACCESS_PUBLIC;
150
         return true;
151
      }
152
      else if (word.equals("protected")) {
153
         accessLevel=ACCESS_PROTECTED;
154
         return true;
155
      }
156
      else if (word.equals("private")) {
157
         accessLevel=ACCESS_PRIVATE;
158
         return true;
159
      }
160
      else if (word.equals("static")) {
161
         isStatic=true;
162
         return true;
163
      }
164
      else if (word.equals("final")) {
165
         isFinal=true;
166
         return true;
167
      }
168
      else {
169
         return false;
170
      }
171
   }
172
 
173
   void setIsStatic(boolean b) {
174
      this.isStatic=b;
175
   }
176
 
177
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.