Package com.ibm.icu.impl.coll
Class CollationRootElements
- java.lang.Object
-
- com.ibm.icu.impl.coll.CollationRootElements
-
public final class CollationRootElements extends java.lang.Object
Container and access methods for collation elements and weights that occur in the root collator. Needed for finding boundaries for building a tailoring. This class takes and returns 16-bit secondary and tertiary weights.
-
-
Field Summary
Fields Modifier and Type Field Description private long[]
elements
Data structure: See ICU4C source/i18n/collationrootelements.h.(package private) static int
IX_COMMON_SEC_AND_TER_CE
Must match Collation.COMMON_SEC_AND_TER_CE.(package private) static int
IX_COUNT
The current number of indexes.(package private) static int
IX_FIRST_PRIMARY_INDEX
Index of the first CE with a non-zero primary weight.(package private) static int
IX_FIRST_SECONDARY_INDEX
Index of the first CE with a non-zero secondary weight.static int
IX_FIRST_TERTIARY_INDEX
Index of the first CE with a non-zero tertiary weight.(package private) static int
IX_SEC_TER_BOUNDARIES
Secondary & tertiary boundaries.static long
PRIMARY_SENTINEL
Higher than any root primary.static int
PRIMARY_STEP_MASK
Mask for getting the primary range step value from a primary-range-end element.static int
SEC_TER_DELTA_FLAG
Flag in a root element, set if the element contains secondary & tertiary weights, rather than a primary.
-
Constructor Summary
Constructors Constructor Description CollationRootElements(long[] rootElements)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private int
findP(long p)
Finds the largest index i where elements[i]<=p.(package private) int
findPrimary(long p)
Finds the index of the input primary.(package private) long
firstCEWithPrimaryAtLeast(long p)
Returns the first root CE with a primary weight of at least p.(package private) long
getFirstPrimary()
Returns the first assigned primary weight.(package private) long
getFirstPrimaryCE()
Returns the first assigned primary CE.(package private) long
getFirstSecondaryCE()
Returns the first assigned secondary CE.private long
getFirstSecTerForPrimary(int index)
Returns the first secondary & tertiary weights for p where index=findPrimary(p)+1.(package private) long
getFirstTertiaryCE()
Returns the first assigned tertiary CE.int
getLastCommonSecondary()
Returns the last common secondary weight.(package private) long
getLastSecondaryCE()
Returns the last assigned secondary CE.(package private) long
getLastTertiaryCE()
Returns the last assigned tertiary CE.(package private) long
getPrimaryAfter(long p, int index, boolean isCompressible)
Returns the primary weight after p where index=findPrimary(p).(package private) long
getPrimaryBefore(long p, boolean isCompressible)
Returns the primary weight before p.(package private) int
getSecondaryAfter(int index, int s)
Returns the secondary weight after [p, s] where index=findPrimary(p) except use index=0 for p=0.(package private) int
getSecondaryBefore(long p, int s)
Returns the secondary weight before [p, s].int
getSecondaryBoundary()
Returns the boundary between secondary weights of primary CEs and those of secondary CEs.(package private) int
getTertiaryAfter(int index, int s, int t)
Returns the tertiary weight after [p, s, t] where index=findPrimary(p) except use index=0 for p=0.(package private) int
getTertiaryBefore(long p, int s, int t)
Returns the tertiary weight before [p, s, t].int
getTertiaryBoundary()
Returns the boundary between tertiary weights of primary/secondary CEs and those of tertiary CEs.private static boolean
isEndOfPrimaryRange(long q)
(package private) long
lastCEWithPrimaryBefore(long p)
Returns the last root CE with a primary weight before p.
-
-
-
Field Detail
-
PRIMARY_SENTINEL
public static final long PRIMARY_SENTINEL
Higher than any root primary.- See Also:
- Constant Field Values
-
SEC_TER_DELTA_FLAG
public static final int SEC_TER_DELTA_FLAG
Flag in a root element, set if the element contains secondary & tertiary weights, rather than a primary.- See Also:
- Constant Field Values
-
PRIMARY_STEP_MASK
public static final int PRIMARY_STEP_MASK
Mask for getting the primary range step value from a primary-range-end element.- See Also:
- Constant Field Values
-
IX_FIRST_TERTIARY_INDEX
public static final int IX_FIRST_TERTIARY_INDEX
Index of the first CE with a non-zero tertiary weight. Same as the start of the compact root elements table.- See Also:
- Constant Field Values
-
IX_FIRST_SECONDARY_INDEX
static final int IX_FIRST_SECONDARY_INDEX
Index of the first CE with a non-zero secondary weight.- See Also:
- Constant Field Values
-
IX_FIRST_PRIMARY_INDEX
static final int IX_FIRST_PRIMARY_INDEX
Index of the first CE with a non-zero primary weight.- See Also:
- Constant Field Values
-
IX_COMMON_SEC_AND_TER_CE
static final int IX_COMMON_SEC_AND_TER_CE
Must match Collation.COMMON_SEC_AND_TER_CE.- See Also:
- Constant Field Values
-
IX_SEC_TER_BOUNDARIES
static final int IX_SEC_TER_BOUNDARIES
Secondary & tertiary boundaries. Bits 31..24: [fixed last secondary common byte 45] Bits 23..16: [fixed first ignorable secondary byte 80] Bits 15.. 8: reserved, 0 Bits 7.. 0: [fixed first ignorable tertiary byte 3C]- See Also:
- Constant Field Values
-
IX_COUNT
static final int IX_COUNT
The current number of indexes. Currently the same as elements[IX_FIRST_TERTIARY_INDEX].- See Also:
- Constant Field Values
-
elements
private long[] elements
Data structure: See ICU4C source/i18n/collationrootelements.h.
-
-
Method Detail
-
getTertiaryBoundary
public int getTertiaryBoundary()
Returns the boundary between tertiary weights of primary/secondary CEs and those of tertiary CEs. This is the upper limit for tertiaries of primary/secondary CEs. This minus one is the lower limit for tertiaries of tertiary CEs.
-
getFirstTertiaryCE
long getFirstTertiaryCE()
Returns the first assigned tertiary CE.
-
getLastTertiaryCE
long getLastTertiaryCE()
Returns the last assigned tertiary CE.
-
getLastCommonSecondary
public int getLastCommonSecondary()
Returns the last common secondary weight. This is the lower limit for secondaries of primary CEs.
-
getSecondaryBoundary
public int getSecondaryBoundary()
Returns the boundary between secondary weights of primary CEs and those of secondary CEs. This is the upper limit for secondaries of primary CEs. This minus one is the lower limit for secondaries of secondary CEs.
-
getFirstSecondaryCE
long getFirstSecondaryCE()
Returns the first assigned secondary CE.
-
getLastSecondaryCE
long getLastSecondaryCE()
Returns the last assigned secondary CE.
-
getFirstPrimary
long getFirstPrimary()
Returns the first assigned primary weight.
-
getFirstPrimaryCE
long getFirstPrimaryCE()
Returns the first assigned primary CE.
-
lastCEWithPrimaryBefore
long lastCEWithPrimaryBefore(long p)
Returns the last root CE with a primary weight before p. Intended only for reordering group boundaries.
-
firstCEWithPrimaryAtLeast
long firstCEWithPrimaryAtLeast(long p)
Returns the first root CE with a primary weight of at least p. Intended only for reordering group boundaries.
-
getPrimaryBefore
long getPrimaryBefore(long p, boolean isCompressible)
Returns the primary weight before p. p must be greater than the first root primary.
-
getSecondaryBefore
int getSecondaryBefore(long p, int s)
Returns the secondary weight before [p, s].
-
getTertiaryBefore
int getTertiaryBefore(long p, int s, int t)
Returns the tertiary weight before [p, s, t].
-
findPrimary
int findPrimary(long p)
Finds the index of the input primary. p must occur as a root primary, and must not be 0.
-
getPrimaryAfter
long getPrimaryAfter(long p, int index, boolean isCompressible)
Returns the primary weight after p where index=findPrimary(p). p must be at least the first root primary.
-
getSecondaryAfter
int getSecondaryAfter(int index, int s)
Returns the secondary weight after [p, s] where index=findPrimary(p) except use index=0 for p=0.Must return a weight for every root [p, s] as well as for every weight returned by getSecondaryBefore(). If p!=0 then s can be BEFORE_WEIGHT16.
Exception: [0, 0] is handled by the CollationBuilder: Both its lower and upper boundaries are special.
-
getTertiaryAfter
int getTertiaryAfter(int index, int s, int t)
Returns the tertiary weight after [p, s, t] where index=findPrimary(p) except use index=0 for p=0.Must return a weight for every root [p, s, t] as well as for every weight returned by getTertiaryBefore(). If s!=0 then t can be BEFORE_WEIGHT16.
Exception: [0, 0, 0] is handled by the CollationBuilder: Both its lower and upper boundaries are special.
-
getFirstSecTerForPrimary
private long getFirstSecTerForPrimary(int index)
Returns the first secondary & tertiary weights for p where index=findPrimary(p)+1.
-
findP
private int findP(long p)
Finds the largest index i where elements[i]<=p. Requires first primary<=p<0xffffff00 (PRIMARY_SENTINEL). Does not require that p is a root collator primary.
-
isEndOfPrimaryRange
private static boolean isEndOfPrimaryRange(long q)
-
-