Class UnicodeMap<T>
java.lang.Object
org.graalvm.shadowed.com.ibm.icu.impl.UnicodeMap<T>
- All Implemented Interfaces:
Cloneable,Iterable<String>,StringTransform,Transform<String,,String> Freezable<UnicodeMap<T>>
public final class UnicodeMap<T>
extends Object
implements Cloneable, Freezable<UnicodeMap<T>>, StringTransform, Iterable<String>
Class for mapping Unicode characters and strings to values, optimized for single code points,
where ranges of code points have the same value.
Much smaller storage than using HashMap, and much faster and more compact than
a list of UnicodeSets. The API design mimics Mapinvalid input: '<'String,T> but can't extend it due to some
necessary changes (much as UnicodeSet mimics Set). Note that nulls are not permitted as values;
that is, a put(x,null) is the same as remove(x).
At this point "" is also not allowed as a key, although that may change.
At this point "" is also not allowed as a key, although that may change.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classUsed to add complex values, where the value isn't replaced but in some sense composedstatic classStruct-like class used to iterate over a UnicodeMap in a for loop. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<U extends Map<T, UnicodeSet>>
UaddInverseTo(U target) Gets the inverse of this map, adding to the target.static booleanclear()Standard clone.composeWith(UnicodeMap<T> other, UnicodeMap.Composer<T> composer) composeWith(UnicodeSet set, T value, UnicodeMap.Composer<T> composer) booleancontainsKey(int key) booleancontainsKey(String key) booleancontainsValue(T value) Returns an Iterable over EntryRange, designed for efficient for loops over UnicodeMaps.entrySet()booleanstatic intfindCommonPrefix(String last, String s) Utility to find the maximal common prefix of two strings.freeze()Freezes the object.static <T> Map<T, UnicodeSet> freeze(Map<T, UnicodeSet> target) Freeze an inverse map.get(int codepoint) Gets the value associated with a given code point.Gets the value associated with a given code point.Old form for compatibility<U extends Collection<T>>
UgetAvailableValues(U result) Old form for compatibilitybooleanGet the strings that are not in the ranges.intGet the number of ranges; used for getRangeStart/End.intgetRangeEnd(int range) Get the start of a range.intgetRangeStart(int range) Get the start of a range.getRangeValue(int range) Get the value for the range.Old form for compatibilitygetSet(T value, UnicodeSet result) Old form for compatibilitygetValue(int key) Old form for compatibilityOld form for compatibilityinthashCode()booleanisEmpty()booleanisFrozen()Determines whether the object has been frozen or not.iterator()keySet()Returns the keyset consisting of all the keys that would produce (non-null) values.Returns the keyset consisting of all the keys that would produce the given value.keySet(T value, UnicodeSet result) Returns the keyset consisting of all the keys that would produce the given value.Sets the codepoint value.Sets the codepoint value.Adds bunch o' codepoints; otherwise like add.putAll(UnicodeMap<T> unicodeMap) Add all the (main) values from a UnicodeMapputAll(UnicodeSet codepoints, T value) Adds bunch o' codepoints; otherwise like put.putAllCodepointsInto(U map) Utility for extracting mapputAllFiltered(UnicodeMap<T> prop, UnicodeSet filter) Add all the (main) values from a Unicode propertyDeprecated.putAllInto(U map) Utility for extracting mapputAllInverse(Map<T, UnicodeSet> source) remove(int key) final UnicodeMap<T> removeAll(UnicodeMap<T> reference) final UnicodeMap<T> removeAll(UnicodeSet set) final UnicodeMap<T> retainAll(UnicodeMap<T> reference) final UnicodeMap<T> retainAll(UnicodeSet set) setErrorOnReset(boolean errorOnReset) Puts the UnicodeMap into a state whereby new mappings are accepted, but changes to old mappings cause an exception.setMissing(T value) Set the currently unmapped Unicode code points to the given value.intsize()Returns the keys that consist of multiple code points.toString()toString(Comparator<T> collected) Change a new string from the source string according to the mappings.values()Convenience method<U extends Collection<T>>
Uvalues(U result) Returns the list of possible values.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
UnicodeMap
public UnicodeMap() -
UnicodeMap
-
-
Method Details
-
clear
-
equals
-
areEqual
-
hashCode
-
cloneAsThawed
Standard clone. Warning, as with Collections, does not do deep clone.- Specified by:
cloneAsThawedin interfaceFreezable<T>
-
put
Sets the codepoint value.- Parameters:
codepoint-value-- Returns:
- this (for chaining)
-
put
Sets the codepoint value.- Parameters:
value-codepoint-- Returns:
- this (for chaining)
-
putAll
Adds bunch o' codepoints; otherwise like put.- Parameters:
codepoints-value-- Returns:
- this (for chaining)
-
putAll
Adds bunch o' codepoints; otherwise like add.- Parameters:
startCodePoint-endCodePoint-value-- Returns:
- this (for chaining)
-
putAll
Add all the (main) values from a UnicodeMap- Parameters:
unicodeMap- the property to add to the map- Returns:
- this (for chaining)
-
putAllFiltered
Add all the (main) values from a Unicode property- Parameters:
prop- the property to add to the map- Returns:
- this (for chaining)
-
setMissing
Set the currently unmapped Unicode code points to the given value.- Parameters:
value- the value to set- Returns:
- this (for chaining)
-
keySet
Returns the keyset consisting of all the keys that would produce the given value. Deposits into result if it is not null. Remember to clear if you just want the new values. -
keySet
Returns the keyset consisting of all the keys that would produce the given value. the new values. -
keySet
Returns the keyset consisting of all the keys that would produce (non-null) values. -
values
Returns the list of possible values. Deposits each non-null value into result. Creates result if it is null. Remember to clear result if you are not appending to existing collection.- Parameters:
result-- Returns:
- result
-
values
-
get
Gets the value associated with a given code point. Returns null, if there is no such value.- Parameters:
codepoint-- Returns:
- the value
-
get
-
transform
Change a new string from the source string according to the mappings. For each code point cp, if getValue(cp) is null, append the character, otherwise append getValue(cp).toString() TODO: extend to strings -
composeWith
-
composeWith
-
toString
-
toString
-
getErrorOnReset
public boolean getErrorOnReset()- Returns:
- Returns the errorOnReset value.
-
setErrorOnReset
Puts the UnicodeMap into a state whereby new mappings are accepted, but changes to old mappings cause an exception.- Parameters:
errorOnReset- The errorOnReset to set.
-
isFrozen
-
freeze
-
findCommonPrefix
-
getRangeCount
public int getRangeCount()Get the number of ranges; used for getRangeStart/End. The ranges together cover all of the single-codepoint keys in the UnicodeMap. Other keys can be gotten with getStrings(). -
getRangeStart
public int getRangeStart(int range) Get the start of a range. All code points between start and end are in the UnicodeMap's keyset. -
getRangeEnd
public int getRangeEnd(int range) Get the start of a range. All code points between start and end are in the UnicodeMap's keyset. -
getRangeValue
Get the value for the range. -
getNonRangeStrings
-
containsKey
-
containsKey
public boolean containsKey(int key) -
containsValue
-
isEmpty
public boolean isEmpty() -
putAll
-
putAllIn
Deprecated.Utility for extracting map -
putAllInto
-
putAllCodepointsInto
-
remove
-
remove
-
size
public int size() -
entrySet
-
entryRanges
Returns an Iterable over EntryRange, designed for efficient for loops over UnicodeMaps. Caution: For efficiency, the EntryRange may be reused, so the EntryRange may change on each iteration! The value is guaranteed never to be null. The entryRange.string values (non-null) are after all the ranges.- Returns:
- entry range, for for loops
-
iterator
-
getValue
-
getValue
Old form for compatibility -
getAvailableValues
Old form for compatibility -
getAvailableValues
Old form for compatibility -
getSet
Old form for compatibility -
getSet
Old form for compatibility -
removeAll
-
removeAll
-
retainAll
-
retainAll
-
stringKeys
-
addInverseTo
Gets the inverse of this map, adding to the target. Like putAllIn- Returns:
-
freeze
Freeze an inverse map.- Parameters:
target-- Returns:
-
putAllInverse
- Parameters:
target-- Returns:
-