APIdia Launch Partner
Top Description Inners Constructors Methods
jdk.internal.icu.util

public abstract Class CodePointMap

extends Object
implements Iterable<CodePointMap.Range>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable
Known Direct Subclasses
jdk.internal.icu.util.CodePointTrie
Imports
java.util.Iterator, .NoSuchElementException

Abstract map from Unicode code points (U+0000..U+10FFFF) to integer values. This does not implement java.util.Map.
ICU Status
Stable since ICU 63.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
CodePointMap.Range

Range iteration result data.

private class
public static enum
CodePointMap.RangeOption

Selectors for how getRange() should report value ranges overlapping with surrogates.

public class
CodePointMap.StringIterator

Iterates over code points of a string and fetches map values.

public static interface
CodePointMap.ValueFilter

Callback function interface: Modifies a map value.

Constructor Summary

AccessConstructor and Description
protected
CodePointMap()

Protected no-args constructor.

Method Summary

Modifier and TypeMethod and Description
public abstract int

Returns:

the map value, or an implementation-defined error value if the code point is not in the range 0..U+10FFFF
get
(int
the code point
c
)

Returns the value for a code point as stored in the map, with range checking.

public abstract boolean

Returns:

true if start is 0..U+10FFFF; otherwise no new range is fetched
getRange
(int
range start
start
,
CodePointMap.ValueFilter
an object that may modify the map data value, or null if the values from the map are to be used unmodified
filter
,
CodePointMap.Range
the range object that will be set to the code point range and value
range
)

Sets the range object to a range of code points beginning with the start parameter.

public boolean

Returns:

true if start is 0..U+10FFFF; otherwise no new range is fetched
getRange
(int
range start
start
,
CodePointMap.RangeOption
defines whether surrogates are treated normally, or as having the surrogateValue; usually RangeOption#NORMAL
option
,
int
value for surrogates; ignored if option==RangeOption#NORMAL
surrogateValue
,
CodePointMap.ValueFilter
an object that may modify the map data value, or null if the values from the map are to be used unmodified
filter
,
CodePointMap.Range
the range object that will be set to the code point range and value
range
)

Sets the range object to a range of code points beginning with the start parameter.

public Iterator<CodePointMap.Range>

Returns:

a Range iterator
iterator
()

Implements java.lang.Iterable.iterator.

Convenience iterator over same-map-value code point ranges.

public CodePointMap.StringIterator

Returns:

the iterator
stringIterator
(CharSequence
string to iterate over
s
,
int
string index where the iteration will start
sIndex
)

Returns an iterator (not a java.util.Iterator) over code points of a string for fetching map values.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

CodePointMapback to summary
protected CodePointMap()

Protected no-args constructor.

ICU Status
Stable since ICU 63.

Method Detail

getback to summary
public abstract int get(int c)

Returns the value for a code point as stored in the map, with range checking. Returns an implementation-defined error value if c is not in the range 0..U+10FFFF.

Parameters
c:int

the code point

Returns:int

the map value, or an implementation-defined error value if the code point is not in the range 0..U+10FFFF

ICU Status
Stable since ICU 63.
getRangeback to summary
public abstract boolean getRange(int start, CodePointMap.ValueFilter filter, CodePointMap.Range range)

Sets the range object to a range of code points beginning with the start parameter. The range start is the same as the start input parameter (even if there are preceding code points that have the same value). The range end is the last code point such that all those from start to there have the same value. Returns false if start is not 0..U+10FFFF. Can be used to efficiently iterate over all same-value ranges in a map. (This is normally faster than iterating over code points and get()ting each value, but may be much slower than a data structure that stores ranges directly.)

If the ValueFilter parameter is not null, then the value to be delivered is passed through that filter, and the return value is the end of the range where all values are modified to the same actual value. The value is unchanged if that parameter is null.

Example:

int start = 0;
CodePointMap.Range range = new CodePointMap.Range();
while (map.getRange(start, null, range)) {
    int end = range.getEnd();
    int value = range.getValue();
    // Work with the range start..end and its value.
    start = end + 1;
}
Parameters
start:int

