1 7 package com.ibm.icu.text; 8 import com.ibm.icu.impl.NormalizerImpl; 9 10 51 public final class ComposedCharIter { 53 54 60 public static final char DONE = (char) Normalizer.DONE; 61 62 68 public ComposedCharIter() { 69 compat = false; 70 options =0; 71 } 72 73 74 88 public ComposedCharIter(boolean compat, int options) { 89 this.compat = compat; 90 this.options = options; 91 } 92 93 98 public boolean hasNext() { 99 if (nextChar == Normalizer.DONE) { 100 findNextChar(); 101 } 102 return nextChar != Normalizer.DONE; 103 } 104 105 113 public char next() { 114 if (nextChar == Normalizer.DONE) { 115 findNextChar(); 116 } 117 curChar = nextChar; 118 nextChar = Normalizer.DONE; 119 return (char) curChar; 120 } 121 122 129 public String decomposition() { 130 return new String (decompBuf,0, bufLen); 133 } 134 135 private void findNextChar() { 136 int c=curChar+1; 137 for(;;){ 138 if(c < 0xFFFF){ 139 bufLen = NormalizerImpl.getDecomposition(c,compat, 140 decompBuf,0, 141 decompBuf.length); 142 if(bufLen>0){ 143 break; 146 } 147 c++; 148 }else{ 149 c=Normalizer.DONE; 150 break; 151 } 152 } 153 nextChar=c; 154 } 155 156 private int options; 157 private boolean compat; 158 private char[] decompBuf = new char[100]; 159 private int bufLen=0; 160 private int curChar = 0; 161 private int nextChar = Normalizer.DONE; 162 163 164 }; 165 | Popular Tags |