GeezerVison is showing docs.oracle.com — BreakIterator (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
compact1, compact2, compact3
java.text
Class BreakIterator
-
-
Field Summary
Fields
| Modifier and Type |
Field |
Description |
static int |
DONE |
DONE is returned by previous(), next(), next(int), preceding(int)
and following(int) when either the first or last text boundary has been
reached.
|
-
Constructor Summary
Constructors
| Modifier |
Constructor |
Description |
protected |
BreakIterator() |
Constructor.
|
-
-
Field Detail
-
DONE
public static final int DONE
DONE is returned by previous(), next(), next(int), preceding(int)
and following(int) when either the first or last text boundary has been
reached.
- See Also:
- Constant Field Values
-
Method Detail
-
next
public abstract int next(int n)
Returns the nth boundary from the current boundary. If either
the first or last text boundary has been reached, it returns
BreakIterator.DONE and the current position is set to either
the first or last text boundary depending on which one is reached. Otherwise,
the iterator's current position is set to the new boundary.
For example, if the iterator's current position is the mth text boundary
and three more boundaries exist from the current boundary to the last text
boundary, the next(2) call will return m + 2. The new text position is set
to the (m + 2)th text boundary. A next(4) call would return
BreakIterator.DONE and the last text boundary would become the
new text position.
- Parameters:
n - which boundary to return. A value of 0
does nothing. Negative values move to previous boundaries
and positive values move to later boundaries.
- Returns:
- The character index of the nth boundary from the current position
or
BreakIterator.DONE if either first or last text boundary
has been reached.
-
next
public abstract int next()
Returns the boundary following the current boundary. If the current boundary
is the last text boundary, it returns BreakIterator.DONE and
the iterator's current position is unchanged. Otherwise, the iterator's
current position is set to the boundary following the current boundary.
- Returns:
- The character index of the next text boundary or
BreakIterator.DONE if the current boundary is the last text
boundary.
Equivalent to next(1).
- See Also:
next(int)
-
previous
public abstract int previous()
Returns the boundary preceding the current boundary. If the current boundary
is the first text boundary, it returns BreakIterator.DONE and
the iterator's current position is unchanged. Otherwise, the iterator's
current position is set to the boundary preceding the current boundary.
- Returns:
- The character index of the previous text boundary or
BreakIterator.DONE if the current boundary is the first text
boundary.
-
following
public abstract int following(int offset)
Returns the first boundary following the specified character offset. If the
specified offset equals to the last text boundary, it returns
BreakIterator.DONE and the iterator's current position is unchanged.
Otherwise, the iterator's current position is set to the returned boundary.
The value returned is always greater than the offset or the value
BreakIterator.DONE.
- Parameters:
offset - the character offset to begin scanning.
- Returns:
- The first boundary after the specified offset or
BreakIterator.DONE if the last text boundary is passed in
as the offset.
- Throws:
IllegalArgumentException - if the specified offset is less than
the first text boundary or greater than the last text boundary.
-
preceding
public int preceding(int offset)
Returns the last boundary preceding the specified character offset. If the
specified offset equals to the first text boundary, it returns
BreakIterator.DONE and the iterator's current position is unchanged.
Otherwise, the iterator's current position is set to the returned boundary.
The value returned is always less than the offset or the value
BreakIterator.DONE.
- Parameters:
offset - the character offset to begin scanning.
- Returns:
- The last boundary before the specified offset or
BreakIterator.DONE if the first text boundary is passed in
as the offset.
- Throws:
IllegalArgumentException - if the specified offset is less than
the first text boundary or greater than the last text boundary.
- Since:
- 1.2
-
current
public abstract int current()
Returns character index of the text boundary that was most
recently returned by next(), next(int), previous(), first(), last(),
following(int) or preceding(int). If any of these methods returns
BreakIterator.DONE because either first or last text boundary
has been reached, it returns the first or last text boundary depending on
which one is reached.
- Returns:
- The text boundary returned from the above methods, first or last
text boundary.
- See Also:
next(),
next(int),
previous(),
first(),
last(),
following(int),
preceding(int)
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|