@Override public int following(int offset) { return fIcuBrkItr.following(offset); }
/** * Return true if the specfied position is a boundary position. If the * function returns true, the current iteration position is set to the * specified position; if the function returns false, the current * iteration position is set as though following() had been called. * @param offset the offset to check. * @return True if "offset" is a boundary position. * @stable ICU 2.0 */ public boolean isBoundary(int offset) { // Again, this is the default implementation, which is provided solely because // we couldn't add a new abstract method to an existing class. The real // implementations will usually need to do a little more work. if (offset == 0) { return true; } else return following(offset - 1) == offset; }
/** * Return true if the specified position is a boundary position. If the * function returns true, the current iteration position is set to the * specified position; if the function returns false, the current * iteration position is set as though following() had been called. * @param offset the offset to check. * @return True if "offset" is a boundary position. * @stable ICU 2.0 */ public boolean isBoundary(int offset) { // Again, this is the default implementation, which is provided solely because // we couldn't add a new abstract method to an existing class. The real // implementations will usually need to do a little more work. if (offset == 0) { return true; } else return following(offset - 1) == offset; }
/** * Return true if the specfied position is a boundary position. If the * function returns true, the current iteration position is set to the * specified position; if the function returns false, the current * iteration position is set as though following() had been called. * @param offset the offset to check. * @return True if "offset" is a boundary position. * @stable ICU 2.0 */ public boolean isBoundary(int offset) { // Again, this is the default implementation, which is provided solely because // we couldn't add a new abstract method to an existing class. The real // implementations will usually need to do a little more work. if (offset == 0) { return true; } else return following(offset - 1) == offset; }
private int nextBoundaryAfter(int startIndex) { BreakIterator breakiterator = search_.breakIter(); if (breakiterator == null) { breakiterator = search_.internalBreakIter_; } if (breakiterator != null) { return breakiterator.following(startIndex); } return startIndex; }
/** * Skip the tokens until the stop character is reached. * * @param begin the begin index * @param stop the stop character */ protected final void skipTokens(final int begin, final char stop) { int end= begin; while (end < fContent.length() && fContent.charAt(end) != stop) end++; if (end < fContent.length()) { fNext= end; fPredecessor= fNext; fSuccessor= fWordIterator.following(fNext); } else fSuccessor= BreakIterator.DONE; }
@Override public int following(int offset) { return internalNext(delegate.following(offset)); }
/** * Skip the tokens until the stop character is reached. * * @param begin the begin index * @param stop the stop character */ protected final void skipTokens(final int begin, final int stop) { final boolean isStoppingOnWhiteSpace= stop == WHITE_SPACE_TOKEN; int end= begin; while (end < fContent.length()) { char ch= fContent.charAt(end); if (ch == stop || isStoppingOnWhiteSpace && Character.isWhitespace(ch)) break; end++; } if (end < fContent.length()) { fNext= end; fPredecessor= fNext; fSuccessor= fWordIterator.following(fNext); } else fSuccessor= BreakIterator.DONE; }
/** * Skip the tokens until the stop character is reached. * * @param begin the begin index * @param stop the stop character */ protected final void skipTokens(final int begin, final int stop) { final boolean isStoppingOnWhiteSpace= stop == WHITE_SPACE_TOKEN; int end= begin; while (end < fContent.length()) { char ch= fContent.charAt(end); if (ch == stop || isStoppingOnWhiteSpace && Character.isWhitespace(ch)) break; end++; } if (end < fContent.length()) { fNext= end; fPredecessor= fNext; fSuccessor= fWordIterator.following(fNext); } else fSuccessor= BreakIterator.DONE; }
/** * Sets the iterator's current iteration position to be the last * boundary position preceding the specified position. (Whether the * specified position is itself a boundary position or not doesn't * matter-- this function always moves the iteration position to the * last boundary before the specified position.) If the specified * position is the starting position, returns DONE. * @param offset The character position to start searching from. * @return The position of the last boundary position preceding * "offset" (whether of not "offset" itself is a boundary position), * or DONE if "offset" is the starting offset of the iterator. * @stable ICU 2.0 */ public int preceding(int offset) { // NOTE: This implementation is here solely because we can't add new // abstract methods to an existing class. There is almost ALWAYS a // better, faster way to do this. int pos = following(offset); while (pos >= offset && pos != DONE) pos = previous(); return pos; }
/** * Sets the iterator's current iteration position to be the last * boundary position preceding the specified position. (Whether the * specified position is itself a boundary position or not doesn't * matter-- this function always moves the iteration position to the * last boundary before the specified position.) If the specified * position is the starting position, returns DONE. * @param offset The character position to start searching from. * @return The position of the last boundary position preceding * "offset" (whether of not "offset" itself is a boundary position), * or DONE if "offset" is the starting offset of the iterator. * @stable ICU 2.0 */ public int preceding(int offset) { // NOTE: This implementation is here solely because we can't add new // abstract methods to an existing class. There is almost ALWAYS a // better, faster way to do this. int pos = following(offset); while (pos >= offset && pos != DONE) pos = previous(); return pos; }
/** * Sets the iterator's current iteration position to be the last * boundary position preceding the specified position. (Whether the * specified position is itself a boundary position or not doesn't * matter-- this function always moves the iteration position to the * last boundary before the specified position.) If the specified * position is the starting position, returns DONE. * @param offset The character position to start searching from. * @return The position of the last boundary position preceding * "offset" (whether of not "offset" itself is a boundary position), * or DONE if "offset" is the starting offset of the iterator. * @stable ICU 2.0 */ public int preceding(int offset) { // NOTE: This implementation is here solely because we can't add new // abstract methods to an existing class. There is almost ALWAYS a // better, faster way to do this. int pos = following(offset); while (pos >= offset && pos != DONE) pos = previous(); return pos; }
private boolean matchesSegments(String id) { BreakIterator iter = BreakIterator.getWordInstance(); iter.setText(id); int i = iter.first(); while (i != java.text.BreakIterator.DONE && i < id.length()) { int j = iter.following(i); if (j == java.text.BreakIterator.DONE) { j = id.length(); } // match the word if (Character.isLetterOrDigit(id.charAt(i))) { String word = id.substring(i, j); if (matches(word)) return true; } i = j; } return false; } }
private int findNextBreakOffset(int currOffset) { int currWidth= 0; int nextOffset= fLineBreakIterator.following(currOffset); while (nextOffset != BreakIterator.DONE) { String word= fLine.substring(currOffset, nextOffset); int wordWidth= fGC.textExtent(word).x; int nextWidth= wordWidth + currWidth; if (nextWidth > fMaxWidth) { if (currWidth > 0) return currOffset; if (!fBreakWords) return nextOffset; // need to fit into fMaxWidth int length= word.length(); while (length >= 0) { length--; word= word.substring(0, length); wordWidth= fGC.textExtent(word).x; if (wordWidth + currWidth < fMaxWidth) return currOffset + length; } return nextOffset; } currWidth= nextWidth; currOffset= nextOffset; nextOffset= fLineBreakIterator.next(); } return nextOffset; }
private int findNextBreakOffset(int currOffset) { int currWidth= 0; int nextOffset= fLineBreakIterator.following(currOffset); while (nextOffset != BreakIterator.DONE) { String word= fLine.substring(currOffset, nextOffset); int wordWidth= fGC.textExtent(word).x; int nextWidth= wordWidth + currWidth; if (nextWidth > fMaxWidth) { if (currWidth > 0) return currOffset; if (!fBreakWords) return nextOffset; // need to fit into fMaxWidth int length= word.length(); while (length > 0) { length--; word= word.substring(0, length); wordWidth= fGC.textExtent(word).x; if (wordWidth + currWidth < fMaxWidth) return currOffset + length; } return nextOffset; } currWidth= nextWidth; currOffset= nextOffset; nextOffset= fLineBreakIterator.next(); } return nextOffset; }
@Override public int following(int offset) { // work around too eager IAEs in standard implementation if (offset == getText().getEndIndex()) return DONE; int next = fIterator.following(offset); if (next == DONE) return DONE; // TODO deal with complex script word boundaries // Math.min(offset + run.length, next) does not work // since BreakIterator.getWordInstance considers _ as boundaries // seems to work fine, however Run run = consumeRun(offset); return offset + run.length; }
public int following(int offset) { // work around too eager IAEs in standard implementation if (offset == getText().getEndIndex()) return DONE; int next= fIterator.following(offset); if (next == DONE) return DONE; // TODO deal with complex script word boundaries // Math.min(offset + run.length, next) does not work // since BreakIterator.getWordInstance considers _ as boundaries // seems to work fine, however Run run= consumeRun(offset); return offset + run.length; }
@Override public int following(int offset) { // work around too eager IAEs in standard implementation if (offset == getText().getEndIndex()) return DONE; int next= fIterator.following(offset); if (next == DONE) return DONE; // TODO deal with complex script word boundaries // Math.min(offset + run.length, next) does not work // since BreakIterator.getWordInstance considers _ as boundaries // seems to work fine, however Run run= consumeRun(offset); return offset + run.length; }
@Override public int following(int offset) { // work around too eager IAEs in standard implementation if (offset == getText().getEndIndex()) return DONE; int next= fIterator.following(offset); if (next == DONE) return DONE; // TODO deal with complex script word boundaries // Math.min(offset + run.length, next) does not work // since BreakIterator.getWordInstance considers _ as boundaries // seems to work fine, however Run run= consumeRun(offset); return offset + run.length; }
@Override public int following(int offset) { // work around too eager IAEs in standard implementation if (offset == getText().getEndIndex()) { return DONE; } int next = fIterator.following(offset); if (next == DONE) { return DONE; } // TODO deal with complex script word boundaries // Math.min(offset + run.length, next) does not work // since BreakIterator.getWordInstance considers _ as boundaries // seems to work fine, however Run run = consumeRun(offset); return offset + run.length; }