range start

filter:CodePointMap.ValueFilter

an object that may modify the map data value, or null if the values from the map are to be used unmodified

range:CodePointMap.Range

the range object that will be set to the code point range and value

Returns:boolean

true if start is 0..U+10FFFF; otherwise no new range is fetched

ICU Status
Stable since ICU 63.
getRangeback to summary
public boolean getRange(int start, CodePointMap.RangeOption option, int surrogateValue, CodePointMap.ValueFilter filter, CodePointMap.Range range)

Sets the range object to a range of code points beginning with the start parameter. The range start is the same as the start input parameter (even if there are preceding code points that have the same value). The range end is the last code point such that all those from start to there have the same value. Returns false if start is not 0..U+10FFFF.

Same as the simpler getRange(int, ValueFilter, Range) but optionally modifies the range if it overlaps with surrogate code points.

Parameters
start:int

range start

option:CodePointMap.RangeOption

defines whether surrogates are treated normally, or as having the surrogateValue; usually RangeOption#NORMAL

surrogateValue:int

value for surrogates; ignored if option==RangeOption#NORMAL

filter:CodePointMap.ValueFilter

an object that may modify the map data value, or null if the values from the map are to be used unmodified

range:CodePointMap.Range

the range object that will be set to the code point range and value

Returns:boolean

true if start is 0..U+10FFFF; otherwise no new range is fetched

ICU Status
Stable since ICU 63.
iteratorback to summary
public Iterator<CodePointMap.Range> iterator()

Implements java.lang.Iterable.iterator.

Convenience iterator over same-map-value code point ranges. Same as looping over all ranges with getRange(int, ValueFilter, Range) without filtering. Adjacent ranges have different map values.

The iterator always returns the same Range object.

Returns:Iterator<CodePointMap.Range>

a Range iterator

Annotations
@Override
ICU Status
Stable since ICU 63.
stringIteratorback to summary
public CodePointMap.StringIterator stringIterator(CharSequence s, int sIndex)

Returns an iterator (not a java.util.Iterator) over code points of a string for fetching map values.

Parameters
s:CharSequence

string to iterate over

sIndex:int

string index where the iteration will start

Returns:CodePointMap.StringIterator

the iterator

ICU Status
Stable since ICU 63.
jdk.internal.icu.util back to summary

public final Class CodePointMap.Range

extends Object
Class Inheritance

Range iteration result data. Code points from start to end map to the same value. The value may have been modified by ValueFilter#apply(int), or it may be the surrogateValue if a RangeOption other than "normal" was used.
ICU Status
Stable since ICU 63.
See Also
getRange, iterator

Field Summary

Modifier and TypeField and Description
private int
private int
private int

Constructor Summary

AccessConstructor and Description
public
Range()

Constructor.

Method Summary

Modifier and TypeMethod and Description
public int
getEnd()

Returns: the (inclusive) end code point

public int
getStart()

Returns: the start code point

public int
getValue()

Returns: the range value

public void
set(int
new start code point
start
,
int
new end code point
end
,
int
new value
value
)

Sets the range.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

endback to summary
private int end
startback to summary
private int start
valueback to summary
private int value

Constructor Detail

Rangeback to summary
public Range()

Constructor. Sets start and end to -1 and value to 0.

ICU Status
Stable since ICU 63.

Method Detail

getEndback to summary
public int getEnd()
Returns:int

the (inclusive) end code point

ICU Status
Stable since ICU 63.
getStartback to summary
public int getStart()
Returns:int

the start code point

ICU Status
Stable since ICU 63.
getValueback to summary
public int getValue()
Returns:int

the range value

ICU Status
Stable since ICU 63.
setback to summary
public void set(int start, int end, int value)

Sets the range. When using iterator(), iteration will resume after the newly set end.

Parameters
start:int

new start code point

end:int

new end code point

value:int

new value

