1 /* 2 * Permission is hereby granted, free of charge, to any person obtaining a copy of 3 * this software and associated documentation files (the "Software"), to deal in 4 * the Software without restriction, including without limitation the rights to 5 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 6 * of the Software, and to permit persons to whom the Software is furnished to do 7 * so, subject to the following conditions: 8 * 9 * The above copyright notice and this permission notice shall be included in all 10 * copies or substantial portions of the Software. 11 * 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 18 * SOFTWARE. 19 */ 20 package jdk.nashorn.internal.runtime.regexp.joni; 21 22 final class BitStatus { 23 public static final int BIT_STATUS_BITS_NUM = 4 * 8; 24 25 public static int bsClear() { 26 return 0; 27 } 28 public static int bsAll() { 29 return -1; 30 } 31 public static boolean bsAt(int stats, int n) { 32 return (n < BIT_STATUS_BITS_NUM ? stats & (1 << n) : (stats & 1)) != 0; 33 } 34 public static int bsOnAt(int stats, int n) { 35 if (n < BIT_STATUS_BITS_NUM) { 36 stats |= (1 << n); 37 } else { 38 stats |= 1; 39 } 40 return stats; 41 } 42 public static int bsOnAtSimple(int stats, int n) { 43 if (n < BIT_STATUS_BITS_NUM) stats |= (1 << n); 44 return stats; 45 } 46 47 public static int bsOnOff(int v, int f, boolean negative) { 48 if (negative) { 49 v &= ~f; 50 } else { 51 v |= f; 52 } 53 return v; 54 } 55 }