KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > pmd > ast > AccessNode


1 package net.sourceforge.pmd.ast;
2
3 public class AccessNode extends SimpleJavaNode {
4
5     public static final int PUBLIC = 0x0001;
6     public static final int PROTECTED = 0x0002;
7     public static final int PRIVATE = 0x0004;
8     public static final int ABSTRACT = 0x0008;
9     public static final int STATIC = 0x0010;
10     public static final int FINAL = 0x0020;
11     public static final int SYNCHRONIZED = 0x0040;
12     public static final int NATIVE = 0x0080;
13     public static final int TRANSIENT = 0x0100;
14     public static final int VOLATILE = 0x0200;
15     public static final int STRICTFP = 0x1000;
16
17     public AccessNode(int i) {
18         super(i);
19     }
20
21     public AccessNode(JavaParser parser, int i) {
22         super(parser, i);
23     }
24
25     private int modifiers;
26
27     public void setModifiers(int m) {
28         this.modifiers = m;
29     }
30
31     public boolean isPublic() {
32         return (modifiers & PUBLIC) != 0;
33     }
34
35     public boolean isProtected() {
36         return (modifiers & PROTECTED) != 0;
37     }
38
39     public boolean isPrivate() {
40         return (modifiers & PRIVATE) != 0;
41     }
42
43     public boolean isStatic() {
44         return (modifiers & STATIC) != 0;
45     }
46
47     public boolean isAbstract() {
48         return (modifiers & ABSTRACT) != 0;
49     }
50
51     public boolean isFinal() {
52         return (modifiers & FINAL) != 0;
53     }
54
55     public boolean isNative() {
56         return (modifiers & NATIVE) != 0;
57     }
58
59     public boolean isStrictfp() {
60         return (modifiers & STRICTFP) != 0;
61     }
62
63     public boolean isSynchronized() {
64         return (modifiers & SYNCHRONIZED) != 0;
65     }
66
67     public boolean isTransient() {
68         return (modifiers & TRANSIENT) != 0;
69     }
70
71     public boolean isVolatile() {
72         return (modifiers & VOLATILE) != 0;
73     }
74
75     public void setPublic() {
76         modifiers |= PUBLIC;
77     }
78
79     public void setPrivate() {
80         modifiers |= PRIVATE;
81     }
82
83     public void setProtected() {
84         modifiers |= PROTECTED;
85     }
86
87     public void setSynchronized() {
88         modifiers |= SYNCHRONIZED;
89     }
90
91     public void setVolatile() {
92         modifiers |= VOLATILE;
93     }
94
95     public void setAbstract() {
96         modifiers |= ABSTRACT;
97     }
98
99     public void setStatic() {
100         modifiers |= STATIC;
101     }
102
103     public void setTransient() {
104         modifiers |= TRANSIENT;
105     }
106
107     public void setFinal() {
108         modifiers |= FINAL;
109     }
110
111     public void setNative() {
112         modifiers |= NATIVE;
113     }
114
115     public void setStrictfp() {
116         modifiers |= STRICTFP;
117     }
118
119     /**
120      * Removes the given modifier.
121      */

122     static int removeModifier(int modifiers, int mod) {
123         return modifiers & ~mod;
124     }
125
126     public boolean isPackagePrivate() {
127         return !isPrivate() && !isPublic() && !isProtected();
128     }
129
130     public String JavaDoc collectDumpedModifiers(String JavaDoc prefix) {
131         String JavaDoc out = toString(prefix) + ":";
132         if (isPackagePrivate()) {
133             out += "(package private)";
134         }
135         if (isPrivate()) {
136             out += "(private)";
137         }
138         if (isPublic()) {
139             out += "(public)";
140         }
141         if (isProtected()) {
142             out += "(protected)";
143         }
144         if (isAbstract()) {
145             out += "(abstract)";
146         }
147         if (isStatic()) {
148             out += "(static)";
149         }
150         if (isFinal()) {
151             out += "(final)";
152         }
153         if (isSynchronized()) {
154             out += "(synchronized)";
155         }
156         if (isNative()) {
157             out += "(native)";
158         }
159         if (isStrictfp()) {
160             out += "(strict)";
161         }
162         if (isTransient()) {
163             out += "(transient)";
164         }
165         return out;
166     }
167 }
168
Popular Tags