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

public abstract Class CollationIterator

extends Object
Class Inheritance
Known Direct Subclasses
com.ibm.icu.impl.coll.IterCollationIterator, com.ibm.icu.impl.coll.UTF16CollationIterator, com.ibm.icu.impl.coll.CollationDataBuilder.DataBuilderCollationIterator
Imports
com.ibm.icu.impl.Normalizer2Impl.Hangul, .Trie2_32, com.ibm.icu.util.BytesTrie, .CharsTrie, .ICUException

Collation element iterator and abstract character iterator. When a method returns a code point value, it must be in 0..10FFFF, except it can be negative as a sentinel value.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private CollationIterator.CEBuffer
private int
protected final CollationData
private boolean
protected static final long
private int
private CollationIterator.SkippedState
protected final Trie2_32

Constructor Summary

AccessConstructor and Description
public
CollationIterator(CollationData d)

Partially constructs the iterator.

public
CollationIterator(CollationData d, boolean numeric)

Method Summary

Modifier and TypeMethod and Description
protected final void
appendCEsFromCE32(CollationData d, int c, int ce32, boolean forward)

private final void
appendNumericCEs(int ce32, boolean forward)

Turns a string of digits (bytes 0..9) into a sequence of CEs that will sort in numeric order.

private final void
appendNumericSegmentCEs(CharSequence digits)

Turns 1..254 digits into a sequence of CEs.

protected abstract void
private final void
pack-priv final void
public final void
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public final int

Returns:

getCEsLength()
fetchCEs
()

Fetches all CEs.

protected boolean

Returns:

false if surrogate code points U+D800..U+DFFF map to their own implicit primary weights (for UTF-16), or true if they map to CE(U+FFFD) (for UTF-8)
forbidSurrogateCodePoints
()

protected abstract void
public final long
getCE(int i)

protected int
private final int
public final long[]
public final int
protected int
getDataCE32(int c)

Returns the CE32 from the data trie.

public abstract int
protected char
handleGetTrailSurrogate()

Called when handleNextCE32() returns a LEAD_SURROGATE_TAG for a lead surrogate code unit.

protected long
handleNextCE32()

Returns the next code point and its local CE32 value.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
protected static final boolean
private static final boolean
isSurrogate(int c)

protected static final boolean
protected long
makeCodePointAndCE32Pair(int c, int ce32)

public final long
nextCE()

Returns the next collation element.

private final int
nextCE32FromContraction(CollationData d, int contractionCE32, CharSequence trieChars, int trieOffset, int ce32, int c)

private final int
nextCE32FromDiscontiguousContraction(CollationData d, CharsTrie suffixes, int ce32, int lookAhead, int c)

private final long
nextCEFromCE32(CollationData d, int c, int ce32)

public abstract int
nextCodePoint()

Returns the next code point (with post-increment).

private final int
public final long
previousCE(UVector32 offsets)

Returns the previous collation element.

private final long
previousCEUnsafe(int c, UVector32 offsets)

Returns the previous CE when data.isUnsafeBackward(c, isNumeric).

public abstract int
previousCodePoint()

Returns the previous code point (with pre-decrement).

protected final void
protected final void
reset(boolean numeric)

Resets the state as well as the numeric setting, and completes the initialization.

public abstract void
resetToOffset(int newOffset)

Resets the iterator state and sets the position to the specified offset.

pack-priv final void
setCurrentCE(long ce)

Overwrites the current CE (the last one returned by nextCE()).

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

ceBufferback to summary
private CollationIterator.CEBuffer ceBuffer
cesIndexback to summary
private int cesIndex
databack to summary
protected final CollationData data
isNumericback to summary
private boolean isNumeric
NO_CP_AND_CE32back to summary
protected static final long NO_CP_AND_CE32
numCpFwdback to summary
private int numCpFwd
skippedback to summary
private CollationIterator.SkippedState skipped
trieback to summary
protected final Trie2_32 trie

Constructor Detail

CollationIteratorback to summary
public CollationIterator(CollationData d)

