本文整理汇总了Java中java.text.AttributedCharacterIterator.current方法的典型用法代码示例。如果您正苦于以下问题:Java AttributedCharacterIterator.current方法的具体用法?Java AttributedCharacterIterator.current怎么用?Java AttributedCharacterIterator.current使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.text.AttributedCharacterIterator
的用法示例。
在下文中一共展示了AttributedCharacterIterator.current方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: format
import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
@Override
String format(
AttributedCharacterIterator iterator,
String preExponent) {
int copyFromOffset = 0;
StringBuilder result = new StringBuilder();
for (
iterator.first();
iterator.current() != CharacterIterator.DONE;
) {
Map<Attribute, Object> attributeSet = iterator.getAttributes();
if (attributeSet.containsKey(NumberFormat.Field.EXPONENT_SYMBOL)) {
append(
iterator,
copyFromOffset,
iterator.getRunStart(NumberFormat.Field.EXPONENT_SYMBOL),
result);
copyFromOffset = iterator.getRunLimit(NumberFormat.Field.EXPONENT_SYMBOL);
iterator.setIndex(copyFromOffset);
result.append(preExponent);
result.append(beginMarkup);
} else if (attributeSet.containsKey(NumberFormat.Field.EXPONENT)) {
int limit = iterator.getRunLimit(NumberFormat.Field.EXPONENT);
append(
iterator,
copyFromOffset,
limit,
result);
copyFromOffset = limit;
iterator.setIndex(copyFromOffset);
result.append(endMarkup);
} else {
iterator.next();
}
}
append(iterator, copyFromOffset, iterator.getEndIndex(), result);
return result.toString();
}
示例2: char32AtAndAdvance
import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
private static int char32AtAndAdvance(AttributedCharacterIterator iterator) {
char c1 = iterator.current();
char c2 = iterator.next();
if (UCharacter.isHighSurrogate(c1)) {
// If c2 is DONE, it will fail the low surrogate test and we
// skip this block.
if (UCharacter.isLowSurrogate(c2)) {
iterator.next();
return UCharacter.toCodePoint(c1, c2);
}
}
return c1;
}
示例3: iterateRun
import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
private boolean iterateRun(AttributedCharacterIterator iterator, StringBuilder sb) {
sb.setLength(0);
int charCount = iterator.getRunLimit() - iterator.getRunStart();
while (charCount-- >= 0) {
char c = iterator.current();
iterator.next();
if (c == AttributedCharacterIterator.DONE) {
return false;
} else {
sb.append(c);
}
}
return true;
}