00001 package de.fub.bytecode.classfile;
00002
00003 import de.fub.bytecode.Constants;
00004
00005
00006
00007
00008
00009
00010
00011
00012 public abstract class AccessFlags {
00013 protected int access_flags;
00014
00015 public AccessFlags() {}
00016
00017
00018
00019 public AccessFlags(int a) {
00020 access_flags = a;
00021 }
00022
00023
00024
00025 public final int getAccessFlags() { return access_flags; }
00026 public final boolean isAbstract() {
00027 return (access_flags & Constants.ACC_ABSTRACT) != 0;
00028 }
00029 public final void isAbstract(boolean flag) { setFlag(Constants.ACC_ABSTRACT, flag); }
00030 public final boolean isFinal() {
00031 return (access_flags & Constants.ACC_FINAL) != 0;
00032 }
00033 public final void isFinal(boolean flag) { setFlag(Constants.ACC_FINAL, flag); }
00034 public final boolean isInterface() {
00035 return (access_flags & Constants.ACC_INTERFACE) != 0;
00036 }
00037 public final void isInterface(boolean flag) { setFlag(Constants.ACC_INTERFACE, flag); }
00038 public final boolean isNative() {
00039 return (access_flags & Constants.ACC_NATIVE) != 0;
00040 }
00041 public final void isNative(boolean flag) { setFlag(Constants.ACC_NATIVE, flag); }
00042 public final boolean isPrivate() {
00043 return (access_flags & Constants.ACC_PRIVATE) != 0;
00044 }
00045 public final void isPrivate(boolean flag) { setFlag(Constants.ACC_PRIVATE, flag); }
00046 public final boolean isProtected() {
00047 return (access_flags & Constants.ACC_PROTECTED) != 0;
00048 }
00049 public final void isProtected(boolean flag) { setFlag(Constants.ACC_PROTECTED, flag); }
00050 public final boolean isPublic() {
00051 return (access_flags & Constants.ACC_PUBLIC) != 0;
00052 }
00053 public final void isPublic(boolean flag) { setFlag(Constants.ACC_PUBLIC, flag); }
00054 public final boolean isStatic() {
00055 return (access_flags & Constants.ACC_STATIC) != 0;
00056 }
00057 public final void isStatic(boolean flag) { setFlag(Constants.ACC_STATIC, flag); }
00058 public final boolean isSynchronized() {
00059 return (access_flags & Constants.ACC_SYNCHRONIZED) != 0;
00060 }
00061 public final void isSynchronized(boolean flag) { setFlag(Constants.ACC_SYNCHRONIZED, flag); }
00062 public final boolean isTransient() {
00063 return (access_flags & Constants.ACC_TRANSIENT) != 0;
00064 }
00065 public final void isTransient(boolean flag) { setFlag(Constants.ACC_TRANSIENT, flag); }
00066 public final boolean isVolatile() {
00067 return (access_flags & Constants.ACC_VOLATILE) != 0;
00068 }
00069 public final void isVolatile(boolean flag) { setFlag(Constants.ACC_VOLATILE, flag); }
00070
00071
00072
00073 public final void setAccessFlags(int access_flags) {
00074 this.access_flags = access_flags;
00075 }
00076 private final void setFlag(int flag, boolean set) {
00077 if((access_flags & flag) != 0) {
00078 if(!set)
00079 access_flags ^= flag;
00080 } else {
00081 if(set)
00082 access_flags |= flag;
00083 }
00084 }
00085 }