예제 #1
0
 private static String pretty(String source) {
   StringBuilder result = new StringBuilder();
   for (int i = 0; i < source.length(); ++i) {
     char c = source.charAt(i);
     String color =
         lead.contains(c)
             ? "FFcccc"
             : vowel.contains(c) ? "ccFFcc" : trail.contains(c) ? "ccccFF" : "FFFFFF";
     result.append("<span style='background-color: #" + color + "'>" + c + "</span>");
   }
   return result.toString();
 }
예제 #2
0
  @Override
  public int next() {
    int current = current();
    int next = rules.next();
    if (next == BreakIterator.DONE) return next;
    else next += workingOffset;

    char c = working.current();
    int following = rules.next(); // lookahead
    if (following != BreakIterator.DONE) {
      following += workingOffset;
      if (rules.getRuleStatus() == 0 && laoSet.contains(c) && verifyPushBack(current, next)) {
        workingOffset = next - 1;
        working.setText(
            text.getText(), text.getStart() + workingOffset, text.getLength() - workingOffset);
        return next - 1;
      }
      rules.previous(); // undo the lookahead
    }

    return next;
  }