本文整理汇总了Java中com.ibm.icu.lang.UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE属性的典型用法代码示例。如果您正苦于以下问题:Java UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE属性的具体用法?Java UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE怎么用?Java UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.ibm.icu.lang.UCharacter
的用法示例。
在下文中一共展示了UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getExitDir
/**
* Returns the directionality of the last character with strong directionality in the string, or
* Dir.NEUTRAL if none was encountered. For efficiency, actually scans backwards from the end of
* the string. Treats a non-BN character between an LRE/RLE/LRO/RLO and its matching PDF as a
* strong character, LTR after LRE/LRO, and RTL after RLE/RLO. The results are undefined for a
* string containing unbalanced LRE/RLE/LRO/RLO/PDF characters.
*/
Dir getExitDir() {
// The reason for this method name, as opposed to getLastStrongDir(), is that "last strong"
// sounds like the exact opposite of "first strong", which is a commonly used description of
// Unicode's estimation algorithm (getUnicodeDir() above), but the two must treat formatting
// characters quite differently. Thus, we are staying away from both "first" and "last" in
// these method names to avoid confusion.
charIndex = length;
int embeddingLevel = 0;
int lastNonEmptyEmbeddingLevel = 0;
while (charIndex > 0) {
switch (dirTypeBackward()) {
case UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT:
if (embeddingLevel == 0) {
return Dir.LTR;
}
if (lastNonEmptyEmbeddingLevel == 0) {
lastNonEmptyEmbeddingLevel = embeddingLevel;
}
break;
case UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING:
case UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE:
if (lastNonEmptyEmbeddingLevel == embeddingLevel) {
return Dir.LTR;
}
--embeddingLevel;
break;
case UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT:
case UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
if (embeddingLevel == 0) {
return Dir.RTL;
}
if (lastNonEmptyEmbeddingLevel == 0) {
lastNonEmptyEmbeddingLevel = embeddingLevel;
}
break;
case UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING:
case UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE:
if (lastNonEmptyEmbeddingLevel == embeddingLevel) {
return Dir.RTL;
}
--embeddingLevel;
break;
case UCharacter.DIRECTIONALITY_POP_DIRECTIONAL_FORMAT:
++embeddingLevel;
break;
case UCharacter.BOUNDARY_NEUTRAL:
break;
default:
if (lastNonEmptyEmbeddingLevel == 0) {
lastNonEmptyEmbeddingLevel = embeddingLevel;
}
break;
}
}
return Dir.NEUTRAL;
}