ICU Status
Stable since ICU 63.
jdk.internal.icu.util back to summary

private final Class CodePointMap.RangeIterator

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

Field Summary

Modifier and TypeField and Description
private CodePointMap.Range

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public CodePointMap.Range
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

public final 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

rangeback to summary
private CodePointMap.Range range

Constructor Detail

RangeIteratorback to summary
private RangeIterator()

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.)

Annotations
@Override
nextback to summary
public CodePointMap.Range next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Annotations
@Override
removeback to summary
public final 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
jdk.internal.icu.util back to summary

public final Enum CodePointMap.RangeOption

extends Enum<CodePointMap.RangeOption>
Class Inheritance

Selectors for how getRange() should report value ranges overlapping with surrogates. Most users should use NORMAL.
ICU Status
Stable since ICU 63.
See Also
getRange

Field Summary

Modifier and TypeField and Description
public static final CodePointMap.RangeOption
FIXED_ALL_SURROGATES

getRange() enumerates all same-value ranges as stored in the map, except that all surrogates (U+D800..U+DFFF) are treated as having the surrogateValue, which is passed to getRange() as a separate parameter.

public static final CodePointMap.RangeOption
FIXED_LEAD_SURROGATES

getRange() enumerates all same-value ranges as stored in the map, except that lead surrogates (U+D800..U+DBFF) are treated as having the surrogateValue, which is passed to getRange() as a separate parameter.

public static final CodePointMap.RangeOption
NORMAL

