当前位置: 首页>>代码示例>>Java>>正文


Java UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT属性代码示例

本文整理汇总了Java中com.ibm.icu.lang.UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT属性的典型用法代码示例。如果您正苦于以下问题:Java UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT属性的具体用法?Java UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT怎么用?Java UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.ibm.icu.lang.UCharacter的用法示例。


在下文中一共展示了UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:google,项目名称:closure-templates,代码行数:63,代码来源:BidiUtils.java

示例2: isLtr

/**
 * @param ch
 * @return
 */
private boolean isLtr( char ch )
{
	return UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT == UCharacter
			.getDirectionality( ch );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:9,代码来源:BidiEngine.java


注:本文中的com.ibm.icu.lang.UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。