| Modifier and Type | Field and Description |
|---|---|
| private int[] | cachedBreakPositions
when a range of characters is divided up using the dictionary, the break positions that are discovered are stored here, preventing us from having to use either the dictionary or the state table again until the iterator leaves this range of text |
| private boolean[] | categoryFlags
a list of flags indicating which character categories are contained in the dictionary file (this is used to determine which ranges of characters to apply the dictionary to) |
| private BreakDictionary | dictionary
a list of known words that is used to divide up contiguous ranges of letters, stored in a compressed, indexed, format that offers fast access |
| private int | dictionaryCharCount
a temporary hiding place for the number of dictionary characters in the last range passed over by next() |
| private int | positionInCache
if cachedBreakPositions is not null, this indicates which item in the cache the current iteration position refers to |
| Access | Constructor and Description |
|---|---|
| public | DictionaryBasedBreakIterator(String
the name of the rule data file ruleFile, byte[] the rule data loaded from the rule data file ruleData, String the name of the dictionary file dictionaryFile, byte[] the dictionary data loaded from the dictionary file dictionaryData)Constructs a DictionaryBasedBreakIterator. |
| Modifier and Type | Method and Description |
|---|---|
| private void | divideUpDictionaryRange(int startPos, int endPos)
This is the function that actually implements the dictionary-based algorithm. |
| public int | Returns: The offset of the beginning of the text.Overrides sun. Sets the current iteration position to the beginning of the text. |
| public int | Returns: The position of the first boundary after "offset"The position to begin searching forward from offset)Overrides sun. Sets the current iteration position to the first boundary position after the specified position. |
| protected int | handleNext()
Overrides sun. This is the implementation function for next(). |
| public int | Returns: The text's past-the-end offset.Overrides sun. Sets the current iteration position to the end of the text. |
| protected int | lookupCategory(int c)
Overrides sun. Looks up a character category for a character. |
| public int | Returns: The position of the last boundary before "offset"The position to begin searching from offset)Overrides sun. Sets the current iteration position to the last boundary position before the specified position. |
| private void | |
| public int | Returns: The position of the last boundary position before the current iteration positionOverrides sun. Advances the iterator one step backwards. |
| public void | setText(CharacterIterator newText)
Overrides sun. Set the iterator to analyze a new piece of text. |
| cachedBreakPositions | back to summary |
|---|---|
| private int[] cachedBreakPositions when a range of characters is divided up using the dictionary, the break positions that are discovered are stored here, preventing us from having to use either the dictionary or the state table again until the iterator leaves this range of text | |
| categoryFlags | back to summary |
|---|---|
| private boolean[] categoryFlags a list of flags indicating which character categories are contained in the dictionary file (this is used to determine which ranges of characters to apply the dictionary to) | |
| dictionary | back to summary |
|---|---|
| private BreakDictionary dictionary a list of known words that is used to divide up contiguous ranges of letters, stored in a compressed, indexed, format that offers fast access | |
| dictionaryCharCount | back to summary |
|---|---|
| private int dictionaryCharCount a temporary hiding place for the number of dictionary characters in the last range passed over by next() | |
| positionInCache | back to summary |
|---|---|
| private int positionInCache if cachedBreakPositions is not null, this indicates which item in the cache the current iteration position refers to | |
| DictionaryBasedBreakIterator | back to summary |
|---|---|
| public DictionaryBasedBreakIterator(String ruleFile, byte[] ruleData, String dictionaryFile, byte[] dictionaryData) Constructs a DictionaryBasedBreakIterator.
| |
| divideUpDictionaryRange | back to summary |
|---|---|
| private void divideUpDictionaryRange(int startPos, int endPos) This is the function that actually implements the dictionary-based algorithm. Given the endpoints of a range of text, it uses the dictionary to determine the positions of any boundaries in this range. It stores all the boundary positions it discovers in cachedBreakPositions so that we only have to do this work once for each time we enter the range. | |
| first | back to summary |
|---|---|
| public int first() Overrides sun. Sets the current iteration position to the beginning of the text. (i.e., the CharacterIterator's starting offset).
| |
| following | back to summary |
|---|---|
| public int following(int offset) Overrides sun. Sets the current iteration position to the first boundary position after the specified position.
| |
| handleNext | back to summary |
|---|---|
| protected int handleNext() Overrides sun. This is the implementation function for next().
| |
| last | back to summary |
|---|---|
| public int last() Overrides sun. Sets the current iteration position to the end of the text. (i.e., the CharacterIterator's ending offset).
| |
| lookupCategory | back to summary |
|---|---|
| protected int lookupCategory(int c) Overrides sun. Looks up a character category for a character.
| |
| preceding | back to summary |
|---|---|
| public int preceding(int offset) Overrides sun. Sets the current iteration position to the last boundary position before the specified position.
| |
| prepareCategoryFlags | back to summary |
|---|---|
| private void prepareCategoryFlags(byte[] data) | |
| previous | back to summary |
|---|---|
| public int previous() Overrides sun. Advances the iterator one step backwards.
| |
| setText | back to summary |
|---|---|
| public void setText(CharacterIterator newText) Overrides sun. Doc from sun. Set the iterator to analyze a new piece of text. This function resets the current iteration position to the beginning of the text.
| |