33 * Constant that indicates the iteration has completed. 34 * {@link #next} returns this value when there are no more composed characters 35 * over which to iterate. 36 */ 37 public static final int DONE = NormalizerBase.DONE; 38 39 //cache the decomps mapping, so the seconde composedcharIter does 40 //not need to get the data again. 41 private static int chars[]; 42 private static String decomps[]; 43 private static int decompNum; 44 45 static { 46 int maxNum = 2000; //TBD: Unicode 4.0 only has 1926 canoDecomp... 47 chars = new int[maxNum]; 48 decomps = new String[maxNum]; 49 decompNum = NormalizerImpl.getDecompose(chars, decomps); 50 } 51 52 /** 53 * Construct a new <tt>ComposedCharIter</tt>. The iterator will return 54 * all Unicode characters with canonical decompositions, excluding Korean 55 * Hangul characters. 56 */ 57 public ComposedCharIter() { } 58 59 /** 60 * Returns the next precomposed Unicode character. 61 * Repeated calls to <tt>next</tt> return all of the precomposed characters defined 62 * by Unicode, in ascending order. After all precomposed characters have 63 * been returned, {@link #hasNext} will return <tt>false</tt> and further calls 64 * to <tt>next</tt> will return {@link #DONE}. 65 */ 66 public int next() { 67 if (curChar == decompNum - 1) { 68 return DONE; 69 } 70 return chars[++curChar]; 71 } 72 73 /** 74 * Returns the Unicode decomposition of the current character. 75 * This method returns the decomposition of the precomposed character most 76 * recently returned by {@link #next}. The resulting decomposition is 77 * affected by the settings of the options passed to the constructor. 78 */ 79 public String decomposition() { 80 return decomps[curChar]; 81 } 82 private int curChar = -1; 83 } | 33 * Constant that indicates the iteration has completed. 34 * {@link #next} returns this value when there are no more composed characters 35 * over which to iterate. 36 */ 37 public static final int DONE = NormalizerBase.DONE; 38 39 //cache the decomps mapping, so the seconde composedcharIter does 40 //not need to get the data again. 41 private static int chars[]; 42 private static String decomps[]; 43 private static int decompNum; 44 45 static { 46 int maxNum = 2000; //TBD: Unicode 4.0 only has 1926 canoDecomp... 47 chars = new int[maxNum]; 48 decomps = new String[maxNum]; 49 decompNum = NormalizerImpl.getDecompose(chars, decomps); 50 } 51 52 /** 53 * Construct a new {@code ComposedCharIter}. The iterator will return 54 * all Unicode characters with canonical decompositions, excluding Korean 55 * Hangul characters. 56 */ 57 public ComposedCharIter() { } 58 59 /** 60 * Returns the next precomposed Unicode character. 61 * Repeated calls to {@code next} return all of the precomposed characters defined 62 * by Unicode, in ascending order. After all precomposed characters have 63 * been returned, {@link #hasNext} will return {@code false} and further calls 64 * to {@code next} will return {@link #DONE}. 65 */ 66 public int next() { 67 if (curChar == decompNum - 1) { 68 return DONE; 69 } 70 return chars[++curChar]; 71 } 72 73 /** 74 * Returns the Unicode decomposition of the current character. 75 * This method returns the decomposition of the precomposed character most 76 * recently returned by {@link #next}. The resulting decomposition is 77 * affected by the settings of the options passed to the constructor. 78 */ 79 public String decomposition() { 80 return decomps[curChar]; 81 } 82 private int curChar = -1; 83 } |