Source code: com/chaoswg/xtc4y/classdesc/AccessFlags.java
1 //$Header: /cvsroot/xtc4y/xtc4y/src/com/chaoswg/xtc4y/classdesc/AccessFlags.java,v 1.3 2003/09/08 21:04:11 toggm Exp $
2 /******************************************************************************
3 * XTC4y - eXtreme Testing Collection 4 you *
4 * -------------------------------------------------------------------------- *
5 * URL: http://www.chaoswg.com/xtc4y *
6 * Author: Mike Toggweiler (2.dog@gmx.ch) *
7 * *
8 * Last Updated: $Date: 2003/09/08 21:04:11 $, by $Author: toggm $ *
9 * Version: $Revision: 1.3 $ *
10 * -------------------------------------------------------------------------- *
11 * COPYRIGHT: (c) 2003 by Mike Toggweiler *
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 *****************************************************************************/
18 package com.chaoswg.xtc4y.classdesc;
19
20 import java.io.DataInputStream;
21 import java.io.DataOutputStream;
22 import java.io.IOException;
23
24 /**
25 * this class represents the accessflags configured for the current field
26 * @author Mike Toggweiler
27 **/
28 public abstract class AccessFlags {
29
30 /**
31 * Declared public; may be accessed from outside its package.
32 **/
33 public static final short ACC_PUBLIC = 0x0001;
34
35 /**
36 * Declared private; usable only within the defining class.
37 **/
38 public static final short ACC_PRIVATE = 0x0002;
39
40 /**
41 * Declared protected; may be accessed within subclasses.
42 **/
43 public static final short ACC_PROTECTED = 0x0004;
44
45 /**
46 * Declared static.
47 **/
48 public static final short ACC_STATIC = 0x0008;
49
50 /**
51 * Declared final; no subclasses allowed.
52 **/
53 public static final short ACC_FINAL = 0x0010;
54
55 /**
56 * Treat superclass methods specially when invoked by the invokespecial
57 * instruction.
58 **/
59 public static final short ACC_SUPER = 0x0020;
60
61 /**
62 * Declared synchronized; invocation is wrapped in a monitor lock.
63 **/
64 public static final short ACC_SYNCHRONIZED = 0x0020;
65
66 /**
67 * Declared volatile; cannot be cached.
68 **/
69 public static final short ACC_VOLATILE = 0x0040;
70
71 /**
72 * Declared transient; not written or read by a persistent object manager.
73 **/
74 public static final short ACC_TRANSIENT = 0x0080;
75
76 /**
77 * Declared native; implemented in a language other than Java.
78 **/
79 public static final short ACC_NATIVE = 0x0100;
80
81 /**
82 * Is an interface, not a class.
83 **/
84 public static final short ACC_INTERFACE = 0x0200;
85
86 /**
87 * Declared abstract; may not be instantiated.
88 **/
89 public static final short ACC_ABSTRACT = 0x0400;
90
91 /**
92 * Declared strictfp; floating-point mode is FP-strict
93 **/
94 public static final short ACC_STRICT = 0x0800;
95
96 /**
97 * The complementare of the flags
98 **/
99 public static final short ACC_PUBLIC_COMP = (short)0xFFFF - ACC_PUBLIC;
100 public static final short ACC_PRIVATE_COMP = (short)0xFFFF - ACC_PRIVATE;
101 public static final short ACC_PROTECTED_COMP =
102 (short)0xFFFF - ACC_PROTECTED;
103 public static final short ACC_STATIC_COMP = (short)0xFFFF - ACC_STATIC;
104 public static final short ACC_SUPER_COMP = (short)0xFFFF - ACC_SUPER;
105 public static final short ACC_SYNCHRONIZED_COMP =
106 (short)0xFFFF - ACC_SYNCHRONIZED;
107 public static final short ACC_FINAL_COMP = (short)0xFFFF - ACC_FINAL;
108 public static final short ACC_VOLATILE_COMP = (short)0xFFFF - ACC_VOLATILE;
109 public static final short ACC_TRANSIENT_COMP =
110 (short)0xFFFF - ACC_TRANSIENT;
111 public static final short ACC_NATIVE_COMP = (short)0xFFFF - ACC_NATIVE;
112 public static final short ACC_INTERFACE_COMP =
113 (short)0xFFFF - ACC_INTERFACE;
114 public static final short ACC_ABSTRACT_COMP = (short)0xFFFF - ACC_ABSTRACT;
115 public static final short ACC_STRICT_COMP = (short)0xFFFF - ACC_STRICT;
116
117
118 /**
119 * Some masks used
120 **/
121 protected static final short MASK_ACCESS = (short)0xFFF0;
122
123 /**
124 * Constructs a new field access flag
125 * @param access initial access flag
126 **/
127 public AccessFlags(short access) {
128 setAccessFlag(access);
129 }
130
131 /**
132 * Creates a AccessFlags and initializes it from a DataInputStream
133 * @param dis the DataInputStream to read from
134 **/
135 protected AccessFlags(DataInputStream dis) throws IOException {
136 short access = (short)dis.readUnsignedShort();
137 setAccessFlag(access);
138 }
139
140 /**
141 * Write the constant pool information into a DataOutputStream
142 * @param dos the DataOutputStream to write on
143 **/
144 protected void write(DataOutputStream dos) throws IOException {
145 dos.writeShort(getAccessFlag());
146 }
147
148 /**
149 * Set the read access flag
150 * @param access flag
151 **/
152 protected abstract void setAccessFlag(short access);
153
154 /**
155 * Read the possibly modified access flags
156 * @return the current access flags
157 **/
158 protected abstract short getAccessFlag();
159
160 /**
161 * Print access flag in a readable way
162 **/
163 public String toString() {
164 return String.valueOf(getAccessFlag());
165 }
166 }