Partially constructs the iterator. In Java, we cache partially constructed iterators and finish their setup when starting to work on text (via reset(boolean) and the setText(numeric, ...) methods of subclasses). This avoids memory allocations for iterators that remain unused.

In C++, there is only one constructor, and iterators are stack-allocated as needed.

CollationIteratorback to summary
public CollationIterator(CollationData d, boolean numeric)

Method Detail

appendCEsFromCE32back to summary
protected final void appendCEsFromCE32(CollationData d, int c, int ce32, boolean forward)
appendNumericCEsback to summary
private final void appendNumericCEs(int ce32, boolean forward)

Turns a string of digits (bytes 0..9) into a sequence of CEs that will sort in numeric order. Starts from this ce32's digit value and consumes the following/preceding digits. The digits string must not be empty and must not have leading zeros.

appendNumericSegmentCEsback to summary
private final void appendNumericSegmentCEs(CharSequence digits)

Turns 1..254 digits into a sequence of CEs. Called by appendNumericCEs() for each segment of at most 254 digits.

backwardNumCodePointsback to summary
protected abstract void backwardNumCodePoints(int num)
backwardNumSkippedback to summary
private final void backwardNumSkipped(int n)
clearCEsback to summary
pack-priv final void clearCEs()
clearCEsIfNoneRemainingback to summary
public final void clearCEsIfNoneRemaining()
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
fetchCEsback to summary
public final int fetchCEs()

Fetches all CEs.

Returns:int

getCEsLength()

forbidSurrogateCodePointsback to summary
protected boolean forbidSurrogateCodePoints()
Returns:boolean

false if surrogate code points U+D800..U+DFFF map to their own implicit primary weights (for UTF-16), or true if they map to CE(U+FFFD) (for UTF-8)

forwardNumCodePointsback to summary
protected abstract void forwardNumCodePoints(int num)
getCEback to summary
public final long getCE(int i)
getCE32FromBuilderDataback to summary
protected int getCE32FromBuilderData(int ce32)
getCE32FromPrefixback to summary
private final int getCE32FromPrefix(CollationData d, int ce32)
getCEsback to summary
public final long[] getCEs()
getCEsLengthback to summary
public final int getCEsLength()
getDataCE32back to summary
protected int getDataCE32(int c)

Returns the CE32 from the data trie. Normally the same as data.getCE32(), but overridden in the builder. Call this only when the faster data.getCE32() cannot be used.

getOffsetback to summary
public abstract int getOffset()
handleGetTrailSurrogateback to summary
protected char handleGetTrailSurrogate()

Called when handleNextCE32() returns a LEAD_SURROGATE_TAG for a lead surrogate code unit. Returns the trail surrogate in that case and advances past it, if a trail surrogate follows the lead surrogate. Otherwise returns any other code unit and does not advance.

handleNextCE32back to summary
protected long handleNextCE32()

Returns the next code point and its local CE32 value. Returns Collation.FALLBACK_CE32 at the end of the text (c<0) or when c's CE32 value is to be looked up in the base data (fallback). The code point is used for fallbacks, context and implicit weights. It is ignored when the returned CE32 is not special (e.g., FFFD_CE32). Returns the code point in bits 63..32 (signed) and the CE32 in bits 31..0.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
isLeadSurrogateback to summary
protected static final boolean isLeadSurrogate(int c)
isSurrogateback to summary
private static final boolean isSurrogate(int c)
isTrailSurrogateback to summary
protected static final boolean isTrailSurrogate(int c)
makeCodePointAndCE32Pairback to summary
protected long makeCodePointAndCE32Pair(int c, int ce32)
nextCEback to summary
public final long nextCE()

Returns the next collation element.

nextCE32FromContractionback to summary
private final int nextCE32FromContraction(CollationData d, int contractionCE32, CharSequence trieChars, int trieOffset, int ce32, int c)
nextCE32FromDiscontiguousContractionback to summary
private final int nextCE32FromDiscontiguousContraction(CollationData d, CharsTrie suffixes, int ce32, int lookAhead, int c)
nextCEFromCE32back to summary
private final long nextCEFromCE32(CollationData d, int c, int ce32)
nextCodePointback to summary
public abstract int nextCodePoint()

