本文整理汇总了Java中com.ibm.icu.lang.UCharacter.getDirectionality方法的典型用法代码示例。如果您正苦于以下问题:Java UCharacter.getDirectionality方法的具体用法?Java UCharacter.getDirectionality怎么用?Java UCharacter.getDirectionality使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.icu.lang.UCharacter
的用法示例。
在下文中一共展示了UCharacter.getDirectionality方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dirTypeForward
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
* Returns the UCharacter.DIRECTIONALITY_... value of the next codepoint and advances charIndex.
* If isHtml, and the codepoint is '<' or '&', advances through the tag/entity, and returns an
* appropriate dirtype.
*
* @throws java.lang.IndexOutOfBoundsException if called when charIndex >= length or < 0.
*/
@VisibleForTesting
byte dirTypeForward() {
lastChar = text.charAt(charIndex);
if (UCharacter.isHighSurrogate(lastChar)) {
int codePoint = UCharacter.codePointAt(text, charIndex);
charIndex += UCharacter.charCount(codePoint);
return UCharacter.getDirectionality(codePoint);
}
charIndex++;
byte dirType = getCachedDirectionality(lastChar);
if (isHtml) {
// Process tags and entities.
if (lastChar == '<') {
dirType = skipTagForward();
} else if (lastChar == '&') {
dirType = skipEntityForward();
}
}
return dirType;
}
示例2: dirTypeBackward
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
* Returns the UCharacter.DIRECTIONALITY_... value of the preceding codepoint and advances
* charIndex backwards. If isHtml, and the codepoint is the end of a complete HTML tag or
* entity, advances over the whole tag/entity and returns an appropriate dirtype.
*
* @throws java.lang.IndexOutOfBoundsException if called when charIndex > length or <= 0.
*/
@VisibleForTesting
byte dirTypeBackward() {
lastChar = text.charAt(charIndex - 1);
if (UCharacter.isLowSurrogate(lastChar)) {
int codePoint = UCharacter.codePointBefore(text, charIndex);
charIndex -= UCharacter.charCount(codePoint);
return UCharacter.getDirectionality(codePoint);
}
charIndex--;
byte dirType = getCachedDirectionality(lastChar);
if (isHtml) {
// Process tags and entities.
if (lastChar == '>') {
dirType = skipTagBackward();
} else if (lastChar == ';') {
dirType = skipEntityBackward();
}
}
return dirType;
}
示例3: getDirectionality
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
* Gets the Unicode directionality of the specified character.
*
* @param codePoint
* the Unicode code point to get the directionality of.
* @return the Unicode directionality of {@code codePoint}.
*/
public static byte getDirectionality(int codePoint) {
if (getType(codePoint) == Character.UNASSIGNED) {
return Character.DIRECTIONALITY_UNDEFINED;
}
byte UCDirectionality = UCharacter.getDirectionality(codePoint);
if (UCDirectionality == -1) {
return -1;
}
return DIRECTIONALITY[UCDirectionality];
}
示例4: isRtl
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
* @param ch
* @return
*/
private boolean isRtl( char ch )
{
byte direction = UCharacter.getDirectionality( ch );
return UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT == direction
|| UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC == direction;
}
示例5: getDirectionality
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
* Gets the Unicode directionality of the specified character.
*
* @param codePoint
* the character, including supplementary characters
* @return the Unicode directionality
*/
public static byte getDirectionality(int codePoint) {
if (getType(codePoint) == Character.UNASSIGNED) {
return Character.DIRECTIONALITY_UNDEFINED;
}
byte UCDirectionality = UCharacter.getDirectionality(codePoint);
if (UCDirectionality == -1) {
return -1;
}
return DIRECTIONALITY[UCDirectionality];
}
示例6: isLtr
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
* @param ch
* @return
*/
private boolean isLtr( char ch )
{
return UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT == UCharacter
.getDirectionality( ch );
}
示例7: getCachedDirectionality
import com.ibm.icu.lang.UCharacter; //导入方法依赖的package包/类
/**
* Gets the bidi character class, i.e. UCharacter.getDirectionality(), of a given char, using a
* cache for speed. Not designed for supplementary codepoints, whose results we do not cache.
*/
private static byte getCachedDirectionality(char c) {
return c < DIR_TYPE_CACHE_SIZE ? DIR_TYPE_CACHE[c] : UCharacter.getDirectionality(c);
}