-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAccessFlags.java
More file actions
138 lines (107 loc) · 3.38 KB
/
AccessFlags.java
File metadata and controls
138 lines (107 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package hasnaer.java.bytecode;
/**
*
* @author hasnae rehioui
*/
public class AccessFlags {
public static int PUBLIC = 0x0001;
public static int PRIVATE = 0x0002;
public static int PROTECTED = 0x0004;
public static int STATIC = 0x0008;
public static int FINAL = 0x0010;
public static int ABSTRACT = 0x0400;
public static int INTERFACE = 0x0200;
public static int TRANSIENT = 0x0080;
public static int VOLATIlE = 0x0040;
public static int SYNCHRONIZED = 0x0020;
public static int NATIVE = 0x0100;
public static int STRICT = 0x0800;
public static boolean isPublic(int flags){
return (flags & PUBLIC) != 0 ;
}
public static boolean isPrivate(int flags){
return (flags & PRIVATE) != 0;
}
public static boolean isInterface(int flags){
return (flags & INTERFACE) != 0;
}
public static boolean isProtected(int flags){
return (flags & PROTECTED) != 0;
}
public static boolean isStatic(int flags){
return (flags & STATIC) != 0;
}
public static boolean isFinal(int flags){
return (flags & FINAL) != 0;
}
public static boolean isAbstract(int flags){
return (flags & ABSTRACT) != 0;
}
public static boolean isTransient(int flags){
return (flags & TRANSIENT) != 0;
}
public static boolean isVolatile(int flags){
return (flags & VOLATIlE) != 0;
}
public static boolean isSynchronized(int flags){
return (flags & SYNCHRONIZED) != 0;
}
public static boolean isNative(int flags){
return (flags & NATIVE) != 0;
}
public static boolean isStrict(int flags){
return (flags & STRICT) != 0;
}
public static String fieldAccess(int flags){
StringBuilder builder = new StringBuilder();
if(isPrivate(flags)){
builder.append("private ");
} else if(isProtected(flags)){
builder.append("protected ");
} else if(isPublic(flags)){
builder.append("private ");
}
if(isFinal(flags)){
builder.append("final ");
}
if(isStatic(flags)){
builder.append("static ");
}
if(isVolatile(flags)){
builder.append("volatile ");
}
if(isTransient(flags)){
builder.append("transient ");
}
return builder.toString();
}
public static String methodAccess(int flags){
StringBuilder builder = new StringBuilder();
if(isPrivate(flags)){
builder.append("private ");
} else if(isPublic(flags)){
builder.append("public ");
} else if(isProtected(flags)){
builder.append("protected ");
}
if(isFinal(flags)){
builder.append("final ");
}
if(isStatic(flags)){
builder.append("static ");
}
if(isSynchronized(flags)){
builder.append("synchronized ");
}
if(isNative(flags)){
builder.append("native ");
}
if(isAbstract(flags)){
builder.append("abstract ");
}
if(isStrict(flags)){
builder.append("strictfp ");
}
return builder.toString();
}
}