/** * {@inheritDoc} * @stable ICU 4.4 */ @Override public Normalizer.QuickCheckResult quickCheck(CharSequence s) { Normalizer.QuickCheckResult result=Normalizer.YES; UnicodeSet.SpanCondition spanCondition=UnicodeSet.SpanCondition.SIMPLE; for(int prevSpanLimit=0; prevSpanLimit<s.length();) { int spanLimit=set.span(s, prevSpanLimit, spanCondition); if(spanCondition==UnicodeSet.SpanCondition.NOT_CONTAINED) { spanCondition=UnicodeSet.SpanCondition.SIMPLE; } else { Normalizer.QuickCheckResult qcResult= norm2.quickCheck(s.subSequence(prevSpanLimit, spanLimit)); if(qcResult==Normalizer.NO) { return qcResult; } else if(qcResult==Normalizer.MAYBE) { result=qcResult; } spanCondition=UnicodeSet.SpanCondition.NOT_CONTAINED; } prevSpanLimit=spanLimit; } return result; } /**
/** * Performing quick check on a string, to quickly determine if the string is * in a particular normalization format. * Three types of result can be returned Normalizer.YES, Normalizer.NO or * Normalizer.MAYBE. Result Normalizer.YES indicates that the argument * string is in the desired normalized format, Normalizer.NO determines that * argument string is not in the desired normalized format. A * Normalizer.MAYBE result indicates that a more thorough check is required, * the user may have to put the string in its normalized form and compare * the results. * * @param source string for determining if it is in a normalized format * @param mode normalization format (Normalizer.NFC,Normalizer.NFD, * Normalizer.NFKC,Normalizer.NFKD) * @param options Options for use with exclusion set and tailored Normalization * The only option that is currently recognized is UNICODE_3_2 * @return Return code to specify if the text is normalized or not * (Normalizer.YES, Normalizer.NO or Normalizer.MAYBE) * @deprecated ICU 56 Use {@link Normalizer2} instead. */ @Deprecated public static QuickCheckResult quickCheck(String source, Mode mode, int options) { return mode.getNormalizer2(options).quickCheck(source); }
/** * Performing quick check on a string, to quickly determine if the string is * in a particular normalization format. * Three types of result can be returned Normalizer.YES, Normalizer.NO or * Normalizer.MAYBE. Result Normalizer.YES indicates that the argument * string is in the desired normalized format, Normalizer.NO determines that * argument string is not in the desired normalized format. A * Normalizer.MAYBE result indicates that a more thorough check is required, * the user may have to put the string in its normalized form and compare * the results. * * @param source string for determining if it is in a normalized format * @param start the start index of the source * @param limit the limit index of the source it is equal to the length * @param mode normalization format (Normalizer.NFC,Normalizer.NFD, * Normalizer.NFKC,Normalizer.NFKD) * @param options Options for use with exclusion set and tailored Normalization * The only option that is currently recognized is UNICODE_3_2 * @return Return code to specify if the text is normalized or not * (Normalizer.YES, Normalizer.NO or * Normalizer.MAYBE) * @deprecated ICU 56 Use {@link Normalizer2} instead. */ @Deprecated public static QuickCheckResult quickCheck(char[] source,int start, int limit, Mode mode,int options) { CharBuffer srcBuffer = CharBuffer.wrap(source, start, limit - start); return mode.getNormalizer2(options).quickCheck(srcBuffer); }
@Override public final boolean incrementToken() throws IOException { if (input.incrementToken()) { if (normalizer.quickCheck(termAtt) != Normalizer.YES) { buffer.setLength(0); normalizer.normalize(termAtt, buffer); termAtt.setEmpty().append(buffer); } return true; } else { return false; } } }
@Override public final boolean incrementToken() throws IOException { if (input.incrementToken()) { if (normalizer.quickCheck(termAtt) != Normalizer.YES) { buffer.setLength(0); normalizer.normalize(termAtt, buffer); termAtt.setEmpty().append(buffer); } return true; } else { return false; } } }