V - The type of the value that is to be stored.public class StringPrefixMap<V extends Serializable> extends Object implements PrefixMap<V>, Serializable
| Modifier | Constructor and Description |
|---|---|
|
StringPrefixMap(boolean caseSensitive) |
protected |
StringPrefixMap(nl.basjes.collections.prefixmap.PrefixTrie<V> prefixTrie) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
The prefixmap will be empty after this call returns.
|
boolean |
containsPrefix(String prefix)
Returns true if this map contains an exact mapping
for the specified prefix.
|
V |
getLongestMatch(String input)
Return the value of the longest matching prefix.
|
V |
getShortestMatch(String input)
Return the value of the shortest matching prefix.
|
V |
put(String prefix,
V value)
Stored the specified value as the result for the specified prefix.
|
V |
remove(String prefix)
Removes the mapping for a prefix if present.
|
int |
size() |
protected StringPrefixMap(nl.basjes.collections.prefixmap.PrefixTrie<V> prefixTrie)
public StringPrefixMap(boolean caseSensitive)
public boolean containsPrefix(String prefix)
PrefixMapReturns true if this map contains an exact mapping for the specified prefix.
Note that implementations may be constructed to match either case sensitive or case insensitive.
containsPrefix in interface PrefixMap<V extends Serializable>prefix - prefix whose presence in this prefixmap is to be checkedpublic V put(String prefix, V value)
PrefixMapStored the specified value as the result for the specified prefix.
If for the specified prefix previously a value was present then the old value is replaced with the new value and the old value is returned.
Note that implementations may be constructed to store this value for either case sensitive or case insensitive matching during retrieval.
put in interface PrefixMap<V extends Serializable>prefix - prefix with which the specified value is to be associatedvalue - value to be associated with the specified prefixpublic int size()
size in interface PrefixMap<V extends Serializable>public void clear()
PrefixMapclear in interface PrefixMap<V extends Serializable>public V remove(String prefix)
PrefixMapRemoves the mapping for a prefix if present.
Note that implementations may be constructed to remove either case sensitive (only this exact value) or case insensitive (all case variations).
remove in interface PrefixMap<V extends Serializable>prefix - prefix whose mapping is to be removed from the prefixmappublic V getShortestMatch(String input)
PrefixMapReturn the value of the shortest matching prefix.
The value returned is the shortest stored prefix for which is true: input.startsWith(prefix).
Note that implementations may be constructed to match either case sensitive or case insensitive.
getShortestMatch in interface PrefixMap<V extends Serializable>input - The string for which we need value of the stored prefixpublic V getLongestMatch(String input)
PrefixMapReturn the value of the longest matching prefix.
The value returned is the longest stored prefix for which is true: input.startsWith(prefix).
Note that implementations may be constructed to match either case sensitive or case insensitive.
getLongestMatch in interface PrefixMap<V extends Serializable>input - The string for which we need value of the stored prefixCopyright © 2019. All rights reserved.