< prev index next >

src/java.base/share/classes/java/util/regex/ASCII.java

Print this page
rev 56177 : [mq]: 8230365-Pattern-for-a-control-char-matches-non-control-characters
   1 /*
   2  * Copyright (c) 1999, 2000, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 240     }
 241 
 242     static boolean isOctDigit(int ch) {
 243         return ((ch-'0')|('7'-ch)) >= 0;
 244     }
 245 
 246     static boolean isCntrl(int ch) {
 247         return isType(ch, CNTRL);
 248     }
 249 
 250     static boolean isLower(int ch) {
 251         return ((ch-'a')|('z'-ch)) >= 0;
 252     }
 253 
 254     static boolean isUpper(int ch) {
 255         return ((ch-'A')|('Z'-ch)) >= 0;
 256     }
 257 
 258     static boolean isWord(int ch) {
 259         return isType(ch, WORD);




 260     }
 261 
 262     static int toDigit(int ch) {
 263         return (ctype[ch & 0x7F] & 0x3F);
 264     }
 265 
 266     static int toLower(int ch) {
 267         return isUpper(ch) ? (ch + 0x20) : ch;
 268     }
 269 
 270     static int toUpper(int ch) {
 271         return isLower(ch) ? (ch - 0x20) : ch;
 272     }
 273 
 274 }
   1 /*
   2  * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 240     }
 241 
 242     static boolean isOctDigit(int ch) {
 243         return ((ch-'0')|('7'-ch)) >= 0;
 244     }
 245 
 246     static boolean isCntrl(int ch) {
 247         return isType(ch, CNTRL);
 248     }
 249 
 250     static boolean isLower(int ch) {
 251         return ((ch-'a')|('z'-ch)) >= 0;
 252     }
 253 
 254     static boolean isUpper(int ch) {
 255         return ((ch-'A')|('Z'-ch)) >= 0;
 256     }
 257 
 258     static boolean isWord(int ch) {
 259         return isType(ch, WORD);
 260     }
 261 
 262     static boolean isCntrlId(int ch) {
 263         return ((ch-0x3f)|(0x5f-ch)) >= 0;
 264     }
 265 
 266     static int toDigit(int ch) {
 267         return (ctype[ch & 0x7F] & 0x3F);
 268     }
 269 
 270     static int toLower(int ch) {
 271         return isUpper(ch) ? (ch + 0x20) : ch;
 272     }
 273 
 274     static int toUpper(int ch) {
 275         return isLower(ch) ? (ch - 0x20) : ch;
 276     }
 277 
 278 }
< prev index next >