Returns the next code point (with post-increment). Public for identical-level comparison and for testing.

nextSkippedCodePointback to summary
private final int nextSkippedCodePoint()
previousCEback to summary
public final long previousCE(UVector32 offsets)

Returns the previous collation element.

previousCEUnsafeback to summary
private final long previousCEUnsafe(int c, UVector32 offsets)

Returns the previous CE when data.isUnsafeBackward(c, isNumeric).

previousCodePointback to summary
public abstract int previousCodePoint()

Returns the previous code point (with pre-decrement). Public for identical-level comparison and for testing.

resetback to summary
protected final void reset()
resetback to summary
protected final void reset(boolean numeric)

Resets the state as well as the numeric setting, and completes the initialization. Only exists in Java where we reset cached CollationIterator instances rather than stack-allocating temporary ones. (See also the constructor comments.)

resetToOffsetback to summary
public abstract void resetToOffset(int newOffset)

Resets the iterator state and sets the position to the specified offset. Subclasses must implement, and must call the parent class method, or CollationIterator.reset().

setCurrentCEback to summary
pack-priv final void setCurrentCE(long ce)

Overwrites the current CE (the last one returned by nextCE()).

com.ibm.icu.impl.coll back to summary

private final Class CollationIterator.CEBuffer

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private long[]
private static final int
INITIAL_CAPACITY

Large enough for CEs of most short strings.

pack-priv int

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
append(long ce)

pack-priv void
appendUnsafe(long ce)

pack-priv void
pack-priv long
get(int i)

pack-priv long[]
pack-priv void
pack-priv long
set(int i, long ce)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferback to summary
private long[] buffer
INITIAL_CAPACITYback to summary
private static final int INITIAL_CAPACITY

Large enough for CEs of most short strings.

lengthback to summary
pack-priv int length

Constructor Detail

CEBufferback to summary
pack-priv CEBuffer()

Method Detail

appendback to summary
pack-priv void append(long ce)
appendUnsafeback to summary
pack-priv void appendUnsafe(long ce)
ensureAppendCapacityback to summary
pack-priv void ensureAppendCapacity(int appCap)
getback to summary
pack-priv long get(int i)
getCEsback to summary
pack-priv long[] getCEs()
incLengthback to summary
pack-priv void incLength()
setback to summary
pack-priv long set(int i, long ce)
com.ibm.icu.impl.coll back to summary

private final Class CollationIterator.SkippedState

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final StringBuilder
private final StringBuilder
private int
private int
private CharsTrie.State

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv int
pack-priv void
pack-priv boolean
pack-priv void
pack-priv boolean
pack-priv int
next()

pack-priv void
pack-priv void
pack-priv void
pack-priv void
pack-priv void
pack-priv void
skip(int c)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

newBufferback to summary
private final StringBuilder newBuffer
oldBufferback to summary
private final StringBuilder oldBuffer
posback to summary
private int pos
skipLengthAtMatchback to summary
private int skipLengthAtMatch
stateback to summary
private CharsTrie.State state

Constructor Detail

SkippedStateback to summary
pack-priv SkippedState()

Method Detail

backwardNumCodePointsback to summary
pack-priv int backwardNumCodePoints(int n)
clearback to summary
pack-priv void clear()
hasNextback to summary
pack-priv boolean hasNext()
incBeyondback to summary
pack-priv void incBeyond()
isEmptyback to summary
pack-priv boolean isEmpty()
nextback to summary
pack-priv int next()
recordMatchback to summary
pack-priv void recordMatch()
replaceMatchback to summary
pack-priv void replaceMatch()
resetToTrieStateback to summary
pack-priv void resetToTrieState(CharsTrie trie)
saveTrieStateback to summary
pack-priv void saveTrieState(CharsTrie trie)
setFirstSkippedback to summary
pack-priv void setFirstSkipped(int c)
skipback to summary
pack-priv void skip(int c)