< prev index next >

src/java.base/share/classes/java/text/BreakIterator.java

Print this page
rev 58428 : [mq]: XXXXXXX-typos


 301      * {@code BreakIterator.DONE} if the current boundary is the last text
 302      * boundary.
 303      * Equivalent to next(1).
 304      * @see #next(int)
 305      */
 306     public abstract int next();
 307 
 308     /**
 309      * Returns the boundary preceding the current boundary. If the current boundary
 310      * is the first text boundary, it returns {@code BreakIterator.DONE} and
 311      * the iterator's current position is unchanged. Otherwise, the iterator's
 312      * current position is set to the boundary preceding the current boundary.
 313      * @return The character index of the previous text boundary or
 314      * {@code BreakIterator.DONE} if the current boundary is the first text
 315      * boundary.
 316      */
 317     public abstract int previous();
 318 
 319     /**
 320      * Returns the first boundary following the specified character offset. If the
 321      * specified offset equals to the last text boundary, it returns
 322      * {@code BreakIterator.DONE} and the iterator's current position is unchanged.
 323      * Otherwise, the iterator's current position is set to the returned boundary.
 324      * The value returned is always greater than the offset or the value
 325      * {@code BreakIterator.DONE}.
 326      * @param offset the character offset to begin scanning.
 327      * @return The first boundary after the specified offset or
 328      * {@code BreakIterator.DONE} if the last text boundary is passed in
 329      * as the offset.
 330      * @throws     IllegalArgumentException if the specified offset is less than
 331      * the first text boundary or greater than the last text boundary.
 332      */
 333     public abstract int following(int offset);
 334 
 335     /**
 336      * Returns the last boundary preceding the specified character offset. If the
 337      * specified offset equals to the first text boundary, it returns
 338      * {@code BreakIterator.DONE} and the iterator's current position is unchanged.
 339      * Otherwise, the iterator's current position is set to the returned boundary.
 340      * The value returned is always less than the offset or the value
 341      * {@code BreakIterator.DONE}.
 342      * @param offset the character offset to begin scanning.
 343      * @return The last boundary before the specified offset or
 344      * {@code BreakIterator.DONE} if the first text boundary is passed in
 345      * as the offset.
 346      * @throws      IllegalArgumentException if the specified offset is less than
 347      * the first text boundary or greater than the last text boundary.
 348      * @since 1.2
 349      */
 350     public int preceding(int offset) {
 351         // NOTE:  This implementation is here solely because we can't add new
 352         // abstract methods to an existing class.  There is almost ALWAYS a
 353         // better, faster way to do this.
 354         int pos = following(offset);
 355         while (pos >= offset && pos != DONE) {
 356             pos = previous();
 357         }




 301      * {@code BreakIterator.DONE} if the current boundary is the last text
 302      * boundary.
 303      * Equivalent to next(1).
 304      * @see #next(int)
 305      */
 306     public abstract int next();
 307 
 308     /**
 309      * Returns the boundary preceding the current boundary. If the current boundary
 310      * is the first text boundary, it returns {@code BreakIterator.DONE} and
 311      * the iterator's current position is unchanged. Otherwise, the iterator's
 312      * current position is set to the boundary preceding the current boundary.
 313      * @return The character index of the previous text boundary or
 314      * {@code BreakIterator.DONE} if the current boundary is the first text
 315      * boundary.
 316      */
 317     public abstract int previous();
 318 
 319     /**
 320      * Returns the first boundary following the specified character offset. If the
 321      * specified offset is equal to the last text boundary, it returns
 322      * {@code BreakIterator.DONE} and the iterator's current position is unchanged.
 323      * Otherwise, the iterator's current position is set to the returned boundary.
 324      * The value returned is always greater than the offset or the value
 325      * {@code BreakIterator.DONE}.
 326      * @param offset the character offset to begin scanning.
 327      * @return The first boundary after the specified offset or
 328      * {@code BreakIterator.DONE} if the last text boundary is passed in
 329      * as the offset.
 330      * @throws     IllegalArgumentException if the specified offset is less than
 331      * the first text boundary or greater than the last text boundary.
 332      */
 333     public abstract int following(int offset);
 334 
 335     /**
 336      * Returns the last boundary preceding the specified character offset. If the
 337      * specified offset is equal to the first text boundary, it returns
 338      * {@code BreakIterator.DONE} and the iterator's current position is unchanged.
 339      * Otherwise, the iterator's current position is set to the returned boundary.
 340      * The value returned is always less than the offset or the value
 341      * {@code BreakIterator.DONE}.
 342      * @param offset the character offset to begin scanning.
 343      * @return The last boundary before the specified offset or
 344      * {@code BreakIterator.DONE} if the first text boundary is passed in
 345      * as the offset.
 346      * @throws      IllegalArgumentException if the specified offset is less than
 347      * the first text boundary or greater than the last text boundary.
 348      * @since 1.2
 349      */
 350     public int preceding(int offset) {
 351         // NOTE:  This implementation is here solely because we can't add new
 352         // abstract methods to an existing class.  There is almost ALWAYS a
 353         // better, faster way to do this.
 354         int pos = following(offset);
 355         while (pos >= offset && pos != DONE) {
 356             pos = previous();
 357         }


< prev index next >