1 52 53 package com.go.trove.classfile; 54 55 import java.lang.reflect.Modifier ; 56 57 67 public class AccessFlags extends Modifier implements Cloneable { 68 private int mFlags; 69 70 71 public AccessFlags() { 72 mFlags = 0; 73 } 74 75 public AccessFlags(int modifier) { 76 mFlags = modifier; 77 } 78 79 public final int getModifier() { 80 return mFlags; 81 } 82 83 public void setModifier(int flags) { 84 mFlags = flags; 85 } 86 87 public boolean isPublic() { 88 return isPublic(mFlags); 89 } 90 91 94 public void setPublic(boolean value) { 95 if (value) { 96 mFlags |= PUBLIC; 97 mFlags &= ~PROTECTED & ~PRIVATE; 98 } 99 else { 100 mFlags &= ~PUBLIC; 101 } 102 } 103 104 public boolean isPrivate() { 105 return isPrivate(mFlags); 106 } 107 108 111 public void setPrivate(boolean value) { 112 if (value) { 113 mFlags |= PRIVATE; 114 mFlags &= ~PUBLIC & ~PROTECTED; 115 } 116 else { 117 mFlags &= ~PRIVATE; 118 } 119 } 120 121 public boolean isProtected() { 122 return isProtected(mFlags); 123 } 124 125 128 public void setProtected(boolean value) { 129 if (value) { 130 mFlags |= PROTECTED; 131 mFlags &= ~PUBLIC & ~PRIVATE; 132 } 133 else { 134 mFlags &= ~PROTECTED; 135 } 136 } 137 138 public boolean isStatic() { 139 return isStatic(mFlags); 140 } 141 142 public void setStatic(boolean value) { 143 if (value) { 144 mFlags |= STATIC; 145 } 146 else { 147 mFlags &= ~STATIC; 148 } 149 } 150 151 public boolean isFinal() { 152 return isFinal(mFlags); 153 } 154 155 158 public void setFinal(boolean value) { 159 if (value) { 160 mFlags |= FINAL; 161 mFlags &= ~INTERFACE & ~ABSTRACT; 162 } 163 else { 164 mFlags &= ~FINAL; 165 } 166 } 167 168 public boolean isSynchronized() { 169 return isSynchronized(mFlags); 170 } 171 172 public void setSynchronized(boolean value) { 173 if (value) { 174 mFlags |= SYNCHRONIZED; 175 } 176 else { 177 mFlags &= ~SYNCHRONIZED; 178 } 179 } 180 181 public boolean isVolatile() { 182 return isVolatile(mFlags); 183 } 184 185 public void setVolatile(boolean value) { 186 if (value) { 187 mFlags |= VOLATILE; 188 } 189 else { 190 mFlags &= ~VOLATILE; 191 } 192 } 193 194 public boolean isTransient() { 195 return isTransient(mFlags); 196 } 197 198 public void setTransient(boolean value) { 199 if (value) { 200 mFlags |= TRANSIENT; 201 } 202 else { 203 mFlags &= ~TRANSIENT; 204 } 205 } 206 207 public boolean isNative() { 208 return isNative(mFlags); 209 } 210 211 public void setNative(boolean value) { 212 if (value) { 213 mFlags |= NATIVE; 214 } 215 else { 216 mFlags &= ~NATIVE; 217 } 218 } 219 220 public boolean isInterface() { 221 return isInterface(mFlags); 222 } 223 224 228 public void setInterface(boolean value) { 229 if (value) { 230 mFlags |= INTERFACE | ABSTRACT; 231 mFlags &= ~FINAL; 232 } 233 else { 234 mFlags &= ~INTERFACE; 235 } 236 } 237 238 public boolean isAbstract() { 239 return isAbstract(mFlags); 240 } 241 242 246 public void setAbstract(boolean value) { 247 if (value) { 248 mFlags |= ABSTRACT; 249 mFlags &= ~FINAL; 250 } 251 else { 252 mFlags &= ~ABSTRACT & ~INTERFACE; 253 } 254 } 255 256 public Object clone() { 257 try { 258 return super.clone(); 259 } 260 catch (CloneNotSupportedException e) { 261 throw new InternalError (e.toString()); 262 } 263 } 264 265 269 public String toString() { 270 return toString(mFlags); 271 } 272 } 273 | Popular Tags |