OSDN Git Service

Initial revision
[pf3gnuchains/gcc-fork.git] / libjava / java / lang / reflect / Modifier.java
1 // Modifier.java - Process modifier values.
2
3 /* Copyright (C) 1998, 1999  Cygnus Solutions
4
5    This file is part of libgcj.
6
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
9 details.  */
10
11 /**
12  * @author Tom Tromey <tromey@cygnus.com>
13  * @date October 1, 1998
14  */
15
16 /* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
17  * "The Java Language Specification", ISBN 0-201-63451-1
18  * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
19  * Status: Believed complete and correct to version 1.1
20  */
21
22 package java.lang.reflect;
23
24 public class Modifier
25 {
26   public static final int PUBLIC    = 0x001;
27   public static final int PRIVATE   = 0x002;
28   public static final int PROTECTED = 0x004;
29   public static final int STATIC    = 0x008;
30   public static final int FINAL     = 0x010;
31   public static final int SYNCHRONIZED = 0x020;
32   public static final int VOLATILE  = 0x040;
33   public static final int TRANSIENT = 0x080;
34   public static final int NATIVE    = 0x100;
35   public static final int INTERFACE = 0x200;
36   public static final int ABSTRACT  = 0x400;
37
38   public static boolean isAbstract (int mod)
39   {
40     return (mod & ABSTRACT) != 0;
41   }
42
43   public static boolean isFinal (int mod)
44   {
45     return (mod & FINAL) != 0;
46   }
47
48   public static boolean isInterface (int mod)
49   {
50     return (mod & INTERFACE) != 0;
51   }
52
53   public static boolean isNative (int mod)
54   {
55     return (mod & NATIVE) != 0;
56   }
57
58   public static boolean isPrivate (int mod)
59   {
60     return (mod & PRIVATE) != 0;
61   }
62
63   public static boolean isProtected (int mod)
64   {
65     return (mod & PROTECTED) != 0;
66   }
67
68   public static boolean isPublic (int mod)
69   {
70     return (mod & PUBLIC) != 0;
71   }
72
73   public static boolean isStatic (int mod)
74   {
75     return (mod & STATIC) != 0;
76   }
77
78   public static boolean isSynchronized (int mod)
79   {
80     return (mod & SYNCHRONIZED) != 0;
81   }
82
83   public static boolean isTransient (int mod)
84   {
85     return (mod & TRANSIENT) != 0;
86   }
87
88   public static boolean isVolatile (int mod)
89   {
90     return (mod & VOLATILE) != 0;
91   }
92
93   public static String toString (int mod)
94   {
95     StringBuffer r = new StringBuffer ();
96     toString(mod, r);
97     return r.toString();
98   }
99
100   static void toString (int mod, StringBuffer r)
101   {
102     if (isPublic (mod))
103       r.append("public ");
104     if (isProtected (mod))
105       r.append("protected ");
106     if (isPrivate (mod))
107       r.append("private ");
108     if (isAbstract (mod))
109       r.append("abstract ");
110     if (isStatic (mod))
111       r.append("static ");
112     if (isFinal (mod))
113       r.append("final ");
114     if (isTransient (mod))
115       r.append("transient ");
116     if (isVolatile (mod))
117       r.append("volatile ");
118     if (isNative (mod))
119       r.append("native ");
120     if (isSynchronized (mod))
121       r.append("synchronized ");
122     if (isInterface (mod))
123       r.append("interface ");
124
125     // Trim trailing space.
126     int l = r.length();
127     if (l > 0)
128       r.setLength(l - 1);
129   }
130 }