KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gov > nasa > jpf > jvm > JPF_java_lang_Character


1 //
2
// Copyright (C) 2005 United States Government as represented by the
3
// Administrator of the National Aeronautics and Space Administration
4
// (NASA). All Rights Reserved.
5
//
6
// This software is distributed under the NASA Open Source Agreement
7
// (NOSA), version 1.3. The NOSA has been approved by the Open Source
8
// Initiative. See the file NOSA-1.3-JPF at the top of the distribution
9
// directory tree for the complete NOSA document.
10
//
11
// THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
12
// KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
13
// LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
14
// SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
15
// A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
16
// THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
17
// DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
18
//
19
package gov.nasa.jpf.jvm;
20
21 /**
22  * MJI NativePeer class for java.lang.Character library abstraction
23  * Whoever is using this seriously is definitely screwed, performance-wise
24  */

25 public class JPF_java_lang_Character {
26   public static boolean isDefined__C (MJIEnv env, int clsObjRef, char c) {
27     return Character.isDefined(c);
28   }
29
30   public static boolean isDigit__C (MJIEnv env, int clsObjRef, char c) {
31     return Character.isDigit(c);
32   }
33
34   public static boolean isISOControl__C (MJIEnv env, int clsObjRef, char c) {
35     return Character.isISOControl(c);
36   }
37
38   public static boolean isIdentifierIgnorable__C (MJIEnv env, int clsObjRef,
39                                                   char c) {
40     return Character.isIdentifierIgnorable(c);
41   }
42
43   public static boolean isJavaIdentifierPart__C (MJIEnv env, int clsObjRef,
44                                                  char c) {
45     return Character.isJavaIdentifierPart(c);
46   }
47
48   public static boolean isJavaIdentifierStart__C (MJIEnv env, int clsObjRef,
49                                                   char c) {
50     return Character.isJavaIdentifierStart(c);
51   }
52
53   public static boolean isJavaLetterOrDigit__C (MJIEnv env, int clsObjRef,
54                                                 char c) {
55     return Character.isJavaIdentifierPart(c);
56   }
57
58   public static boolean isJavaLetter__C (MJIEnv env, int clsObjRef, char c) {
59     return Character.isJavaIdentifierStart(c);
60   }
61
62   public static boolean isLetterOrDigit__C (MJIEnv env, int clsObjRef, char c) {
63     return Character.isLetterOrDigit(c);
64   }
65
66   public static boolean isLetter__C (MJIEnv env, int clsObjRef, char c) {
67     return Character.isLetter(c);
68   }
69
70   public static boolean isLowerCase__C (MJIEnv env, int clsObjRef, char c) {
71     return Character.isLowerCase(c);
72   }
73
74   public static int getNumericValue__C (MJIEnv env, int clsObjRef, char c) {
75     return Character.getNumericValue(c);
76   }
77
78   public static boolean isSpaceChar__C (MJIEnv env, int clsObjRef, char c) {
79     return Character.isSpaceChar(c);
80   }
81
82   public static boolean isSpace__C (MJIEnv env, int clsObjRef, char c) {
83     return Character.isWhitespace(c);
84   }
85
86   public static boolean isTitleCase__C (MJIEnv env, int clsObjRef, char c) {
87     return Character.isTitleCase(c);
88   }
89
90   public static int getType__C (MJIEnv env, int clsObjRef, char c) {
91     return Character.getType(c);
92   }
93
94   public static boolean isUnicodeIdentifierPart__C (MJIEnv env, int clsObjRef,
95                                                     char c) {
96     return Character.isUnicodeIdentifierPart(c);
97   }
98
99   public static boolean isUnicodeIdentifierStart__C (MJIEnv env, int clsObjRef,
100                                                      char c) {
101     return Character.isUnicodeIdentifierStart(c);
102   }
103
104   public static boolean isUpperCase__C (MJIEnv env, int clsObjRef, char c) {
105     return Character.isUpperCase(c);
106   }
107
108   public static boolean isWhitespace__C (MJIEnv env, int clsObjRef, char c) {
109     return Character.isWhitespace(c);
110   }
111
112   // pcm - we keep this in here to avoid the potentially expensive
113
// real clinit. This has changed a lot in Java 1.4.2 (deferred init, i.e.
114
// we could actually use it now), but in <= 1.4.1 it executes some
115
// 200,000 insns, and some people who didn't grew up with Java might
116
// deduce that JPF is hanging. It's not, it just shows why a real VM has to
117
// be fast.
118
// It is actually Ok to bypass the real clinit if we turn all the
119
// important methods into native ones, i.e. delegate to the real thing.
120
public static void $clinit (MJIEnv env, int clsObjRef) {
121     env.setStaticByteField("java.lang.Character", "UNASSIGNED", (byte) 0);
122     env.setStaticByteField("java.lang.Character", "UPPERCASE_LETTER", (byte) 1);
123     env.setStaticByteField("java.lang.Character", "LOWERCASE_LETTER", (byte) 2);
124     env.setStaticByteField("java.lang.Character", "TITLECASE_LETTER", (byte) 3);
125     env.setStaticByteField("java.lang.Character", "MODIFIER_LETTER", (byte) 4);
126     env.setStaticByteField("java.lang.Character", "OTHER_LETTER", (byte) 5);
127     env.setStaticByteField("java.lang.Character", "NON_SPACING_MARK", (byte) 6);
128     env.setStaticByteField("java.lang.Character", "ENCLOSING_MARK", (byte) 7);
129     env.setStaticByteField("java.lang.Character", "COMBINING_SPACING_MARK",
130                            (byte) 8);
131     env.setStaticByteField("java.lang.Character", "DECIMAL_DIGIT_NUMBER",
132                            (byte) 9);
133     env.setStaticByteField("java.lang.Character", "LETTER_NUMBER", (byte) 10);
134     env.setStaticByteField("java.lang.Character", "OTHER_NUMBER", (byte) 11);
135     env.setStaticByteField("java.lang.Character", "SPACE_SEPARATOR", (byte) 12);
136     env.setStaticByteField("java.lang.Character", "LINE_SEPARATOR", (byte) 13);
137     env.setStaticByteField("java.lang.Character", "PARAGRAPH_SEPARATOR",
138                            (byte) 14);
139     env.setStaticByteField("java.lang.Character", "CONTROL", (byte) 15);
140     env.setStaticByteField("java.lang.Character", "FORMAT", (byte) 16);
141     env.setStaticByteField("java.lang.Character", "PRIVATE_USE", (byte) 18);
142     env.setStaticByteField("java.lang.Character", "SURROGATE", (byte) 19);
143     env.setStaticByteField("java.lang.Character", "DASH_PUNCTUATION", (byte) 20);
144     env.setStaticByteField("java.lang.Character", "START_PUNCTUATION",
145                            (byte) 21);
146     env.setStaticByteField("java.lang.Character", "END_PUNCTUATION", (byte) 22);
147     env.setStaticByteField("java.lang.Character", "CONNECTOR_PUNCTUATION",
148                            (byte) 23);
149     env.setStaticByteField("java.lang.Character", "OTHER_PUNCTUATION",
150                            (byte) 24);
151     env.setStaticByteField("java.lang.Character", "MATH_SYMBOL", (byte) 25);
152     env.setStaticByteField("java.lang.Character", "CURRENCY_SYMBOL", (byte) 26);
153     env.setStaticByteField("java.lang.Character", "MODIFIER_SYMBOL", (byte) 27);
154     env.setStaticByteField("java.lang.Character", "OTHER_SYMBOL", (byte) 28);
155     env.setStaticIntField("java.lang.Character", "MIN_RADIX", 2);
156     env.setStaticIntField("java.lang.Character", "MAX_RADIX", 36);
157     env.setStaticCharField("java.lang.Character", "MIN_VALUE", '\u0000');
158     env.setStaticCharField("java.lang.Character", "MAX_VALUE", '\uffff');
159
160     ClassInfo ci = ClassInfo.getClassInfo("char");
161     env.setStaticReferenceField("java.lang.Character", "TYPE",
162                              ci.getClassObjectRef());
163
164     env.setBooleanField(clsObjRef, "isPrimitive", true);
165   }
166
167   public static int digit__CI (MJIEnv env, int clsObjRef, char c, int radix) {
168     return Character.digit(c, radix);
169   }
170
171   public static char forDigit__II (MJIEnv env, int clsObjRef, int digit,
172                                    int radix) {
173     return Character.forDigit(digit, radix);
174   }
175
176   public static char toLowerCase__C (MJIEnv env, int clsObjRef, char c) {
177     return Character.toLowerCase(c);
178   }
179
180   public static char toTitleCase__C (MJIEnv env, int clsObjRef, char c) {
181     return Character.toTitleCase(c);
182   }
183
184   public static char toUpperCase__C (MJIEnv env, int clsObjRef, char c) {
185     return Character.toUpperCase(c);
186   }
187 }
188
Popular Tags