View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software 
12   * distributed under the License is distributed on an "AS IS" BASIS, 
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
14   * See the License for the specific language governing permissions and 
15   * limitations under the License.
16   */
17  
18  
19  package org.apache.jdo.impl.enhancer.classfile;
20  import java.util.Stack;
21  
22  /***
23   * ClassMember is a common base class for ClassMethod and ClassField
24   */
25  abstract public class ClassMember implements VMConstants {
26  
27      /* public accessors */
28  
29      /***
30       * Is the member static?
31       */
32      final public boolean isStatic() {
33          return (access() & ACCStatic) != 0;
34      }
35  
36      /***
37       * Is the member final?
38       */
39      final public boolean isFinal() {
40          return (access() & ACCFinal) != 0;
41      }
42  
43      /***
44       * Turn on or off the final qualifier for the member.
45       */
46      public void setIsFinal(boolean newFinal) {
47          if (newFinal)
48              setAccess(access() | ACCFinal);
49          else
50              setAccess(access() & ~ACCFinal);
51      }
52  
53      /***
54       * Is the member private?
55       */
56      final public boolean isPrivate() {
57          return (access() & ACCPrivate) != 0;
58      }
59  
60      /***
61       * Is the member protected?
62       */
63      final public boolean isProtected() {
64          return (access() & ACCProtected) != 0;
65      }
66  
67      /***
68       * Is the member public?
69       */
70      final public boolean isPublic() {
71          return (access() & ACCPublic) != 0;
72      }
73  
74      /* These are expected to be implemented by subtypes */
75  
76      /***
77       * Return the access flags for the method - see VMConstants
78       */
79      abstract public int access();
80  
81      /***
82       * Set the access flags for the method - see VMConstants
83       */
84      abstract public void setAccess(int newAccess);
85  
86      /***
87       * Return the name of the member
88       */
89      abstract public ConstUtf8 name();
90  
91      /***
92       * Return the type signature of the method
93       */
94      abstract public ConstUtf8 signature();
95  
96      /***
97       * Return the attributes associated with the member
98       */
99      abstract public AttributeVector attributes();
100 
101     /***
102      * Compares this instance with another for structural equality.
103      */
104     //@olsen: added method
105     public boolean isEqual(Stack msg, Object obj) {
106         if (!(obj instanceof ClassMember)) {
107             msg.push("obj/obj.getClass() = "
108                      + (obj == null ? null : obj.getClass()));
109             msg.push("this.getClass() = "
110                      + this.getClass());
111             return false;
112         }
113         ClassMember other = (ClassMember)obj;
114 
115         return true;
116     }
117 }