com.ibm.icu.text

Class RuleBasedBreakIterator

public class RuleBasedBreakIterator extends BreakIterator

Rule Based Break Iterator This is a port of the C++ class RuleBasedBreakIterator from ICU4C.

UNKNOWN: ICU 2.0

Field Summary
protected static StringfDebugEnv
Control debug, trace and dump options.
protected intfDictionaryCharCount
Counter for the number of characters encountered with the "dictionary" flag set.
protected RBBIDataWrapperfRData
The rule data for this BreakIterator instance
static booleanfTrace
Debugging flag.
static intWORD_IDEO
Tag value for words containing ideographic characters, lower limit
static intWORD_IDEO_LIMIT
Tag value for words containing ideographic characters, upper limit
static intWORD_KANA
Tag value for words containing kana characters, lower limit
static intWORD_KANA_LIMIT
Tag value for words containing kana characters, upper limit
static intWORD_LETTER
Tag value for words that contain letters, excluding hiragana, katakana or ideographic characters, lower limit.
static intWORD_LETTER_LIMIT
Tag value for words containing letters, upper limit
static intWORD_NONE
Tag value for "words" that do not fit into any of other categories.
static intWORD_NONE_LIMIT
Upper bound for tags for uncategorized words.
static intWORD_NUMBER
Tag value for words that appear to be numbers, lower limit.
static intWORD_NUMBER_LIMIT
Tag value for words that appear to be numbers, upper limit.
Constructor Summary
RuleBasedBreakIterator()
RuleBasedBreakIterator(String rules)
Construct a RuleBasedBreakIterator from a set of rules supplied as a string.
Method Summary
protected static voidcheckOffset(int offset, CharacterIterator text)
Throw IllegalArgumentException unless begin <= offset < end.
Objectclone()
Clones this iterator.
intcurrent()
Returns the current iteration position.
voiddump()
Dump the contents of the state table and character classes for this break iterator.
booleanequals(Object that)
Returns true if both BreakIterators are of the same class, have the same rules, and iterate over the same text.
intfirst()
Sets the current iteration position to the beginning of the text. (i.e., the CharacterIterator's starting offset).
intfollowing(int offset)
Sets the iterator to refer to the first boundary position following the specified position.
static RuleBasedBreakIteratorgetInstanceFromCompiledRules(InputStream is)
Create a break iterator from a precompiled set of rules.
intgetRuleStatus()
Return the status tag from the break rule that determined the most recently returned break position.
intgetRuleStatusVec(int[] fillInArray)
Get the status (tag) values from the break rule(s) that determined the most recently returned break position.
CharacterIteratorgetText()
Return a CharacterIterator over the text being analyzed.
inthashCode()
Compute a hashcode for this BreakIterator
booleanisBoundary(int offset)
Returns true if the specfied position is a boundary position.
intlast()
Sets the current iteration position to the end of the text. (i.e., the CharacterIterator's ending offset).
intnext(int n)
Advances the iterator either forward or backward the specified number of steps.
intnext()
Advances the iterator to the next boundary position.
intpreceding(int offset)
Sets the iterator to refer to the last boundary position before the specified position.
intprevious()
Moves the iterator backwards, to the last boundary preceding this one.
voidsetText(CharacterIterator newText)
Set the iterator to analyze a new piece of text.
StringtoString()
Returns the description (rules) used to create this iterator.

Field Detail

fDebugEnv

protected static String fDebugEnv

Deprecated: This API is ICU internal only.

Control debug, trace and dump options.

UNKNOWN:

fDictionaryCharCount

protected int fDictionaryCharCount

Deprecated: This API is ICU internal only.

Counter for the number of characters encountered with the "dictionary" flag set. Normal RBBI iterators don't use it, although the code for updating it is live. Dictionary Based break iterators (a subclass of us) access this field directly.

UNKNOWN:

fRData

protected RBBIDataWrapper fRData

Deprecated: This API is ICU internal only.

The rule data for this BreakIterator instance

UNKNOWN:

fTrace

public static boolean fTrace

Deprecated: This API is ICU internal only.

Debugging flag. Trace operation of state machine when true.

UNKNOWN:

WORD_IDEO

public static final int WORD_IDEO
Tag value for words containing ideographic characters, lower limit

UNKNOWN: ICU 3.0 This is a draft API and might change in a future release of ICU.

WORD_IDEO_LIMIT

public static final int WORD_IDEO_LIMIT
Tag value for words containing ideographic characters, upper limit

UNKNOWN: ICU 3.0 This is a draft API and might change in a future release of ICU.

WORD_KANA

public static final int WORD_KANA
Tag value for words containing kana characters, lower limit

UNKNOWN: ICU 3.0 This is a draft API and might change in a future release of ICU.

WORD_KANA_LIMIT

public static final int WORD_KANA_LIMIT
Tag value for words containing kana characters, upper limit

UNKNOWN: ICU 3.0 This is a draft API and might change in a future release of ICU.

WORD_LETTER

public static final int WORD_LETTER
Tag value for words that contain letters, excluding hiragana, katakana or ideographic characters, lower limit.

UNKNOWN: ICU 3.0 This is a draft API and might change in a future release of ICU.

WORD_LETTER_LIMIT

public static final int WORD_LETTER_LIMIT
Tag value for words containing letters, upper limit

UNKNOWN: ICU 3.0 This is a draft API and might change in a future release of ICU.

WORD_NONE

public static final int WORD_NONE
Tag value for "words" that do not fit into any of other categories. Includes spaces and most punctuation.

UNKNOWN: ICU 3.0 This is a draft API and might change in a future release of ICU.

WORD_NONE_LIMIT

public static final int WORD_NONE_LIMIT
Upper bound for tags for uncategorized words.

UNKNOWN: ICU 3.0 This is a draft API and might change in a future release of ICU.

WORD_NUMBER

public static final int WORD_NUMBER
Tag value for words that appear to be numbers, lower limit.

UNKNOWN: ICU 3.0 This is a draft API and might change in a future release of ICU.

WORD_NUMBER_LIMIT

public static final int WORD_NUMBER_LIMIT
Tag value for words that appear to be numbers, upper limit.

UNKNOWN: ICU 3.0 This is a draft API and might change in a future release of ICU.

Constructor Detail

RuleBasedBreakIterator

public RuleBasedBreakIterator()

Deprecated: This API is ICU internal only.

UNKNOWN:

RuleBasedBreakIterator

public RuleBasedBreakIterator(String rules)
Construct a RuleBasedBreakIterator from a set of rules supplied as a string.

Parameters: rules The break rules to be used. parseError In the event of a syntax error in the rules, provides the location within the rules of the problem. status Information on any errors encountered.

UNKNOWN: ICU 2.2

Method Detail

checkOffset

protected static final void checkOffset(int offset, CharacterIterator text)
Throw IllegalArgumentException unless begin <= offset < end.

UNKNOWN: ICU 2.0

clone

public Object clone()
Clones this iterator.

Returns: A newly-constructed RuleBasedBreakIterator with the same behavior as this one.

UNKNOWN: ICU 2.0

current

public int current()
Returns the current iteration position.

Returns: The current iteration position.

UNKNOWN: ICU 2.0

dump

public void dump()

Deprecated: This API is ICU internal only.

Dump the contents of the state table and character classes for this break iterator. For debugging only.

UNKNOWN:

equals

public boolean equals(Object that)
Returns true if both BreakIterators are of the same class, have the same rules, and iterate over the same text.

UNKNOWN: ICU 2.0

first

public int first()
Sets the current iteration position to the beginning of the text. (i.e., the CharacterIterator's starting offset).

Returns: The offset of the beginning of the text.

UNKNOWN: ICU 2.0

following

public int following(int offset)
Sets the iterator to refer to the first boundary position following the specified position.

Parameters: offset The position from which to begin searching for a break position.

Returns: The position of the first break after the current position.

UNKNOWN: ICU 2.0

getInstanceFromCompiledRules

public static RuleBasedBreakIterator getInstanceFromCompiledRules(InputStream is)

Deprecated: This API is ICU internal only.

Create a break iterator from a precompiled set of rules.

UNKNOWN:

getRuleStatus

public int getRuleStatus()
Return the status tag from the break rule that determined the most recently returned break position. The values appear in the rule source within brackets, {123}, for example. For rules that do not specify a status, a default value of 0 is returned. If more than one rule applies, the numerically largest of the possible status values is returned.

Of the standard types of ICU break iterators, only the word break iterator provides status values. The values are defined in class RuleBasedBreakIterator, and allow distinguishing between words that contain alphabetic letters, "words" that appear to be numbers, punctuation and spaces, words containing ideographic characters, and more. Call getRuleStatus after obtaining a boundary position from next(), previous(), or any other break iterator functions that returns a boundary position.

Returns: the status from the break rule that determined the most recently returned break position.

UNKNOWN: ICU 3.0 This is a draft API and might change in a future release of ICU.

getRuleStatusVec

public int getRuleStatusVec(int[] fillInArray)
Get the status (tag) values from the break rule(s) that determined the most recently returned break position. The values appear in the rule source within brackets, {123}, for example. The default status value for rules that do not explicitly provide one is zero.

The status values used by the standard ICU break rules are defined as public constants in class RuleBasedBreakIterator.

If the size of the output array is insufficient to hold the data, the output will be truncated to the available length. No exception will be thrown.

Parameters: fillInArray an array to be filled in with the status values.

Returns: The number of rule status values from rules that determined the most recent boundary returned by the break iterator. In the event that the array is too small, the return value is the total number of status values that were available, not the reduced number that were actually returned.

UNKNOWN: ICU 3.0 This is a draft API and might change in a future release of ICU.

getText

public CharacterIterator getText()
Return a CharacterIterator over the text being analyzed. This version of this method returns the actual CharacterIterator we're using internally. Changing the state of this iterator can have undefined consequences. If you need to change it, clone it first.

Returns: An iterator over the text being analyzed.

UNKNOWN: ICU 2.0

hashCode

public int hashCode()
Compute a hashcode for this BreakIterator

Returns: A hash code

UNKNOWN: ICU 2.0

isBoundary

public boolean isBoundary(int offset)
Returns true if the specfied position is a boundary position. As a side effect, leaves the iterator pointing to the first boundary position at or after "offset".

Parameters: offset the offset to check.

Returns: True if "offset" is a boundary position.

UNKNOWN: ICU 2.0

last

public int last()
Sets the current iteration position to the end of the text. (i.e., the CharacterIterator's ending offset).

Returns: The text's past-the-end offset.

UNKNOWN: ICU 2.0

next

public int next(int n)
Advances the iterator either forward or backward the specified number of steps. Negative values move backward, and positive values move forward. This is equivalent to repeatedly calling next() or previous().

Parameters: n The number of steps to move. The sign indicates the direction (negative is backwards, and positive is forwards).

Returns: The character offset of the boundary position n boundaries away from the current one.

UNKNOWN: ICU 2.0

next

public int next()
Advances the iterator to the next boundary position.

Returns: The position of the first boundary after this one.

UNKNOWN: ICU 2.0

preceding

public int preceding(int offset)
Sets the iterator to refer to the last boundary position before the specified position.

Parameters: offset The position to begin searching for a break from.

Returns: The position of the last boundary before the starting position.

UNKNOWN: ICU 2.0

previous

public int previous()
Moves the iterator backwards, to the last boundary preceding this one.

Returns: The position of the last boundary position preceding this one.

UNKNOWN: ICU 2.0

setText

public void setText(CharacterIterator newText)
Set the iterator to analyze a new piece of text. This function resets the current iteration position to the beginning of the text.

Parameters: newText An iterator over the text to analyze.

UNKNOWN: ICU 2.0

toString

public String toString()
Returns the description (rules) used to create this iterator. (In ICU4C, the same function is RuleBasedBreakIterator::getRules())

UNKNOWN: ICU 2.0

Copyright (c) 2007 IBM Corporation and others.