Debian Codegraph @

native/jpype_module/src/main/java/org/jpype/manager/ModifierCode.java

raw symbols SCIP
1 /* ****************************************************************************
2 Licensed under the Apache License, Version 2.0 (the "License");
3 you may not use this file except in compliance with the License.
4 You may obtain a copy of the License at
5
6 http://www.apache.org/licenses/LICENSE-2.0
7
8 Unless required by applicable law or agreed to in writing, software
9 distributed under the License is distributed on an "AS IS" BASIS,
10 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 See the License for the specific language governing permissions and
12 limitations under the License.
13
14 See NOTICE file for details.
15 **************************************************************************** */
16 package org.jpype.manager;
17
18 import java.lang.reflect.Modifier;
19 import java.util.EnumSet;
20
21 /**
22 * Definitions for JPype modifiers.
23 * <p>
24 * These pretty much match Java plus a few codes we need.
25 *
26 * @author nelson85
27 */
28 public enum ModifierCode
29 {
30 // we need
31 // fields: static, final
32 // methods: static, final, varargs, constructor
33 // class: interface, throwable, abstract, final
34 PUBLIC(Modifier.PUBLIC),
35 PRIVATE(Modifier.PRIVATE),
36 PROTECTED(Modifier.PROTECTED),
37 STATIC(Modifier.STATIC),
38 FINAL(Modifier.FINAL),
39 VARARGS(0x0080),
40 ENUM(0x4000),
41 ABSTRACT(0x0400),
42 // Special flags for classes required for JPype
43 SPECIAL(0x00010000),
44 THROWABLE(0x00020000),
45 SERIALIZABLE(0x00040000),
46 ANONYMOUS(0x00080000),
47 FUNCTIONAL(0x00100000),
48 CALLER_SENSITIVE(0x00200000),
49 PRIMITIVE_ARRAY(0x00400000),
50 COMPARABLE(0x00800000),
51 BUFFER(0x01000000),
52 CTOR(0x10000000),
53 BEAN_ACCESSOR(0x20000000),
54 BEAN_MUTATOR(0x40000000);
55 final public int value;
56
57 ModifierCode(int value)
58 {
59 this.value = value;
60 }
61
62 public static int get(EnumSet<ModifierCode> set)
63 {
64 int out = 0;
65 for (ModifierCode m : set)
66 {
67 out |= m.value;
68 }
69 return out;
70 }
71
72 public static EnumSet<ModifierCode> decode(long modifiers)
73 {
74 EnumSet<ModifierCode> out = EnumSet.noneOf(ModifierCode.class);
75 for (ModifierCode code : ModifierCode.values())
76 {
77 if ((modifiers & code.value) == code.value)
78 out.add(code);
79 }
80 return out;
81 }
82 }