java.text
Class BreakIterator
java.lang.Object
|
+--java.text.BreakIterator
All Implemented Interfaces:
Cloneable
This class iterates over text elements such as words, lines, sentences,
and characters. It can only iterate over one of these text elements at
a time. An instance of this class configured for the desired iteration
type is created by calling one of the static factory methods, not
by directly calling a constructor.
Authors:- Tom Tromey <tromey@cygnus.com>
- Aaron M. Renn (arenn@urbanophile.com)
DONE
public static final int DONE
This value is returned by the next()
and
previous
in order to indicate that the end of the
text has been reached.
BreakIterator
protected BreakIterator()
This method initializes a new instance of BreakIterator
.
This protected constructor is available to subclasses as a default
no-arg superclass constructor.
current
public int current()
This method returns the index of the current text element boundary.
Returns:
- The current text boundary.
first
public int first()
This method returns the first text element boundary in the text being
iterated over.
Returns:
following
public int following(int pos)
This methdod returns the offset of the text element boundary following
the specified offset.
Parameters:
getAvailableLocales
public static synchronized Locale[] getAvailableLocales()
This method returns a list of locales for which instances of
BreakIterator
are available.
Returns:
- A list of available locales
getCharacterInstance
public static BreakIterator getCharacterInstance()
This method returns an instance of BreakIterator
that will
iterate over characters as defined in the default locale.
Returns:
- A
BreakIterator
instance for the default locale.
getCharacterInstance
public static BreakIterator getCharacterInstance(java.util.Locale loc)
This method returns an instance of BreakIterator
that will
iterate over characters as defined in the specified locale. If the
desired locale is not available, the default locale is used.
Parameters:
Returns:
- A
BreakIterator
instance for the default locale.
getLineInstance
public static BreakIterator getLineInstance()
This method returns an instance of BreakIterator
that will
iterate over line breaks as defined in the default locale.
Returns:
- A
BreakIterator
instance for the default locale.
getLineInstance
public static BreakIterator getLineInstance(java.util.Locale loc)
This method returns an instance of BreakIterator
that will
iterate over line breaks as defined in the specified locale. If the
desired locale is not available, the default locale is used.
Parameters:
Returns:
- A
BreakIterator
instance for the default locale.
getSentenceInstance
public static BreakIterator getSentenceInstance()
This method returns an instance of BreakIterator
that will
iterate over sentences as defined in the default locale.
Returns:
- A
BreakIterator
instance for the default locale.
getSentenceInstance
public static BreakIterator getSentenceInstance(java.util.Locale loc)
This method returns an instance of BreakIterator
that will
iterate over sentences as defined in the specified locale. If the
desired locale is not available, the default locale is used.
Parameters:
Returns:
- A
BreakIterator
instance for the default locale.
getText
public CharacterIterator getText()
This method returns the text this object is iterating over as a
CharacterIterator
.
getWordInstance
public static BreakIterator getWordInstance()
This method returns an instance of BreakIterator
that will
iterate over words as defined in the default locale.
Returns:
- A
BreakIterator
instance for the default locale.
getWordInstance
public static BreakIterator getWordInstance(java.util.Locale loc)
This method returns an instance of BreakIterator
that will
iterate over words as defined in the specified locale. If the
desired locale is not available, the default locale is used.
Parameters:
Returns:
- A
BreakIterator
instance for the default locale.
isBoundary
public boolean isBoundary(int pos)
This method tests whether or not the specified position is a text
element boundary.
Parameters:
Returns:
true
if the position is a boundary,
false
otherwise.
last
public int last()
This method returns the last text element boundary in the text being
iterated over.
Returns:
next
public int next()
This method returns the text element boundary following the current
text position.
Returns:
next
public int next(int n)
This method returns the n'th text element boundary following the current
text position.
Parameters:
Returns:
preceding
public int preceding(int pos)
This methdod returns the offset of the text element boundary preceding
the specified offset.
Parameters:
previous
public int previous()
This method returns the text element boundary preceding the current
text position.
Returns:
- The previous text boundary.
setText
public void setText(java.lang.String newText)
This method sets the text string to iterate over.
Parameters:
setText
public void setText(java.text.CharacterIterator newText)
This method sets the text to iterate over from the specified
CharacterIterator
.
Parameters: