Top Description Inners Fields Constructors Methods
com.ibm.icu.impl

public Class TextTrieMap<V>

extends Object
Class Inheritance
Imports
java.util.Iterator, .LinkedList, .List, .ListIterator, com.ibm.icu.lang.UCharacter, com.ibm.icu.text.UnicodeSet

TextTrieMap is a trie implementation for supporting fast prefix match for the key.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
private static class
private class
TextTrieMap.Node

Inner class representing a text node in the trie.

public static class
public static interface
TextTrieMap.ResultHandler<V>

Callback handler for processing prefix matches used by find method.

Field Summary

Modifier and TypeField and Description
pack-priv boolean
private TextTrieMap<V>.Node

Constructor Summary

AccessConstructor and Description
public
TextTrieMap(boolean
true to use simple case insensitive match
ignoreCase
)

Constructs a TextTrieMap object.

Method Summary

Modifier and TypeMethod and Description
public void
public void
find(CharSequence text, int offset, TextTrieMap.ResultHandler<V> handler)

private void
find(CharSequence text, int offset, TextTrieMap.ResultHandler<V> handler, TextTrieMap.Output output)

private synchronized void
public Iterator<V>

Returns:

An iterator of the objects associated with the longest prefix matching matching key, or null if no matching entry is found.
get
(String
The text to be matched with prefixes.
text
)

Gets an iterator of the objects associated with the longest prefix matching string key.

public Iterator<V>

Returns:

An iterator of the objects associated with the longest prefix matching matching key, or null if no matching entry is found.
get
(CharSequence
The text to be matched with prefixes.
text
,
int
The start index of of the text
start
)

Gets an iterator of the objects associated with the longest prefix matching string key starting at the specified position.

public Iterator<V>
get(CharSequence text, int start, TextTrieMap.Output output)

public TextTrieMap<V>
put(CharSequence
The text.
text
,
V
The value object associated with the text.
val
)

Adds the text key and its associated object in this object.

public void
private static char[]
subArray(char[] array, int start)

private static char[]
subArray(char[] array, int start, int limit)

private static char[]
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_ignoreCaseback to summary
pack-priv boolean _ignoreCase
_rootback to summary
private TextTrieMap<V>.Node _root

Constructor Detail

TextTrieMapback to summary
public TextTrieMap(boolean ignoreCase)

Constructs a TextTrieMap object.

Parameters
ignoreCase:boolean

true to use simple case insensitive match

Method Detail

findback to summary
public void find(CharSequence text, TextTrieMap.ResultHandler<V> handler)
findback to summary
public void find(CharSequence text, int offset, TextTrieMap.ResultHandler<V> handler)
findback to summary
private void find(CharSequence text, int offset, TextTrieMap.ResultHandler<V> handler, TextTrieMap.Output output)
findback to summary
private synchronized void find(TextTrieMap<V>.Node node, TextTrieMap.CharIterator chitr, TextTrieMap.ResultHandler<V> handler, TextTrieMap.Output output)
getback to summary
public Iterator<V> get(String text)

Gets an iterator of the objects associated with the longest prefix matching string key.

Parameters
text:String

The text to be matched with prefixes.

Returns:Iterator<V>

An iterator of the objects associated with the longest prefix matching matching key, or null if no matching entry is found.

getback to summary
public Iterator<V> get(CharSequence text, int start)

Gets an iterator of the objects associated with the longest prefix matching string key starting at the specified position.

Parameters
text:CharSequence

The text to be matched with prefixes.

start:int

The start index of of the text

Returns:Iterator<V>

An iterator of the objects associated with the longest prefix matching matching key, or null if no matching entry is found.

getback to summary
public Iterator<V> get(CharSequence text, int start, TextTrieMap.Output output)
putback to summary
public TextTrieMap<V> put(CharSequence text, V val)

Adds the text key and its associated object in this object.

Parameters
text:CharSequence

The text.

val:V

The value object associated with the text.

putLeadCodePointsback to summary
public void putLeadCodePoints(UnicodeSet output)
subArrayback to summary
private static char[] subArray(char[] array, int start)
subArrayback to summary
private static char[] subArray(char[] array, int start, int limit)
toCharArrayback to summary
private static char[] toCharArray(CharSequence text)
com.ibm.icu.impl back to summary

public Class TextTrieMap.CharIterator

extends Object
implements Iterator<Character>
Class Inheritance
All Implemented Interfaces
java.util.Iterator

Field Summary

Modifier and TypeField and Description
private boolean
private int
private Character
private int
private CharSequence

Constructor Summary

AccessConstructor and Description
pack-priv
CharIterator(CharSequence text, int offset, boolean ignoreCase)

Method Summary

Modifier and TypeMethod and Description
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public Character
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
public int
public int
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_ignoreCaseback to summary
private boolean _ignoreCase
_nextIdxback to summary
private int _nextIdx
_remainingCharback to summary
private Character _remainingChar
_startIdxback to summary
private int _startIdx
_textback to summary
private CharSequence _text

Constructor Detail

