jdk/src/share/classes/java/util/regex/ASCII.java
author naoto
Wed, 21 Jan 2009 13:58:46 -0800
changeset 1848 6ecbe9158c6e
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6627549: ISO 3166 code addition: Saint Barthelemy and Saint Martin 6786276: Locale.getISOCountries() still contains country code "CS" Reviewed-by: okutsu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1999-2000 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.util.regex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * Utility class that implements the standard C ctype functionality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * @author Hong Zhang
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
final class ASCII {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    static final int UPPER   = 0x00000100;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    static final int LOWER   = 0x00000200;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    static final int DIGIT   = 0x00000400;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    static final int SPACE   = 0x00000800;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    static final int PUNCT   = 0x00001000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    static final int CNTRL   = 0x00002000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    static final int BLANK   = 0x00004000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    static final int HEX     = 0x00008000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    static final int UNDER   = 0x00010000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    static final int ASCII   = 0x0000FF00;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    static final int ALPHA   = (UPPER|LOWER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    static final int ALNUM   = (UPPER|LOWER|DIGIT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    static final int GRAPH   = (PUNCT|UPPER|LOWER|DIGIT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    static final int WORD    = (UPPER|LOWER|UNDER|DIGIT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    static final int XDIGIT  = (HEX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private static final int[] ctype = new int[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        CNTRL,                  /* 00 (NUL) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        CNTRL,                  /* 01 (SOH) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        CNTRL,                  /* 02 (STX) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        CNTRL,                  /* 03 (ETX) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        CNTRL,                  /* 04 (EOT) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        CNTRL,                  /* 05 (ENQ) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        CNTRL,                  /* 06 (ACK) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        CNTRL,                  /* 07 (BEL) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        CNTRL,                  /* 08 (BS)  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        SPACE+CNTRL+BLANK,      /* 09 (HT)  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        SPACE+CNTRL,            /* 0A (LF)  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        SPACE+CNTRL,            /* 0B (VT)  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        SPACE+CNTRL,            /* 0C (FF)  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        SPACE+CNTRL,            /* 0D (CR)  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        CNTRL,                  /* 0E (SI)  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        CNTRL,                  /* 0F (SO)  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        CNTRL,                  /* 10 (DLE) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        CNTRL,                  /* 11 (DC1) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        CNTRL,                  /* 12 (DC2) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        CNTRL,                  /* 13 (DC3) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        CNTRL,                  /* 14 (DC4) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        CNTRL,                  /* 15 (NAK) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        CNTRL,                  /* 16 (SYN) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        CNTRL,                  /* 17 (ETB) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        CNTRL,                  /* 18 (CAN) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        CNTRL,                  /* 19 (EM)  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        CNTRL,                  /* 1A (SUB) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        CNTRL,                  /* 1B (ESC) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        CNTRL,                  /* 1C (FS)  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        CNTRL,                  /* 1D (GS)  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        CNTRL,                  /* 1E (RS)  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        CNTRL,                  /* 1F (US)  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        SPACE+BLANK,            /* 20 SPACE */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        PUNCT,                  /* 21 !     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        PUNCT,                  /* 22 "     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        PUNCT,                  /* 23 #     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        PUNCT,                  /* 24 $     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        PUNCT,                  /* 25 %     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        PUNCT,                  /* 26 &     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        PUNCT,                  /* 27 '     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        PUNCT,                  /* 28 (     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        PUNCT,                  /* 29 )     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        PUNCT,                  /* 2A *     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        PUNCT,                  /* 2B +     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        PUNCT,                  /* 2C ,     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        PUNCT,                  /* 2D -     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        PUNCT,                  /* 2E .     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        PUNCT,                  /* 2F /     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        DIGIT+HEX+0,            /* 30 0     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        DIGIT+HEX+1,            /* 31 1     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        DIGIT+HEX+2,            /* 32 2     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        DIGIT+HEX+3,            /* 33 3     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        DIGIT+HEX+4,            /* 34 4     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        DIGIT+HEX+5,            /* 35 5     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        DIGIT+HEX+6,            /* 36 6     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        DIGIT+HEX+7,            /* 37 7     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        DIGIT+HEX+8,            /* 38 8     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        DIGIT+HEX+9,            /* 39 9     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        PUNCT,                  /* 3A :     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        PUNCT,                  /* 3B ;     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        PUNCT,                  /* 3C <     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        PUNCT,                  /* 3D =     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        PUNCT,                  /* 3E >     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        PUNCT,                  /* 3F ?     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        PUNCT,                  /* 40 @     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        UPPER+HEX+10,           /* 41 A     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        UPPER+HEX+11,           /* 42 B     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        UPPER+HEX+12,           /* 43 C     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        UPPER+HEX+13,           /* 44 D     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        UPPER+HEX+14,           /* 45 E     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        UPPER+HEX+15,           /* 46 F     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        UPPER+16,               /* 47 G     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        UPPER+17,               /* 48 H     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        UPPER+18,               /* 49 I     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        UPPER+19,               /* 4A J     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        UPPER+20,               /* 4B K     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        UPPER+21,               /* 4C L     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        UPPER+22,               /* 4D M     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        UPPER+23,               /* 4E N     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        UPPER+24,               /* 4F O     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        UPPER+25,               /* 50 P     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        UPPER+26,               /* 51 Q     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        UPPER+27,               /* 52 R     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        UPPER+28,               /* 53 S     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        UPPER+29,               /* 54 T     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        UPPER+30,               /* 55 U     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        UPPER+31,               /* 56 V     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        UPPER+32,               /* 57 W     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        UPPER+33,               /* 58 X     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        UPPER+34,               /* 59 Y     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        UPPER+35,               /* 5A Z     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        PUNCT,                  /* 5B [     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        PUNCT,                  /* 5C \     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        PUNCT,                  /* 5D ]     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        PUNCT,                  /* 5E ^     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        PUNCT|UNDER,            /* 5F _     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        PUNCT,                  /* 60 `     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        LOWER+HEX+10,           /* 61 a     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        LOWER+HEX+11,           /* 62 b     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        LOWER+HEX+12,           /* 63 c     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        LOWER+HEX+13,           /* 64 d     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        LOWER+HEX+14,           /* 65 e     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        LOWER+HEX+15,           /* 66 f     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        LOWER+16,               /* 67 g     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        LOWER+17,               /* 68 h     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        LOWER+18,               /* 69 i     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        LOWER+19,               /* 6A j     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        LOWER+20,               /* 6B k     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        LOWER+21,               /* 6C l     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        LOWER+22,               /* 6D m     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        LOWER+23,               /* 6E n     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        LOWER+24,               /* 6F o     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        LOWER+25,               /* 70 p     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        LOWER+26,               /* 71 q     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        LOWER+27,               /* 72 r     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        LOWER+28,               /* 73 s     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        LOWER+29,               /* 74 t     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        LOWER+30,               /* 75 u     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        LOWER+31,               /* 76 v     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        LOWER+32,               /* 77 w     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        LOWER+33,               /* 78 x     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        LOWER+34,               /* 79 y     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        LOWER+35,               /* 7A z     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        PUNCT,                  /* 7B {     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        PUNCT,                  /* 7C |     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        PUNCT,                  /* 7D }     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        PUNCT,                  /* 7E ~     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        CNTRL,                  /* 7F (DEL) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    static int getType(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        return ((ch & 0xFFFFFF80) == 0 ? ctype[ch] : 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    static boolean isType(int ch, int type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        return (getType(ch) & type) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    static boolean isAscii(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        return ((ch & 0xFFFFFF80) == 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    static boolean isAlpha(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        return isType(ch, ALPHA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    static boolean isDigit(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        return ((ch-'0')|('9'-ch)) >= 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    static boolean isAlnum(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        return isType(ch, ALNUM);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    static boolean isGraph(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        return isType(ch, GRAPH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    static boolean isPrint(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        return ((ch-0x20)|(0x7E-ch)) >= 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    static boolean isPunct(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        return isType(ch, PUNCT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    static boolean isSpace(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        return isType(ch, SPACE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    static boolean isHexDigit(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        return isType(ch, HEX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    static boolean isOctDigit(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        return ((ch-'0')|('7'-ch)) >= 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    static boolean isCntrl(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        return isType(ch, CNTRL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    static boolean isLower(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        return ((ch-'a')|('z'-ch)) >= 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    static boolean isUpper(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        return ((ch-'A')|('Z'-ch)) >= 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    static boolean isWord(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        return isType(ch, WORD);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    static int toDigit(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        return (ctype[ch & 0x7F] & 0x3F);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    static int toLower(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        return isUpper(ch) ? (ch + 0x20) : ch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    static int toUpper(int ch) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        return isLower(ch) ? (ch - 0x20) : ch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
}