Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.text

Class BreakIterator

java.lang.Object
|
+--java.text.BreakIterator

All Implemented Interfaces:

Cloneable


public abstract class BreakIterator

extends Object

implements 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:

Field Summary

static intDONE

This value is returned by the next() and previous in order to indicate that the end of the text has been reached.

Constructor Summary

BreakIterator()

This method initializes a new instance of BreakIterator.

Method Summary

intcurrent()

This method returns the index of the current text element boundary.
intfirst()

This method returns the first text element boundary in the text being iterated over.
intfollowing(int pos)

This methdod returns the offset of the text element boundary following the specified offset.
static synchronized java.util.Locale[]getAvailableLocales()

This method returns a list of locales for which instances of BreakIterator are available.
static java.text.BreakIteratorgetCharacterInstance()

This method returns an instance of BreakIterator that will iterate over characters as defined in the default locale.
static java.text.BreakIteratorgetCharacterInstance(java.util.Locale loc)

This method returns an instance of BreakIterator that will iterate over characters as defined in the specified locale.
static java.text.BreakIteratorgetLineInstance()

This method returns an instance of BreakIterator that will iterate over line breaks as defined in the default locale.
static java.text.BreakIteratorgetLineInstance(java.util.Locale loc)

This method returns an instance of BreakIterator that will iterate over line breaks as defined in the specified locale.
static java.text.BreakIteratorgetSentenceInstance()

This method returns an instance of BreakIterator that will iterate over sentences as defined in the default locale.
static java.text.BreakIteratorgetSentenceInstance(java.util.Locale loc)

This method returns an instance of BreakIterator that will iterate over sentences as defined in the specified locale.
java.text.CharacterIteratorgetText()

This method returns the text this object is iterating over as a CharacterIterator.
static java.text.BreakIteratorgetWordInstance()

This method returns an instance of BreakIterator that will iterate over words as defined in the default locale.
static java.text.BreakIteratorgetWordInstance(java.util.Locale loc)

This method returns an instance of BreakIterator that will iterate over words as defined in the specified locale.
booleanisBoundary(int pos)

This method tests whether or not the specified position is a text element boundary.
intlast()

This method returns the last text element boundary in the text being iterated over.
intnext()

This method returns the text element boundary following the current text position.
intnext(int n)

This method returns the n'th text element boundary following the current text position.
intpreceding(int pos)

This methdod returns the offset of the text element boundary preceding the specified offset.
intprevious()

This method returns the text element boundary preceding the current text position.
voidsetText(java.lang.String newText)

This method sets the text string to iterate over.
voidsetText(java.text.CharacterIterator newText)

This method sets the text to iterate over from the specified CharacterIterator.

Field Details

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.


Constructor Details

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.


Method Details

current

public int current()

This method returns the index of the current text element boundary.

Returns:


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:


getCharacterInstance

public static BreakIterator getCharacterInstance()

This method returns an instance of BreakIterator that will iterate over characters as defined in the default locale.

Returns:


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:


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:


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:


getSentenceInstance

public static BreakIterator getSentenceInstance()

This method returns an instance of BreakIterator that will iterate over sentences as defined in the default locale.

Returns:


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:


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:


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:


isBoundary

public boolean isBoundary(int pos)

This method tests whether or not the specified position is a text element boundary.

Parameters:

Returns:


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:


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: