001: package net.sourceforge.pmd.ast;
002:
003: public class AccessNode extends SimpleJavaNode {
004:
005: public static final int PUBLIC = 0x0001;
006: public static final int PROTECTED = 0x0002;
007: public static final int PRIVATE = 0x0004;
008: public static final int ABSTRACT = 0x0008;
009: public static final int STATIC = 0x0010;
010: public static final int FINAL = 0x0020;
011: public static final int SYNCHRONIZED = 0x0040;
012: public static final int NATIVE = 0x0080;
013: public static final int TRANSIENT = 0x0100;
014: public static final int VOLATILE = 0x0200;
015: public static final int STRICTFP = 0x1000;
016:
017: public AccessNode(int i) {
018: super (i);
019: }
020:
021: public AccessNode(JavaParser parser, int i) {
022: super (parser, i);
023: }
024:
025: private int modifiers;
026:
027: public void setModifiers(int m) {
028: this .modifiers = m;
029: }
030:
031: public boolean isPublic() {
032: return (modifiers & PUBLIC) != 0;
033: }
034:
035: public boolean isProtected() {
036: return (modifiers & PROTECTED) != 0;
037: }
038:
039: public boolean isPrivate() {
040: return (modifiers & PRIVATE) != 0;
041: }
042:
043: public boolean isStatic() {
044: return (modifiers & STATIC) != 0;
045: }
046:
047: public boolean isAbstract() {
048: return (modifiers & ABSTRACT) != 0;
049: }
050:
051: public boolean isFinal() {
052: return (modifiers & FINAL) != 0;
053: }
054:
055: public boolean isNative() {
056: return (modifiers & NATIVE) != 0;
057: }
058:
059: public boolean isStrictfp() {
060: return (modifiers & STRICTFP) != 0;
061: }
062:
063: public boolean isSynchronized() {
064: return (modifiers & SYNCHRONIZED) != 0;
065: }
066:
067: public boolean isTransient() {
068: return (modifiers & TRANSIENT) != 0;
069: }
070:
071: public boolean isVolatile() {
072: return (modifiers & VOLATILE) != 0;
073: }
074:
075: public void setPublic() {
076: modifiers |= PUBLIC;
077: }
078:
079: public void setPrivate() {
080: modifiers |= PRIVATE;
081: }
082:
083: public void setProtected() {
084: modifiers |= PROTECTED;
085: }
086:
087: public void setSynchronized() {
088: modifiers |= SYNCHRONIZED;
089: }
090:
091: public void setVolatile() {
092: modifiers |= VOLATILE;
093: }
094:
095: public void setAbstract() {
096: modifiers |= ABSTRACT;
097: }
098:
099: 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 collectDumpedModifiers(String prefix) {
131: String 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: }
|