1 7 package com.ibm.icu.text; 8 9 17 public abstract class UnicodeFilter implements UnicodeMatcher { 18 19 26 public abstract boolean contains(int c); 27 28 33 public int matches(Replaceable text, 34 int[] offset, 35 int limit, 36 boolean incremental) { 37 int c; 38 if (offset[0] < limit && 39 contains(c = text.char32At(offset[0]))) { 40 offset[0] += UTF16.getCharCount(c); 41 return U_MATCH; 42 } 43 if (offset[0] > limit && 44 contains(c = text.char32At(offset[0]))) { 45 --offset[0]; 49 if (offset[0] >= 0) { 50 offset[0] -= UTF16.getCharCount(text.char32At(offset[0])) - 1; 51 } 52 return U_MATCH; 53 } 54 if (incremental && offset[0] == limit) { 55 return U_PARTIAL_MATCH; 56 } 57 return U_MISMATCH; 58 } 59 60 69 protected UnicodeFilter() {} 70 } 71 | Popular Tags |