getRange() enumerates all same-value ranges as stored in the map.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static CodePointMap.RangeOption
public static CodePointMap.RangeOption[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

FIXED_ALL_SURROGATESback to summary
public static final CodePointMap.RangeOption FIXED_ALL_SURROGATES

getRange() enumerates all same-value ranges as stored in the map, except that all surrogates (U+D800..U+DFFF) are treated as having the surrogateValue, which is passed to getRange() as a separate parameter. The surrogateValue is not transformed via filter(). See Character#isSurrogate.

Most users should use NORMAL instead.

This option is useful for maps that map surrogate code units to special values optimized for UTF-16 string processing or for special error behavior for unpaired surrogates, but those values are not to be associated with the lead surrogate code points.

ICU Status
Stable since ICU 63.
FIXED_LEAD_SURROGATESback to summary
public static final CodePointMap.RangeOption FIXED_LEAD_SURROGATES

getRange() enumerates all same-value ranges as stored in the map, except that lead surrogates (U+D800..U+DBFF) are treated as having the surrogateValue, which is passed to getRange() as a separate parameter. The surrogateValue is not transformed via filter(). See Character#isHighSurrogate.

Most users should use NORMAL instead.

This option is useful for maps that map surrogate code units to special values optimized for UTF-16 string processing or for special error behavior for unpaired surrogates, but those values are not to be associated with the lead surrogate code points.

ICU Status
Stable since ICU 63.
NORMALback to summary
public static final CodePointMap.RangeOption NORMAL

getRange() enumerates all same-value ranges as stored in the map. Most users should use this option.

ICU Status
Stable since ICU 63.

Constructor Detail

RangeOptionback to summary
private RangeOption()

Method Detail

valueOfback to summary
public static CodePointMap.RangeOption valueOf(String name)
valuesback to summary
public static CodePointMap.RangeOption[] values()
jdk.internal.icu.util back to summary

public Class CodePointMap.StringIterator

extends Object
Class Inheritance
Known Direct Subclasses
jdk.internal.icu.util.CodePointTrie.Fast.FastStringIterator, jdk.internal.icu.util.CodePointTrie.Small.SmallStringIterator

Iterates over code points of a string and fetches map values. This does not implement java.util.Iterator.
void onString(CodePointMap map, CharSequence s, int start) {
    CodePointMap.StringIterator iter = map.stringIterator(s, start);
    while (iter.next()) {
        int end = iter.getIndex();  // code point from between start and end
        useValue(s, start, end, iter.getCodePoint(), iter.getValue());
        start = end;
    }
}

This class is not intended for public subclassing.

ICU Status
Stable since ICU 63.

Field Summary

Modifier and TypeField and Description
protected int
c

Deprecated This API is ICU internal only.
protected CharSequence
s

Deprecated This API is ICU internal only.
protected int
sIndex

Deprecated This API is ICU internal only.
protected int
value

Deprecated This API is ICU internal only.

Constructor Summary

AccessConstructor and Description
protected
StringIterator(CharSequence s, int sIndex)
Deprecated This API is ICU internal only.

Method Summary

Modifier and TypeMethod and Description
public final int
getCodePoint()

Returns: the code point

public final int
getIndex()

Returns: the string index

public final int
getValue()

Returns: the map value, or an implementation-defined error value if the code point is an unpaired surrogate

public boolean

Returns:

true if the string index was not yet at the end of the string; otherwise the iterator did not advance
next
()

Reads the next code point, post-increments the string index, and gets a value from the map.

public boolean

Returns:

true if the string index was not yet at the start of the string; otherwise the iterator did not advance
previous
()

Reads the previous code point, pre-decrements the string index, and gets a value from the map.

public void
reset(CharSequence
string to iterate over
s
,
int
string index where the iteration will start
sIndex
)

Resets the iterator to a new string and/or a new string index.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cback to summary
protected int c

Deprecated

This API is ICU internal only.

Annotations
@Deprecated
ICU Status
Internal ICU component.
sback to summary
protected CharSequence s

Deprecated

This API is ICU internal only.

Annotations
@Deprecated
ICU Status
Internal ICU component.
sIndexback to summary
protected int sIndex

Deprecated

This API is ICU internal only.

Annotations
@Deprecated
ICU Status
Internal ICU component.
valueback to summary
protected int value

Deprecated

This API is ICU internal only.

Annotations
@Deprecated
ICU Status
Internal ICU component.

Constructor Detail

StringIteratorback to summary
protected StringIterator(CharSequence s, int sIndex)

Deprecated

This API is ICU internal only.

Annotations
@Deprecated
ICU Status
Internal ICU component.

Method Detail

getCodePointback to summary
public final int getCodePoint()
Returns:int

the code point

ICU Status
Stable since ICU 63.
getIndexback to summary
public final int getIndex()
Returns:int

the string index

ICU Status
Stable since ICU 63.
getValueback to summary
public final int getValue()
Returns:int

the map value, or an implementation-defined error value if the code point is an unpaired surrogate

ICU Status
Stable since ICU 63.
nextback to summary
public boolean next()

Reads the next code point, post-increments the string index, and gets a value from the map. Sets an implementation-defined error value if the code point is an unpaired surrogate.

Returns:boolean

true if the string index was not yet at the end of the string; otherwise the iterator did not advance

ICU Status
Stable since ICU 63.
previousback to summary
public boolean previous()

Reads the previous code point, pre-decrements the string index, and gets a value from the map. Sets an implementation-defined error value if the code point is an unpaired surrogate.

Returns:boolean

true if the string index was not yet at the start of the string; otherwise the iterator did not advance

ICU Status
Stable since ICU 63.
resetback to summary
public void reset(CharSequence s, int sIndex)

Resets the iterator to a new string and/or a new string index.

Parameters
s:CharSequence

string to iterate over

sIndex:int

string index where the iteration will start

ICU Status
Stable since ICU 63.
jdk.internal.icu.util back to summary

public Interface CodePointMap.ValueFilter


Callback function interface: Modifies a map value. Optionally called by getRange(). The modified value will be returned by the getRange() function.

Can be used to ignore some of the value bits, make a filter for one of several values, return a value index computed from the map value, etc.

ICU Status
Stable since ICU 63.
See Also
getRange, iterator

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

modified value
apply
(int
map value
value
)

Modifies the map value.

Method Detail

applyback to summary
public int apply(int value)

Modifies the map value.

Parameters
value:int

map value

Returns:int

modified value

ICU Status
Stable since ICU 63.