< prev index next >

src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AccessFlags.java

Print this page


   1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.bcel.internal.classfile;
  23 
  24 
  25 import  com.sun.org.apache.bcel.internal.Constants;
  26 
  27 /**
  28  * Super class for all objects that have modifiers like private, final, ...
  29  * I.e. classes, fields, and methods.
  30  *
  31  * @author  <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
  32  */
  33 public abstract class AccessFlags implements java.io.Serializable {
  34   protected int access_flags;
  35 
  36   public AccessFlags() {}



  37 
  38   /**
  39    * @param a inital access flags
  40    */
  41   public AccessFlags(int a) {
  42     access_flags = a;
  43   }
  44 
  45   /**
  46    * @return Access flags of the object aka. "modifiers".
  47    */
  48   public final int getAccessFlags() { return access_flags; }


  49 
  50   /**
  51    * @return Access flags of the object aka. "modifiers".
  52    */
  53   public final int getModifiers() { return access_flags; }


  54 
  55   /** Set access flags aka "modifiers".


  56    * @param access_flags Access flags of the object.
  57    */
  58   public final void setAccessFlags(int access_flags) {
  59     this.access_flags = access_flags;
  60   }
  61 
  62   /** Set access flags aka "modifiers".


  63    * @param access_flags Access flags of the object.
  64    */
  65   public final void setModifiers(int access_flags) {
  66     setAccessFlags(access_flags);
  67   }
  68 
  69   private final void setFlag(int flag, boolean set) {
  70     if((access_flags & flag) != 0) { // Flag is set already
  71       if(!set) // Delete flag ?
  72         access_flags ^= flag;

  73     } else {   // Flag not set
  74       if(set)  // Set flag ?
  75         access_flags |= flag;
  76     }
  77   }





  78 
  79   public final void isPublic(boolean flag) { setFlag(Constants.ACC_PUBLIC, flag); }
  80   public final boolean isPublic() {
  81     return (access_flags & Constants.ACC_PUBLIC) != 0;




  82   }
  83 
  84   public final void isPrivate(boolean flag) { setFlag(Constants.ACC_PRIVATE, flag); }
  85   public final boolean isPrivate() {
  86     return (access_flags & Constants.ACC_PRIVATE) != 0;




  87   }
  88 
  89   public final void isProtected(boolean flag) { setFlag(Constants.ACC_PROTECTED, flag); }
  90   public final boolean isProtected() {
  91     return (access_flags & Constants.ACC_PROTECTED) != 0;




  92   }
  93 
  94   public final void isStatic(boolean flag) { setFlag(Constants.ACC_STATIC, flag); }
  95   public final boolean isStatic() {
  96     return (access_flags & Constants.ACC_STATIC) != 0;




  97   }
  98 
  99   public final void isFinal(boolean flag) { setFlag(Constants.ACC_FINAL, flag); }
 100   public final boolean isFinal() {
 101     return (access_flags & Constants.ACC_FINAL) != 0;




 102   }
 103 
 104   public final void isSynchronized(boolean flag) { setFlag(Constants.ACC_SYNCHRONIZED, flag); }
 105   public final boolean isSynchronized() {
 106     return (access_flags & Constants.ACC_SYNCHRONIZED) != 0;




 107   }
 108 
 109   public final void isVolatile(boolean flag) { setFlag(Constants.ACC_VOLATILE, flag); }
 110   public final boolean isVolatile() {
 111     return (access_flags & Constants.ACC_VOLATILE) != 0;




 112   }
 113 
 114   public final void isTransient(boolean flag) { setFlag(Constants.ACC_TRANSIENT, flag); }
 115   public final boolean isTransient() {
 116     return (access_flags & Constants.ACC_TRANSIENT) != 0;




 117   }
 118 
 119   public final void isNative(boolean flag) { setFlag(Constants.ACC_NATIVE, flag); }
 120   public final boolean isNative() {
 121     return (access_flags & Constants.ACC_NATIVE) != 0;




 122   }
 123 
 124   public final void isInterface(boolean flag) { setFlag(Constants.ACC_INTERFACE, flag); }
 125   public final boolean isInterface() {
 126     return (access_flags & Constants.ACC_INTERFACE) != 0;




 127   }
 128 
 129   public final void isAbstract(boolean flag) { setFlag(Constants.ACC_ABSTRACT, flag); }
 130   public final boolean isAbstract() {
 131     return (access_flags & Constants.ACC_ABSTRACT) != 0;




 132   }
 133 
 134   public final void isStrictfp(boolean flag) { setFlag(Constants.ACC_STRICT, flag); }
 135   public final boolean isStrictfp() {
 136     return (access_flags & Constants.ACC_STRICT) != 0;
































 137   }
 138 }
   1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.

   3  */
   4 /*
   5  * Licensed to the Apache Software Foundation (ASF) under one or more
   6  * contributor license agreements.  See the NOTICE file distributed with
   7  * this work for additional information regarding copyright ownership.
   8  * The ASF licenses this file to You under the Apache License, Version 2.0
   9  * (the "License"); you may not use this file except in compliance with
  10  * the License.  You may obtain a copy of the License at
  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */

  20 package com.sun.org.apache.bcel.internal.classfile;
  21 
  22 import com.sun.org.apache.bcel.internal.Const;

  23 
  24 /**
  25  * Super class for all objects that have modifiers like private, final, ... I.e.
  26  * classes, fields, and methods.
  27  *
  28  * @version $Id: AccessFlags.java 1748636 2016-06-15 20:45:17Z dbrosius $
  29  */
  30 public abstract class AccessFlags {

  31 
  32     private int access_flags;
  33 
  34     public AccessFlags() {
  35     }
  36 
  37     /**
  38      * @param a inital access flags
  39      */
  40     public AccessFlags(final int a) {
  41         access_flags = a;
  42     }
  43 
  44     /**
  45      * @return Access flags of the object aka. "modifiers".
  46      */
  47     public final int getAccessFlags() {
  48         return access_flags;
  49     }
  50 
  51     /**
  52      * @return Access flags of the object aka. "modifiers".
  53      */
  54     public final int getModifiers() {
  55         return access_flags;
  56     }
  57 
  58     /**
  59      * Set access flags aka "modifiers".
  60      *
  61      * @param access_flags Access flags of the object.
  62      */
  63     public final void setAccessFlags(final int access_flags) {
  64         this.access_flags = access_flags;
  65     }
  66 
  67     /**
  68      * Set access flags aka "modifiers".
  69      *
  70      * @param access_flags Access flags of the object.
  71      */
  72     public final void setModifiers(final int access_flags) {
  73         setAccessFlags(access_flags);
  74     }
  75 
  76     private void setFlag(final int flag, final boolean set) {
  77         if ((access_flags & flag) != 0) { // Flag is set already
  78             if (!set) {
  79                 access_flags ^= flag;
  80             }
  81         } else { // Flag not set
  82             if (set) {
  83                 access_flags |= flag;
  84             }
  85         }
  86     }
  87 
  88     public final void isPublic(final boolean flag) {
  89         setFlag(Const.ACC_PUBLIC, flag);
  90     }
  91 

  92     public final boolean isPublic() {
  93         return (access_flags & Const.ACC_PUBLIC) != 0;
  94     }
  95 
  96     public final void isPrivate(final boolean flag) {
  97         setFlag(Const.ACC_PRIVATE, flag);
  98     }
  99 

 100     public final boolean isPrivate() {
 101         return (access_flags & Const.ACC_PRIVATE) != 0;
 102     }
 103 
 104     public final void isProtected(final boolean flag) {
 105         setFlag(Const.ACC_PROTECTED, flag);
 106     }
 107 

 108     public final boolean isProtected() {
 109         return (access_flags & Const.ACC_PROTECTED) != 0;
 110     }
 111 
 112     public final void isStatic(final boolean flag) {
 113         setFlag(Const.ACC_STATIC, flag);
 114     }
 115 

 116     public final boolean isStatic() {
 117         return (access_flags & Const.ACC_STATIC) != 0;
 118     }
 119 
 120     public final void isFinal(final boolean flag) {
 121         setFlag(Const.ACC_FINAL, flag);
 122     }
 123 

 124     public final boolean isFinal() {
 125         return (access_flags & Const.ACC_FINAL) != 0;
 126     }
 127 
 128     public final void isSynchronized(final boolean flag) {
 129         setFlag(Const.ACC_SYNCHRONIZED, flag);
 130     }
 131 

 132     public final boolean isSynchronized() {
 133         return (access_flags & Const.ACC_SYNCHRONIZED) != 0;
 134     }
 135 
 136     public final void isVolatile(final boolean flag) {
 137         setFlag(Const.ACC_VOLATILE, flag);
 138     }
 139 

 140     public final boolean isVolatile() {
 141         return (access_flags & Const.ACC_VOLATILE) != 0;
 142     }
 143 
 144     public final void isTransient(final boolean flag) {
 145         setFlag(Const.ACC_TRANSIENT, flag);
 146     }
 147 

 148     public final boolean isTransient() {
 149         return (access_flags & Const.ACC_TRANSIENT) != 0;
 150     }
 151 
 152     public final void isNative(final boolean flag) {
 153         setFlag(Const.ACC_NATIVE, flag);
 154     }
 155 

 156     public final boolean isNative() {
 157         return (access_flags & Const.ACC_NATIVE) != 0;
 158     }
 159 
 160     public final void isInterface(final boolean flag) {
 161         setFlag(Const.ACC_INTERFACE, flag);
 162     }
 163 

 164     public final boolean isInterface() {
 165         return (access_flags & Const.ACC_INTERFACE) != 0;
 166     }
 167 
 168     public final void isAbstract(final boolean flag) {
 169         setFlag(Const.ACC_ABSTRACT, flag);
 170     }
 171 

 172     public final boolean isAbstract() {
 173         return (access_flags & Const.ACC_ABSTRACT) != 0;
 174     }
 175 
 176     public final void isStrictfp(final boolean flag) {
 177         setFlag(Const.ACC_STRICT, flag);
 178     }
 179 

 180     public final boolean isStrictfp() {
 181         return (access_flags & Const.ACC_STRICT) != 0;
 182     }
 183 
 184     public final void isSynthetic(final boolean flag) {
 185         setFlag(Const.ACC_SYNTHETIC, flag);
 186     }
 187 
 188     public final boolean isSynthetic() {
 189         return (access_flags & Const.ACC_SYNTHETIC) != 0;
 190     }
 191 
 192     public final void isAnnotation(final boolean flag) {
 193         setFlag(Const.ACC_ANNOTATION, flag);
 194     }
 195 
 196     public final boolean isAnnotation() {
 197         return (access_flags & Const.ACC_ANNOTATION) != 0;
 198     }
 199 
 200     public final void isEnum(final boolean flag) {
 201         setFlag(Const.ACC_ENUM, flag);
 202     }
 203 
 204     public final boolean isEnum() {
 205         return (access_flags & Const.ACC_ENUM) != 0;
 206     }
 207 
 208     public final void isVarArgs(final boolean flag) {
 209         setFlag(Const.ACC_VARARGS, flag);
 210     }
 211 
 212     public final boolean isVarArgs() {
 213         return (access_flags & Const.ACC_VARARGS) != 0;
 214     }
 215 }
< prev index next >