Build 1.0_r1(from source)

java.text
Class BreakIterator

java.lang.Object
  extended by java.text.BreakIterator
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
RuleBasedBreakIterator

public abstract class BreakIterator
extends Object
implements Cloneable

This class is used to locate the boundaries of text. Instance of this class can be got by some factory methods:

BreakIterator uses CharacterIterator to perform the analysis, so that any storage which provides CharacterIterator interface.

See Also:
CharacterIterator

Field Summary
static int DONE
          This constant is returned by iterate methods like previous() or next() if they have returned all valid boundaries.
(package private)  com.ibm.icu4jni.text.BreakIterator wrapped
           
 
Constructor Summary
protected BreakIterator()
          Default constructor, just for invocation by subclass.
(package private) BreakIterator(com.ibm.icu4jni.text.BreakIterator iterator)
           
 
Method Summary
 Object clone()
          Create copy of this iterator, all status including current position is kept.
abstract  int current()
          Return this iterator's current position.
abstract  int first()
          Set this iterator's current position to the first boundary, and return this position.
abstract  int following(int offset)
          Set the position of the first boundary following the given offset, and return this position.
static Locale[] getAvailableLocales()
          Return all supported locales.
static BreakIterator getCharacterInstance()
          Return a new instance of BreakIterator used to iterate characters using default locale.
static BreakIterator getCharacterInstance(Locale where)
          Return a new instance of BreakIterator used to iterate characters using given locale.
protected static int getInt(byte[] buf, int offset)
          Get an int value from the given byte array, start from given offset.
static BreakIterator getLineInstance()
          Return a new instance of BreakIterator used to iterate line-breaks using default locale.
static BreakIterator getLineInstance(Locale where)
          Return a new instance of BreakIterator used to iterate line-breaks using given locale.
protected static long getLong(byte[] buf, int offset)
          Get a long value from the given byte array, start from given offset.
static BreakIterator getSentenceInstance()
          Return a new instance of BreakIterator used to iterate sentence-breaks using default locale.
static BreakIterator getSentenceInstance(Locale where)
          Return a new instance of BreakIterator used to iterate sentence-breaks using given locale.
protected static short getShort(byte[] buf, int offset)
          Get a short value from the given byte array, start from given offset.
abstract  CharacterIterator getText()
          Return a CharacterIterator which represents the text being analyzed.
static BreakIterator getWordInstance()
          Return a new instance of BreakIterator used to iterate word-breaks using default locale.
static BreakIterator getWordInstance(Locale where)
          Return a new instance of BreakIterator used to iterate word-breaks using given locale.
 boolean isBoundary(int offset)
          Return true if the given offset is a boundary position.
abstract  int last()
          Set this iterator's current position to the last boundary, and return this position.
abstract  int next()
          Set this iterator's current position to the next boundary after current position, and return this position.
abstract  int next(int n)
          Set this iterator's current position to the next boundary after the given position, and return this position.
 int preceding(int offset)
          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.
abstract  int previous()
          Set this iterator's current position to the previous boundary before current position, and return this position.
abstract  void setText(CharacterIterator newText)
          Set new text to be analyzed by given CharacterIterator.
 void setText(String newText)
          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.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DONE

public static final int DONE
This constant is returned by iterate methods like previous() or next() if they have returned all valid boundaries.

See Also:
Constant Field Values

wrapped

com.ibm.icu4jni.text.BreakIterator wrapped
Constructor Detail

BreakIterator

protected BreakIterator()
Default constructor, just for invocation by subclass.


BreakIterator

BreakIterator(com.ibm.icu4jni.text.BreakIterator iterator)
Method Detail

getAvailableLocales

public static Locale[] getAvailableLocales()
Return all supported locales.

Returns:
all supported locales

getCharacterInstance

public static BreakIterator getCharacterInstance()
Return a new instance of BreakIterator used to iterate characters using default locale.

Returns:
a new instance of BreakIterator used to iterate characters using default locale.

