本文整理汇总了Java中com.ibm.icu.text.Collator.SECONDARY属性的典型用法代码示例。如果您正苦于以下问题:Java Collator.SECONDARY属性的具体用法?Java Collator.SECONDARY怎么用?Java Collator.SECONDARY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.ibm.icu.text.Collator
的用法示例。
在下文中一共展示了Collator.SECONDARY属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findOrInsertNodeForRootCE
private int findOrInsertNodeForRootCE(long ce, int strength) {
assert((int)(ce >>> 56) != Collation.UNASSIGNED_IMPLICIT_BYTE);
// Find or insert the node for each of the root CE's weights,
// down to the requested level/strength.
// Root CEs must have common=zero quaternary weights (for which we never insert any nodes).
assert((ce & 0xc0) == 0);
int index = findOrInsertNodeForPrimary(ce >>> 32);
if(strength >= Collator.SECONDARY) {
int lower32 = (int)ce;
index = findOrInsertWeakNode(index, lower32 >>> 16, Collator.SECONDARY);
if(strength >= Collator.TERTIARY) {
index = findOrInsertWeakNode(index, lower32 & Collation.ONLY_TERTIARY_MASK,
Collator.TERTIARY);
}
}
return index;
}
示例2: insertTailoredNodeAfter
/**
* Makes and inserts a new tailored node into the list, after the one at index.
* Skips over nodes of weaker strength to maintain collation order
* ("postpone insertion").
* @return the new node's index
*/
private int insertTailoredNodeAfter(int index, int strength) {
assert(0 <= index && index < nodes.size());
if(strength >= Collator.SECONDARY) {
index = findCommonNode(index, Collator.SECONDARY);
if(strength >= Collator.TERTIARY) {
index = findCommonNode(index, Collator.TERTIARY);
}
}
// Postpone insertion:
// Insert the new node before the next one with a strength at least as strong.
long node = nodes.elementAti(index);
int nextIndex;
while((nextIndex = nextIndexFromNode(node)) != 0) {
node = nodes.elementAti(nextIndex);
if(strengthFromNode(node) <= strength) { break; }
// Skip the next node which has a weaker (larger) strength than the new one.
index = nextIndex;
}
node = IS_TAILORED | nodeFromStrength(strength);
return insertNodeBetween(index, nextIndex, node);
}
示例3: findCommonNode
/**
* Finds the node which implies or contains a common=05 weight of the given strength
* (secondary or tertiary), if the current node is stronger.
* Skips weaker nodes and tailored nodes if the current node is stronger
* and is followed by an explicit-common-weight node.
* Always returns the input index if that node is no stronger than the given strength.
*/
private int findCommonNode(int index, int strength) {
assert(Collator.SECONDARY <= strength && strength <= Collator.TERTIARY);
long node = nodes.elementAti(index);
if(strengthFromNode(node) >= strength) {
// The current node is no stronger.
return index;
}
if(strength == Collator.SECONDARY ? !nodeHasBefore2(node) : !nodeHasBefore3(node)) {
// The current node implies the strength-common weight.
return index;
}
index = nextIndexFromNode(node);
node = nodes.elementAti(index);
assert(!isTailoredNode(node) && strengthFromNode(node) == strength &&
weight16FromNode(node) < Collation.COMMON_WEIGHT16);
// Skip to the explicit common node.
do {
index = nextIndexFromNode(node);
node = nodes.elementAti(index);
assert(strengthFromNode(node) >= strength);
} while(isTailoredNode(node) || strengthFromNode(node) > strength ||
weight16FromNode(node) < Collation.COMMON_WEIGHT16);
assert(weight16FromNode(node) == Collation.COMMON_WEIGHT16);
return index;
}
示例4: setStrength
public void setStrength(int value) {
int noStrength = options & ~STRENGTH_MASK;
switch(value) {
case Collator.PRIMARY:
case Collator.SECONDARY:
case Collator.TERTIARY:
case Collator.QUATERNARY:
case Collator.IDENTICAL:
options = noStrength | (value << STRENGTH_SHIFT);
break;
default:
throw new IllegalArgumentException("illegal strength value " + value);
}
}
示例5: ceStrength
private static int ceStrength(long ce) {
return
isTempCE(ce) ? strengthFromTempCE(ce) :
(ce & 0xff00000000000000L) != 0 ? Collator.PRIMARY :
((int)ce & 0xff000000) != 0 ? Collator.SECONDARY :
ce != 0 ? Collator.TERTIARY :
Collator.IDENTICAL;
}
示例6: strength2Collator
static private int strength2Collator(Strength strength) {
switch (strength) {
case PRIMARY: return Collator.PRIMARY;
case SECONDARY: return Collator.SECONDARY;
case TERTIARY: return Collator.TERTIARY;
case QUATERNARY: return Collator.QUATERNARY;
case IDENTICAL: return Collator.IDENTICAL;
case UNDEFINED: return Collator.PRIMARY;
}
return Collator.PRIMARY;
}
示例7: parseRelationOperator
private int parseRelationOperator() {
ruleIndex = skipWhiteSpace(ruleIndex);
if(ruleIndex >= rules.length()) { return UCOL_DEFAULT; }
int strength;
int i = ruleIndex;
char c = rules.charAt(i++);
switch(c) {
case 0x3c: // '<'
if(i < rules.length() && rules.charAt(i) == 0x3c) { // <<
++i;
if(i < rules.length() && rules.charAt(i) == 0x3c) { // <<<
++i;
if(i < rules.length() && rules.charAt(i) == 0x3c) { // <<<<
++i;
strength = Collator.QUATERNARY;
} else {
strength = Collator.TERTIARY;
}
} else {
strength = Collator.SECONDARY;
}
} else {
strength = Collator.PRIMARY;
}
if(i < rules.length() && rules.charAt(i) == 0x2a) { // '*'
++i;
strength |= STARRED_FLAG;
}
break;
case 0x3b: // ';' same as <<
strength = Collator.SECONDARY;
break;
case 0x2c: // ',' same as <<<
strength = Collator.TERTIARY;
break;
case 0x3d: // '='
strength = Collator.IDENTICAL;
if(i < rules.length() && rules.charAt(i) == 0x2a) { // '*'
++i;
strength |= STARRED_FLAG;
}
break;
default:
return UCOL_DEFAULT;
}
return ((i - ruleIndex) << OFFSET_SHIFT) | strength;
}
示例8: getWeight16Before
/**
* Returns the secondary or tertiary weight preceding the current node's weight.
* node=nodes[index].
*/
private int getWeight16Before(int index, long node, int level) {
assert(strengthFromNode(node) < level || !isTailoredNode(node));
// Collect the root CE weights if this node is for a root CE.
// If it is not, then return the low non-primary boundary for a tailored CE.
int t;
if(strengthFromNode(node) == Collator.TERTIARY) {
t = weight16FromNode(node);
} else {
t = Collation.COMMON_WEIGHT16; // Stronger node with implied common weight.
}
while(strengthFromNode(node) > Collator.SECONDARY) {
index = previousIndexFromNode(node);
node = nodes.elementAti(index);
}
if(isTailoredNode(node)) {
return Collation.BEFORE_WEIGHT16;
}
int s;
if(strengthFromNode(node) == Collator.SECONDARY) {
s = weight16FromNode(node);
} else {
s = Collation.COMMON_WEIGHT16; // Stronger node with implied common weight.
}
while(strengthFromNode(node) > Collator.PRIMARY) {
index = previousIndexFromNode(node);
node = nodes.elementAti(index);
}
if(isTailoredNode(node)) {
return Collation.BEFORE_WEIGHT16;
}
// [p, s, t] is a root CE. Return the preceding weight for the requested level.
long p = weight32FromNode(node);
int weight16;
if(level == Collator.SECONDARY) {
weight16 = rootElements.getSecondaryBefore(p, s);
} else {
weight16 = rootElements.getTertiaryBefore(p, s, t);
assert((weight16 & ~Collation.ONLY_TERTIARY_MASK) == 0);
}
return weight16;
}
示例9: isCaseSensitive
@Override
public boolean isCaseSensitive() {
return collator.get().getStrength() > Collator.SECONDARY;
}
示例10: makeCheck
@Override
protected void makeCheck(Placeholder target, ImmutableList<String> tokenizedInput, ULocale locale,
String message) {
if (tokenizedInput.size() < 2) {
// Test passed. Nothing to sort.
return;
}
int strength = Collator.SECONDARY;
if (!target.isLenient()) {
if (!target.isStrict()) {
strength = Collator.TERTIARY;
} else {
strength = Collator.IDENTICAL;
}
}
// Init collators.
Collator collator = Collator.getInstance(locale);
ImmutableList.Builder<Collator> collators = ImmutableList.builder();
collators.add(collator);
try {
Collator collator2 = (RuleBasedCollator) collator.clone();
collator2.setStrength(strength);
collators.add(collator2);
RuleBasedCollator collator3 = (RuleBasedCollator) collator.clone();
collator3.setStrength(strength);
collator3.setAlternateHandlingShifted(true);
collators.add(collator3);
RuleBasedCollator collator4 = (RuleBasedCollator) collator.clone();
collator4.setStrength(strength);
collator4.setNumericCollation(true);
collators.add(collator4);
RuleBasedCollator collator5 = (RuleBasedCollator) collator.clone();
collator5.setStrength(strength);
collator5.setAlternateHandlingShifted(true);
collator5.setNumericCollation(true);
collators.add(collator5);
} catch (CloneNotSupportedException e) {
// Do nothing.
}
makeCheck(collators.build(), tokenizedInput, locale, message);
}