use of android.icu.impl.coll.CollationSettings in project j2objc by google.
the class RuleBasedCollator method setDecomposition.
/**
* Sets the decomposition mode of this Collator. Setting this
* decomposition attribute with CANONICAL_DECOMPOSITION allows the
* Collator to handle un-normalized text properly, producing the
* same results as if the text were normalized. If
* NO_DECOMPOSITION is set, it is the user's responsibility to
* insure that all text is already in the appropriate form before
* a comparison or before getting a CollationKey. Adjusting
* decomposition mode allows the user to select between faster and
* more complete collation behavior.
*
* <p>Since a great many of the world's languages do not require
* text normalization, most locales set NO_DECOMPOSITION as the
* default decomposition mode.
*
* The default decompositon mode for the Collator is
* NO_DECOMPOSITON, unless specified otherwise by the locale used
* to create the Collator.
*
* <p>See getDecomposition for a description of decomposition
* mode.
*
* @param decomposition the new decomposition mode
* @see #getDecomposition
* @see #NO_DECOMPOSITION
* @see #CANONICAL_DECOMPOSITION
* @throws IllegalArgumentException If the given value is not a valid
* decomposition mode.
*/
@Override
public void setDecomposition(int decomposition) {
checkNotFrozen();
boolean flag;
switch(decomposition) {
case NO_DECOMPOSITION:
flag = false;
break;
case CANONICAL_DECOMPOSITION:
flag = true;
break;
default:
throw new IllegalArgumentException("Wrong decomposition mode.");
}
if (flag == settings.readOnly().getFlag(CollationSettings.CHECK_FCD)) {
return;
}
CollationSettings ownedSettings = getOwnedSettings();
ownedSettings.setFlag(CollationSettings.CHECK_FCD, flag);
setFastLatinOptions(ownedSettings);
}
use of android.icu.impl.coll.CollationSettings in project j2objc by google.
the class RuleBasedCollator method setMaxVariable.
/**
* <strong>[icu]</strong> Sets the variable top to the top of the specified reordering group.
* The variable top determines the highest-sorting character
* which is affected by the alternate handling behavior.
* If that attribute is set to NON_IGNORABLE, then the variable top has no effect.
* @param group one of Collator.ReorderCodes.SPACE, Collator.ReorderCodes.PUNCTUATION,
* Collator.ReorderCodes.SYMBOL, Collator.ReorderCodes.CURRENCY;
* or Collator.ReorderCodes.DEFAULT to restore the default max variable group
* @return this
* @see #getMaxVariable
*/
@Override
public RuleBasedCollator setMaxVariable(int group) {
// Convert the reorder code into a MaxVariable number, or UCOL_DEFAULT=-1.
int value;
if (group == Collator.ReorderCodes.DEFAULT) {
// UCOL_DEFAULT
value = -1;
} else if (Collator.ReorderCodes.FIRST <= group && group <= Collator.ReorderCodes.CURRENCY) {
value = group - Collator.ReorderCodes.FIRST;
} else {
throw new IllegalArgumentException("illegal max variable group " + group);
}
int oldValue = settings.readOnly().getMaxVariable();
if (value == oldValue) {
return this;
}
CollationSettings defaultSettings = getDefaultSettings();
if (settings.readOnly() == defaultSettings) {
if (value < 0) {
// UCOL_DEFAULT
return this;
}
}
CollationSettings ownedSettings = getOwnedSettings();
if (group == Collator.ReorderCodes.DEFAULT) {
group = Collator.ReorderCodes.FIRST + defaultSettings.getMaxVariable();
}
long varTop = data.getLastPrimaryForGroup(group);
assert (varTop != 0);
ownedSettings.setMaxVariable(value, defaultSettings.options);
ownedSettings.variableTop = varTop;
setFastLatinOptions(ownedSettings);
return this;
}
use of android.icu.impl.coll.CollationSettings in project j2objc by google.
the class RuleBasedCollator method setAlternateHandlingShifted.
/**
* Sets the alternate handling for QUATERNARY strength to be either shifted or non-ignorable. See the UCA definition
* on <a href="http://www.unicode.org/unicode/reports/tr10/#Variable_Weighting">Variable Weighting</a>. This
* attribute will only be effective when QUATERNARY strength is set. The default value for this mode is false,
* corresponding to the NON_IGNORABLE mode in UCA. In the NON_IGNORABLE mode, the RuleBasedCollator treats all
* the code points with non-ignorable primary weights in the same way. If the mode is set to true, the behavior
* corresponds to SHIFTED defined in UCA, this causes code points with PRIMARY orders that are equal or below the
* variable top value to be ignored in PRIMARY order and moved to the QUATERNARY order.
*
* @param shifted
* true if SHIFTED behavior for alternate handling is desired, false for the NON_IGNORABLE behavior.
* @see #isAlternateHandlingShifted
* @see #setAlternateHandlingDefault
*/
public void setAlternateHandlingShifted(boolean shifted) {
checkNotFrozen();
if (shifted == isAlternateHandlingShifted()) {
return;
}
CollationSettings ownedSettings = getOwnedSettings();
ownedSettings.setAlternateHandlingShifted(shifted);
setFastLatinOptions(ownedSettings);
}
use of android.icu.impl.coll.CollationSettings in project j2objc by google.
the class RuleBasedCollator method setCaseFirstDefault.
/**
* Sets the case first mode to the initial mode set during construction of the RuleBasedCollator. See
* setUpperCaseFirst(boolean) and setLowerCaseFirst(boolean) for more details.
*
* @see #isLowerCaseFirst
* @see #isUpperCaseFirst
* @see #setLowerCaseFirst(boolean)
* @see #setUpperCaseFirst(boolean)
*/
public final void setCaseFirstDefault() {
checkNotFrozen();
CollationSettings defaultSettings = getDefaultSettings();
if (settings.readOnly() == defaultSettings) {
return;
}
CollationSettings ownedSettings = getOwnedSettings();
ownedSettings.setCaseFirstDefault(defaultSettings.options);
setFastLatinOptions(ownedSettings);
}
use of android.icu.impl.coll.CollationSettings in project j2objc by google.
the class RuleBasedCollator method setUpperCaseFirst.
/**
* Sets whether uppercase characters sort before lowercase characters or vice versa, in strength TERTIARY. The
* default mode is false, and so lowercase characters sort before uppercase characters. If true, sort upper case
* characters first.
*
* @param upperfirst
* true to sort uppercase characters before lowercase characters, false to sort lowercase characters
* before uppercase characters
* @see #isLowerCaseFirst
* @see #isUpperCaseFirst
* @see #setLowerCaseFirst
* @see #setCaseFirstDefault
*/
public void setUpperCaseFirst(boolean upperfirst) {
checkNotFrozen();
if (upperfirst == isUpperCaseFirst()) {
return;
}
CollationSettings ownedSettings = getOwnedSettings();
ownedSettings.setCaseFirst(upperfirst ? CollationSettings.CASE_FIRST_AND_UPPER_MASK : 0);
setFastLatinOptions(ownedSettings);
}
Aggregations