getCharacterInstance

public static BreakIterator getCharacterInstance(Locale where)
Return a new instance of BreakIterator used to iterate characters using given locale.

Parameters:
where - the given locale
Returns:
a new instance of BreakIterator used to iterate characters using given locale.

getLineInstance

public static BreakIterator getLineInstance()
Return a new instance of BreakIterator used to iterate line-breaks using default locale.

Returns:
a new instance of BreakIterator used to iterate line-breaks using default locale.

getLineInstance

public static BreakIterator getLineInstance(Locale where)
Return a new instance of BreakIterator used to iterate line-breaks using given locale.

Parameters:
where - the given locale
Returns:
a new instance of BreakIterator used to iterate line-breaks using given locale.

getSentenceInstance

public static BreakIterator getSentenceInstance()
Return a new instance of BreakIterator used to iterate sentence-breaks using default locale.

Returns:
a new instance of BreakIterator used to iterate sentence-breaks using default locale.

getSentenceInstance

public static BreakIterator getSentenceInstance(Locale where)
Return a new instance of BreakIterator used to iterate sentence-breaks using given locale.

Parameters:
where - the given locale
Returns:
a new instance of BreakIterator used to iterate sentence-breaks using given locale.

getWordInstance

public static BreakIterator getWordInstance()
Return a new instance of BreakIterator used to iterate word-breaks using default locale.

Returns:
a new instance of BreakIterator used to iterate word-breaks using default locale.

getWordInstance

public static BreakIterator getWordInstance(Locale where)
Return a new instance of BreakIterator used to iterate word-breaks using given locale.

Parameters:
where - the given locale
Returns:
a new instance of BreakIterator used to iterate word-breaks using given locale.

isBoundary

public boolean isBoundary(int offset)
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.

Parameters:
offset - the given offset to check
Returns:
true if the given offset is a boundary position

preceding

public int preceding(int offset)
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.

Parameters:
offset - the given start position to be searched for
Returns:
the position of last boundary precede the given offset

setText

public void setText(String newText)
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.

Parameters:
newText - the new text string to be analyzed

current

public abstract int current()
Return this iterator's current position.

Returns:
this iterator's current position

first

public abstract int first()
Set this iterator's current position to the first boundary, and return this position.

Returns:
the position of first boundary

following

public abstract int following(int offset)
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.

Parameters:
offset - the given position to be searched for
Returns:
the position of the first boundary following the given offset

getText

public abstract CharacterIterator getText()
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.

Returns:
a CharacterIterator which represents the text being analyzed.

last

public abstract int last()
Set this iterator's current position to the last boundary, and return this position.

Returns:
the position of last boundary

next

public abstract int next()
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.

Returns:
the position of last boundary

next

public abstract int next(int n)
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.

Parameters:
n - the given position.
Returns:
the position of last boundary

previous

public abstract int previous()
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.

Returns:
the position of last boundary

setText

public abstract void setText(CharacterIterator newText)
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.

Parameters:
newText - the given CharacterIterator refer to the text to be analyzed

clone

public Object clone()
Create copy of this iterator, all status including current position is kept.

Overrides:
clone in class Object
Returns:
copy of this iterator

getLong

protected static long getLong(byte[] buf,
                              int offset)
Get a long value from the given byte array, start from given offset.

Parameters:
buf - the bytes to be converted
offset - the start position of conversion
Returns:
the converted long value

getInt

protected static int getInt(byte[] buf,
                            int offset)
Get an int value from the given byte array, start from given offset.

Parameters:
buf - the bytes to be converted
offset - the start position of conversion
Returns:
the converted int value

getShort

protected static short getShort(byte[] buf,
                                int offset)
Get a short value from the given byte array, start from given offset.

Parameters:
buf - the bytes to be converted
offset - the start position of conversion
Returns:
the converted short value

Build 1.0_r1(from source)

Please submit a feedback, bug or feature