CharIteratorback to summary
pack-priv CharIterator(CharSequence text, int offset, boolean ignoreCase)

Method Detail

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public Character next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:Character

the next element in the iteration

Annotations
@Override
nextIndexback to summary
public int nextIndex()
processedLengthback to summary
public int processedLength()
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override
com.ibm.icu.impl back to summary

private Class TextTrieMap.LongestMatchHandler<V>

extends Object
implements TextTrieMap.ResultHandler<V>
Class Inheritance
All Implemented Interfaces
com.ibm.icu.impl.TextTrieMap.ResultHandler

Field Summary

Modifier and TypeField and Description
private int
private Iterator<V>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Iterator<V>
public int
public boolean
handlePrefixMatch(int
Matched key's length
matchLength
,
Iterator<V>
An iterator of the objects associated with the matched key
values
)

Implements com.ibm.icu.impl.TextTrieMap.ResultHandler.handlePrefixMatch.

Handles a prefix key match
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

lengthback to summary
private int length
matchesback to summary
private Iterator<V> matches

Constructor Detail

LongestMatchHandlerback to summary
private LongestMatchHandler()

Method Detail

getMatchesback to summary
public Iterator<V> getMatches()
getMatchLengthback to summary
public int getMatchLength()
handlePrefixMatchback to summary
public boolean handlePrefixMatch(int matchLength, Iterator<V> values)

Implements com.ibm.icu.impl.TextTrieMap.ResultHandler.handlePrefixMatch.

Doc from com.ibm.icu.impl.TextTrieMap.ResultHandler.handlePrefixMatch.

Handles a prefix key match

Parameters
matchLength:int

Matched key's length

values:Iterator<V>

An iterator of the objects associated with the matched key

Returns:boolean

Return true to continue the search in the trie, false to quit.

Annotations
@Override
com.ibm.icu.impl back to summary

private Class TextTrieMap.Node

extends Object
Class Inheritance

Inner class representing a text node in the trie.

Field Summary

Modifier and TypeField and Description
private List<TextTrieMap<V>.Node>
private char[]
private List<V>

Constructor Summary

AccessConstructor and Description
private
Node()

private
Node(char[] text, List<V> values, List<TextTrieMap<V>.Node> children)

Method Summary

Modifier and TypeMethod and Description
public void
add(TextTrieMap.CharIterator chitr, V value)

private void
add(char[] text, int offset, V value)

private List<V>
addValue(List<V> list, V value)

public int
public TextTrieMap<V>.Node
private int
lenMatches(char[] text, int offset)

private boolean
public void
private void
split(int offset)

public Iterator<V>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_childrenback to summary
private List<TextTrieMap<V>.Node> _children
_textback to summary
private char[] _text
_valuesback to summary
private List<V> _values

Constructor Detail

Nodeback to summary
private Node()
Nodeback to summary
private Node(char[] text, List<V> values, List<TextTrieMap<V>.Node> children)

Method Detail

addback to summary
public void add(TextTrieMap.CharIterator chitr, V value)
addback to summary
private void add(char[] text, int offset, V value)
addValueback to summary
private List<V> addValue(List<V> list, V value)
charCountback to summary
public int charCount()
findMatchback to summary
public TextTrieMap<V>.Node findMatch(TextTrieMap.CharIterator chitr, TextTrieMap.Output output)
lenMatchesback to summary
private int lenMatches(char[] text, int offset)
matchFollowingback to summary
private boolean matchFollowing(TextTrieMap.CharIterator chitr, TextTrieMap.Output output)
putLeadCodePointsback to summary
public void putLeadCodePoints(UnicodeSet output)
splitback to summary
private void split(int offset)
valuesback to summary
public Iterator<V> values()
com.ibm.icu.impl back to summary

public Class TextTrieMap.Output

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
public int
public boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

matchLengthback to summary
public int matchLength
partialMatchback to summary
public boolean partialMatch

Constructor Detail

Outputback to summary
public Output()
com.ibm.icu.impl back to summary

public Interface TextTrieMap.ResultHandler<V>

Known Direct Implementers
com.ibm.icu.impl.TextTrieMap.LongestMatchHandler, com.ibm.icu.util.Currency.CurrencyNameResultHandler, com.ibm.icu.impl.TimeZoneGenericNames.GenericNameSearchHandler, com.ibm.icu.impl.TimeZoneNamesImpl.NameSearchHandler, com.ibm.icu.impl.TZDBTimeZoneNames.TZDBNameSearchHandler

Callback handler for processing prefix matches used by find method.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

Return true to continue the search in the trie, false to quit.
handlePrefixMatch
(int
Matched key's length
matchLength
,
Iterator<V>
An iterator of the objects associated with the matched key
values
)

Handles a prefix key match

Method Detail

handlePrefixMatchback to summary
public boolean handlePrefixMatch(int matchLength, Iterator<V> values)

Handles a prefix key match

Parameters
matchLength:int

Matched key's length

values:Iterator<V>

An iterator of the objects associated with the matched key

Returns:boolean

Return true to continue the search in the trie, false to quit.