Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

AccessFlags.java

00001 package de.fub.bytecode.classfile;
00002 
00003 import  de.fub.bytecode.Constants;
00004 
00005 /**
00006  * Super class for all objects that have modifiers like private, final, ...
00007  * I.e. classes, fields, and methods.
00008  *
00009  * @version $Id: AccessFlags.java,v 1.1.1.1 2002/01/24 03:41:37 pserver Exp $
00010  * @author  <A HREF="http://www.inf.fu-berlin.de/~dahm">M. Dahm</A>
00011  */
00012 public abstract class AccessFlags {
00013   protected int access_flags;
00014   
00015   public AccessFlags() {}  
00016   /**
00017    * @param a inital access flags
00018    */
00019   public AccessFlags(int a) {
00020     access_flags = a;
00021   }  
00022   /** 
00023    * @return Access flags of the object.
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    * @param access_flags Access flags of the object. 
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) { // Flag is set already
00078       if(!set) // Delete flag ?
00079     access_flags ^= flag;
00080     } else {   // Flag not set
00081       if(set)  // Set flag ?
00082     access_flags |= flag;
00083     }
00084   }  
00085 }

Generated at Thu Feb 7 06:36:54 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001