| java.lang.Object | |
| ↳ | java.text.BreakIterator |
This class is used to locate the boundaries of text. Instance of this class can be got by some factory methods:
getCharacterInstance() returns a BreakIterator that iterate the
logical characters without worrying about how the character is stored. For
example, some character may be stored in more than one Unicode code point
according to Unicode specification, this character can handle the logical
characters with multi code points.getWordInstance() returns a BreakIterator that
iterate the word-breaks. The beginning and end of each word(including numbers)
is treated as boundary position. Whitespace and punctuation are kept separate
from real words.getSentenceInstance() returns a BreakIterator that iterate the
sentence-breaks.getLineInstance() returns a BreakIterator that iterate the
line-breaks which can be used to wrap lines. This iterator can handle whitespaces,
hyphens and punctuations.
BreakIterator uses CharacterIterator to perform the
analysis, so that any storage which provides CharacterIterator
interface.
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| int | DONE | This constant is returned by iterate methods like previous() or next() if they have returned all valid boundaries. | |||||||||
| Protected Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Default constructor, just for invocation by subclass.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Create copy of this iterator, all status including current position is
kept.
| |||||||||||
Return this iterator's current position.
| |||||||||||
Set this iterator's current position to the first boundary, and return
this position.
| |||||||||||
Set the position of the first boundary following the given offset, and
return this position.
| |||||||||||
Return all supported locales.
| |||||||||||
Return a new instance of BreakIterator used to iterate characters using
default locale.
| |||||||||||
Return a new instance of BreakIterator used to iterate characters using
given locale.
| |||||||||||
Return a new instance of BreakIterator used to iterate line-breaks using
default locale.
| |||||||||||
Return a new instance of BreakIterator used to iterate line-breaks using
given locale.
| |||||||||||
Return a new instance of BreakIterator used to iterate sentence-breaks
using given locale.
| |||||||||||
Return a new instance of BreakIterator used to iterate sentence-breaks
using default locale.
| |||||||||||
Return a
CharacterIterator which represents the text being
analyzed. | |||||||||||
Return a new instance of BreakIterator used to iterate word-breaks using
default locale.
| |||||||||||
Return a new instance of BreakIterator used to iterate word-breaks using
given locale.
| |||||||||||
Return true if the given offset is a boundary position.
| |||||||||||
Set this iterator's current position to the last boundary, and return
this position.
| |||||||||||
Set this iterator's current position to the next boundary after current
position, and return this position.
| |||||||||||
Set this iterator's current position to the next boundary after the given
position, and return this position.
| |||||||||||
Return the position of last boundary precede the given offset, and set
current position to returned value, or
DONE if the given
offset specifies the starting position. | |||||||||||
Set this iterator's current position to the previous boundary before
current position, and return this position.
| |||||||||||
Set the new text string to be analyzed, the current position will be
reset to beginning of this new string, and the old string will lost.
| |||||||||||
Set new text to be analyzed by given
CharacterIterator. | |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Get an int value from the given byte array, start from given offset.
| |||||||||||
Get a long value from the given byte array, start from given offset.
| |||||||||||
Get a short value from the given byte array, start from given offset.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
| |||||||||||
This constant is returned by iterate methods like previous() or next() if they have returned all valid boundaries.
Default constructor, just for invocation by subclass.
Create copy of this iterator, all status including current position is kept.
Return this iterator's current position.
Set this iterator's current position to the first boundary, and return this position.
Set the position of the first boundary following the given offset, and return this position. If there is no boundary after the given offset, return DONE.
IllegalArgumentException will be thrown if given offset is
invalid.
| offset | the given position to be searched for |
|---|
Return all supported locales.
Return a new instance of BreakIterator used to iterate characters using default locale.
Return a new instance of BreakIterator used to iterate characters using given locale.
| where | the given locale |
|---|
Return a new instance of BreakIterator used to iterate line-breaks using default locale.
Return a new instance of BreakIterator used to iterate line-breaks using given locale.
| where | the given locale |
|---|
Return a new instance of BreakIterator used to iterate sentence-breaks using given locale.
| where | the given locale |
|---|
Return a new instance of BreakIterator used to iterate sentence-breaks using default locale.
Return a CharacterIterator which represents the text being
analyzed. Please note that the returned value is probably the internal
iterator used by this object, so that if the invoker want to modify the
status of the returned iterator, a clone operation at first is
recommended.
CharacterIterator which represents the text
being analyzed.
Return a new instance of BreakIterator used to iterate word-breaks using default locale.
Return a new instance of BreakIterator used to iterate word-breaks using given locale.
| where | the given locale |
|---|
Return true if the given offset is a boundary position. If this method returns true, the current iteration position is set to the given position; if the function returns false, the current iteration position is set as though following() had been called.
| offset | the given offset to check |
|---|
Set this iterator's current position to the last boundary, and return this position.
Set this iterator's current position to the next boundary after current
position, and return this position. Return DONE if no
boundary found after current position.
Set this iterator's current position to the next boundary after the given
position, and return this position. Return DONE if no
boundary found after the given position.
| n | the given position. |
|---|
Return the position of last boundary precede the given offset, and set
current position to returned value, or DONE if the given
offset specifies the starting position.
IllegalArgumentException will be thrown if given offset is
invalid.
| offset | the given start position to be searched for |
|---|
Set this iterator's current position to the previous boundary before
current position, and return this position. Return DONE if
no boundary found before current position.
Set the new text string to be analyzed, the current position will be reset to beginning of this new string, and the old string will lost.
| newText | the new text string to be analyzed |
|---|
Set new text to be analyzed by given CharacterIterator.
The position will be reset to the beginning of the new text, and other
status of this iterator will be kept.
| newText | the given CharacterIterator refer to the text
to be analyzed
|
|---|
Get an int value from the given byte array, start from given offset.
| buf | the bytes to be converted |
|---|---|
| offset | the start position of conversion |
Get a long value from the given byte array, start from given offset.
| buf | the bytes to be converted |
|---|---|
| offset | the start position of conversion |
Get a short value from the given byte array, start from given offset.
| buf | the bytes to be converted |
|---|---|
| offset | the start position of conversion |