1 package com.daffodilwoods.daffodildb.server.sql99.common; 2 3 40 45 46 public class OctetMap { 47 boolean[] isValid = new boolean[256]; 48 49 public static OctetMap tokenChars; 50 public static OctetMap uriChars; 51 public static OctetMap numberChars; 52 public static OctetMap fieldValueChars; 53 public static OctetMap wsChars; 54 public static OctetMap crlfChars; 55 56 public static OctetMap dquoteChar = new OctetMap('"'); 57 58 static { 59 tokenChars = new OctetMap(32, 126); 60 tokenChars.exclude("()<>@,;:\\\"/[]?={} "); 61 62 uriChars = new OctetMap(0, 255); 63 uriChars.exclude("? \r\n"); 64 65 numberChars = new OctetMap('0', '9'); 66 numberChars.include('.', '.'); 67 68 fieldValueChars = new OctetMap(32, 126); 69 70 wsChars = new OctetMap(' '); 71 wsChars.include('\t'); 72 73 crlfChars = new OctetMap('\r'); 74 crlfChars.include('\n'); 75 } 76 77 public OctetMap(int c) { 78 include(c); 79 } 80 81 public OctetMap(int start, int end) { 82 include(start, end); 83 } 84 85 public OctetMap(String s) { 86 include(s); 87 } 88 89 public void include(int start, int end) { 90 for (int i = start; i <= end; i++) { 91 isValid[i] = true; 92 } 93 } 94 95 public void include(int c) { 96 isValid[c] = true; 97 } 98 99 public void exclude(int start, int end) { 100 for (int i = start; i <= end; i++) { 101 isValid[i] = false; 102 } 103 } 104 105 public void exclude(String s) { 106 for (int i = 0; i < s.length(); i++) { 107 isValid[ (byte) s.charAt(i)] = false; 108 } 109 } 110 111 public void include(String s) { 112 for (int i = 0; i < s.length(); i++) { 113 isValid[ (byte) s.charAt(i)] = true; 114 } 115 } 116 117 public boolean has(int b) { 118 return isValid[b & 0xff]; 119 } 120 } 121 | Popular Tags |