Home | History | Annotate | Download | only in method

Lines Matching refs:offset

71     public int preceding(int offset) {
72 checkOffsetIsValid(offset);
74 offset = mIterator.preceding(offset);
75 if (offset == BreakIterator.DONE || isOnLetterOrDigit(offset)) {
76 return offset;
82 public int following(int offset) {
83 checkOffsetIsValid(offset);
85 offset = mIterator.following(offset);
86 if (offset == BreakIterator.DONE || isAfterLetterOrDigit(offset)) {
87 return offset;
93 public boolean isBoundary(int offset) {
94 checkOffsetIsValid(offset);
95 return mIterator.isBoundary(offset);
99 * Returns the position of next boundary after the given offset. Returns
100 * {@code DONE} if there is no boundary after the given offset.
102 * @param offset the given start position to search from.
103 * @return the position of the last boundary preceding the given offset.
105 public int nextBoundary(int offset) {
106 checkOffsetIsValid(offset);
107 return mIterator.following(offset);
111 * Returns the position of boundary preceding the given offset or
112 * {@code DONE} if the given offset specifies the starting position.
114 * @param offset the given start position to search from.
115 * @return the position of the last boundary preceding the given offset.
117 public int prevBoundary(int offset) {
118 checkOffsetIsValid(offset);
119 return mIterator.preceding(offset);
122 /** If <code>offset</code> is within a word, returns the index of the first character of that
127 * If offset is the index of a low surrogate character, BreakIterator.DONE will be returned.
129 * Valid range for offset is [0..textLength] (note the inclusive upper bound).
130 * The returned value is within [0..offset] or BreakIterator.DONE.
132 * @throws IllegalArgumentException is offset is not valid.
134 public int getBeginning(int offset) {
135 // TODO: Check if usage of this can be updated to getBeginning(offset, true) if
137 return getBeginning(offset, false);
141 * If <code>offset</code> is within a word, returns the index of the last character of that
146 * If offset is the index of a low surrogate character, BreakIterator.DONE will be returned.
148 * Valid range for offset is [0..textLength] (note the inclusive upper bound).
149 * The returned value is within [offset..textLength] or BreakIterator.DONE.
151 * @throws IllegalArgumentException is offset is not valid.
153 public int getEnd(int offset) {
154 // TODO: Check if usage of this can be updated to getEnd(offset, true), if
156 return getEnd(offset, false);
160 * If the <code>offset</code> is within a word or on a word boundary that can only be
165 * If the offset is on a word boundary that can be considered the start and end of a
166 * word, e.g. AABB (where AA and BB are both words) and the offset is the boundary
171 * @throws IllegalArgumentException is offset is not valid.
173 public int getPrevWordBeginningOnTwoWordsBoundary(int offset) {
174 return getBeginning(offset, true);
178 * If the <code>offset</code> is within a word or on a word boundary that can only be
183 * If the offset is on a word boundary that can be considered the start and end of a
184 * word, e.g. AABB (where AA and BB are both words) and the offset is the boundary
189 * @throws IllegalArgumentException is offset is not valid.
191 public int getNextWordEndOnTwoWordBoundary(int offset) {
192 return getEnd(offset, true);
196 * If the <code>offset</code> is within a word or on a word boundary that can only be
201 * If the offset is on a word boundary that can be considered the start and end of a
202 * word, e.g. AABB (where AA and BB are both words) and the offset is the boundary
204 * return the start of the previous word, AA. Otherwise it would return the current offset,
209 * @throws IllegalArgumentException is offset is not valid.
211 private int getBeginning(int offset, boolean getPrevWordBeginningOnTwoWordsBoundary) {
212 checkOffsetIsValid(offset);
214 if (isOnLetterOrDigit(offset)) {
215 if (mIterator.isBoundary(offset)
216 && (!isAfterLetterOrDigit(offset)
218 return offset;
220 return mIterator.preceding(offset);
223 if (isAfterLetterOrDigit(offset)) {
224 return mIterator.preceding(offset);
231 * If the <code>offset</code> is within a word or on a word boundary that can only be
236 * If the offset is on a word boundary that can be considered the start and end of a
237 * word, e.g. AABB (where AA and BB are both words) and the offset is the boundary
239 * the end of the next word, BB. Otherwise it would return the current offset, the end
244 * @throws IllegalArgumentException is offset is not valid.
246 private int getEnd(int offset, boolean getNextWordEndOnTwoWordBoundary) {
247 checkOffsetIsValid(offset);
249 if (isAfterLetterOrDigit(offset)) {
250 if (mIterator.isBoundary(offset)
251 && (!isOnLetterOrDigit(offset) || !getNextWordEndOnTwoWordBoundary)) {
252 return offset;
254 return mIterator.following(offset);
257 if (isOnLetterOrDigit(offset)) {
258 return mIterator.following(offset);
265 * If <code>offset</code> is within a group of punctuation as defined
269 * @param offset the offset to search from.
271 public int getPunctuationBeginning(int offset) {
272 checkOffsetIsValid(offset);
273 while (offset != BreakIterator.DONE && !isPunctuationStartBoundary(offset)) {
274 offset = prevBoundary(offset);
276 // No need to shift offset, prevBoundary handles that.
277 return offset;
281 * If <code>offset</code> is within a group of punctuation as defined
285 * @param offset the offset to search from.
287 public int getPunctuationEnd(int offset) {
288 checkOffsetIsValid(offset);
289 while (offset != BreakIterator.DONE && !isPunctuationEndBoundary(offset)) {
290 offset = nextBoundary(offset);
292 // No need to shift offset, nextBoundary handles that.
293 return offset;
297 * Indicates if the provided offset is after a punctuation character
300 * @param offset the offset to check from.
301 * @return Whether the offset is after a punctuation character.
303 public boolean isAfterPunctuation(int offset) {
304 if (mStart < offset && offset <= mEnd) {
305 final int codePoint = Character.codePointBefore(mCharSeq, offset);
312 * Indicates if the provided offset is at a punctuation character
315 * @param offset the offset to check from.
316 * @return Whether the offset is at a punctuation character.
318 public boolean isOnPunctuation(int offset) {
319 if (mStart <= offset && offset < mEnd) {
320 final int codePoint = Character.codePointAt(mCharSeq, offset);
347 private boolean isPunctuationStartBoundary(int offset) {
348 return isOnPunctuation(offset) && !isAfterPunctuation(offset);
351 private boolean isPunctuationEndBoundary(int offset) {
352 return !isOnPunctuation(offset) && isAfterPunctuation(offset);
366 private boolean isAfterLetterOrDigit(int offset) {
367 if (mStart < offset && offset <= mEnd) {
368 final int codePoint = Character.codePointBefore(mCharSeq, offset);
374 private boolean isOnLetterOrDigit(int offset) {
375 if (mStart <= offset && offset < mEnd) {
376 final int codePoint = Character.codePointAt(mCharSeq, offset);
382 private void checkOffsetIsValid(int offset) {
383 if (!(mStart <= offset && offset <= mEnd)) {
384 throw new IllegalArgumentException("Invalid offset: " + (offset) +