1 7 8 20 21 package java.text; 22 23 import java.util.Vector ; 24 import sun.text.UCompactIntArray; 25 import sun.text.IntHashtable; 26 27 33 final class RBCollationTables { 34 61 public RBCollationTables(String rules, int decmp) throws ParseException { 62 this.rules = rules; 63 64 RBTableBuilder builder = new RBTableBuilder (new BuildAPI()); 65 builder.build(rules, decmp); } 68 69 final class BuildAPI { 70 74 private BuildAPI() { 75 } 76 77 94 void fillInTables(boolean f2ary, 95 boolean swap, 96 UCompactIntArray map, 97 Vector cTbl, 98 Vector eTbl, 99 IntHashtable cFlgs, 100 short mso, 101 short mto) { 102 frenchSec = f2ary; 103 seAsianSwapping = swap; 104 mapping = map; 105 contractTable = cTbl; 106 expandTable = eTbl; 107 contractFlags = cFlgs; 108 maxSecOrder = mso; 109 maxTerOrder = mto; 110 } 111 } 112 113 118 public String getRules() 119 { 120 return rules; 121 } 122 123 public boolean isFrenchSec() { 124 return frenchSec; 125 } 126 127 public boolean isSEAsianSwapping() { 128 return seAsianSwapping; 129 } 130 131 135 140 Vector getContractValues(int ch) 141 { 142 int index = mapping.elementAt(ch); 143 return getContractValuesImpl(index - CONTRACTCHARINDEX); 144 } 145 146 private Vector getContractValuesImpl(int index) 148 { 149 if (index >= 0) 150 { 151 return (Vector )contractTable.elementAt(index); 152 } 153 else { 155 return null; 156 } 157 } 158 159 163 boolean usedInContractSeq(int c) { 164 return contractFlags.get(c) == 1; 165 } 166 167 177 int getMaxExpansion(int order) 178 { 179 int result = 1; 180 181 if (expandTable != null) { 182 for (int i = 0; i < expandTable.size(); i++) { 187 int[] valueList = (int [])expandTable.elementAt(i); 188 int length = valueList.length; 189 190 if (length > result && valueList[length-1] == order) { 191 result = length; 192 } 193 } 194 } 195 196 return result; 197 } 198 199 204 final int[] getExpandValueList(int order) { 205 return (int[])expandTable.elementAt(order - EXPANDCHARINDEX); 206 } 207 208 212 int getUnicodeOrder(int ch) 213 { 214 return mapping.elementAt(ch); 215 } 216 217 short getMaxSecOrder() { 218 return maxSecOrder; 219 } 220 221 short getMaxTerOrder() { 222 return maxTerOrder; 223 } 224 225 228 static void reverse (StringBuffer result, int from, int to) 231 { 232 int i = from; 233 char swap; 234 235 int j = to - 1; 236 while (i < j) { 237 swap = result.charAt(i); 238 result.setCharAt(i, result.charAt(j)); 239 result.setCharAt(j, swap); 240 i++; 241 j--; 242 } 243 } 244 245 final static int getEntry(Vector list, String name, boolean fwd) { 246 for (int i = 0; i < list.size(); i++) { 247 EntryPair pair = (EntryPair )list.elementAt(i); 248 if (pair.fwd == fwd && pair.entryName.equals(name)) { 249 return i; 250 } 251 } 252 return UNMAPPED; 253 } 254 255 final static int EXPANDCHARINDEX = 0x7E000000; final static int CONTRACTCHARINDEX = 0x7F000000; final static int UNMAPPED = 0xFFFFFFFF; 262 263 final static int PRIMARYORDERMASK = 0xffff0000; 264 final static int SECONDARYORDERMASK = 0x0000ff00; 265 final static int TERTIARYORDERMASK = 0x000000ff; 266 final static int PRIMARYDIFFERENCEONLY = 0xffff0000; 267 final static int SECONDARYDIFFERENCEONLY = 0xffffff00; 268 final static int PRIMARYORDERSHIFT = 16; 269 final static int SECONDARYORDERSHIFT = 8; 270 271 private String rules = null; 275 private boolean frenchSec = false; 276 private boolean seAsianSwapping = false; 277 278 private UCompactIntArray mapping = null; 279 private Vector contractTable = null; 280 private Vector expandTable = null; 281 private IntHashtable contractFlags = null; 282 283 private short maxSecOrder = 0; 284 private short maxTerOrder = 0; 285 } 286 | Popular Tags |