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


Java CharacterIterator.DONE属性代码示例

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


在下文中一共展示了CharacterIterator.DONE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkIteratorText

private static final void checkIteratorText(AttributedCharacterIterator iterator, String expectedText) throws Exception {
    if (iterator.getEndIndex() - iterator.getBeginIndex() != expectedText.length()) {
        throwException(iterator, "text length doesn't match between original text and iterator");
    }

    char c = iterator.first();
    for (int i = 0; i < expectedText.length(); i++) {
        if (c != expectedText.charAt(i)) {
            throwException(iterator, "text content doesn't match between original text and iterator");
        }
        c = iterator.next();
    }
    if (c != CharacterIterator.DONE) {
        throwException(iterator, "iterator text doesn't end with DONE");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:AttributedStringTest.java

示例2: readHexValue

public static int readHexValue(CharacterIterator i, int maxchars) {
    int accumul = 0;

    for (int cntr = 0; cntr < maxchars; cntr++) {
        final char c = i.current();

        if (c == CharacterIterator.DONE || !isHexDigit(c)) {
            break;
        }

        accumul = (accumul << 4) | hexValueOf(c);
        i.next();
    }

    return accumul;
}
 
开发者ID:beehive-lab,项目名称:Maxine-VM,代码行数:16,代码来源:StringUtil.java

示例3: checkIteratorSubranges

private static final void checkIteratorSubranges(AttributedCharacterIterator iterator, Set keys, int[] expectedLimits) throws Exception {
    int previous = 0;
    char c = iterator.first();
    for (int i = 0; i < expectedLimits.length; i++) {
         if (iterator.getRunStart(keys) != previous || iterator.getRunLimit(keys) != expectedLimits[i]) {
             throwException(iterator, "run boundaries are not as expected: " + iterator.getRunStart(keys) + ", " + iterator.getRunLimit(keys) + " for keys " + keys);
         }
         previous = expectedLimits[i];
         c = iterator.setIndex(previous);
    }
    if (c != CharacterIterator.DONE) {
        throwException(iterator, "iterator's run sequence doesn't end with DONE");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:AttributedStringTest.java

示例4: setText

/**
 * Calculate break positions eagerly parallel to reading text.
 */
public void setText(CharacterIterator ci) {
    int begin = ci.getBeginIndex();
    text = new char[ci.getEndIndex() - begin];
    int[] breaks0 = new int[text.length + 1];
    int brIx = 0;
    breaks0[brIx++] = begin;

    int charIx = 0;
    boolean inWs = false;
    for (char c = ci.first(); c != CharacterIterator.DONE; c = ci.next()) {
        text[charIx] = c;
        boolean ws = Character.isWhitespace(c);
        if (inWs && !ws) {
            breaks0[brIx++] = charIx + begin;
        }
        inWs = ws;
        charIx++;
    }
    if (text.length > 0) {
        breaks0[brIx++] = text.length + begin;
    }
    System.arraycopy(breaks0, 0, breaks = new int[brIx], 0, brIx);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:WhitespaceBasedBreakIterator.java

示例5: nextTrail32

public static int nextTrail32(CharacterIterator ci, int lead) {
    if (lead == CharacterIterator.DONE && ci.getIndex() >= ci.getEndIndex()) {
        return DONE32;
    }
    int retVal = lead;
    if (lead <= UTF16.LEAD_SURROGATE_MAX_VALUE) {
        char  cTrail = ci.next();
        if (UTF16.isTrailSurrogate(cTrail)) {
            retVal = ((lead  - UTF16.LEAD_SURROGATE_MIN_VALUE) << 10) +
                        (cTrail - UTF16.TRAIL_SURROGATE_MIN_VALUE) +
                        UTF16.SUPPLEMENTARY_MIN_VALUE;
        } else {
            ci.previous();
        }
    }
    return retVal;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:17,代码来源:CharacterIteration.java

示例6: string

private boolean string() {
    if (c != '"') return false;

    int start = col;
    boolean escaped = false;

    for (nextCharacter(); c != CharacterIterator.DONE; nextCharacter()) {
        if (!escaped && c == '\\') {
            escaped = true;
        } else if (escaped) {
            if (!escape()) {
                return false;
            }
            escaped = false;
        } else if (c == '"') {
            nextCharacter();
            return true;
        }
    }

    return error("quoted string", start);
}
 
开发者ID:arccode,项目名称:wechat-pay-sdk,代码行数:22,代码来源:JSONValidator.java

示例7: TextLayout

/**
 * Constructs a <code>TextLayout</code> from an iterator over styled text.
 * <p>
 * The iterator must specify a single paragraph of text because an
 * entire paragraph is required for the bidirectional
 * algorithm.
 * @param text the styled text to display
 * @param frc contains information about a graphics device which is needed
 *       to measure the text correctly.
 *       Text measurements can vary slightly depending on the
 *       device resolution, and attributes such as antialiasing.  This
 *       parameter does not specify a translation between the
 *       <code>TextLayout</code> and user space.
 */
public TextLayout(AttributedCharacterIterator text, FontRenderContext frc) {

    if (text == null) {
        throw new IllegalArgumentException("Null iterator passed to TextLayout constructor.");
    }

    int start = text.getBeginIndex();
    int limit = text.getEndIndex();
    if (start == limit) {
        throw new IllegalArgumentException("Zero length iterator passed to TextLayout constructor.");
    }

    int len = limit - start;
    text.first();
    char[] chars = new char[len];
    int n = 0;
    for (char c = text.first();
         c != CharacterIterator.DONE;
         c = text.next())
    {
        chars[n++] = c;
    }

    text.first();
    if (text.getRunLimit() == limit) {

        Map<? extends Attribute, ?> attributes = text.getAttributes();
        Font font = singleFont(chars, 0, len, attributes);
        if (font != null) {
            fastInit(chars, font, attributes, frc);
            return;
        }
    }

    standardInit(text, chars, frc);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:50,代码来源:TextLayout.java

示例8: string

private boolean string() {
    if (c != '"') return false;
    
    int start = col;
    boolean escaped = false;

    for (nextCharacter(); c != CharacterIterator.DONE; nextCharacter()) {
        if (!escaped && c == '\\') {
            escaped = true;
        } else if (escaped) {
            if (!escape()) {
                return false;
            }
            escaped = false;
        } else if (c == '"') {
            nextCharacter();
            return true;
        }
    }

    return error("quoted string", start);
}
 
开发者ID:1991wangliang,项目名称:pay,代码行数:22,代码来源:JSONValidator.java

示例9: prev

public int prev() {
    char cp2 = iter.previous();
    if (cp2 != CharacterIterator.DONE) {
        if (Character.isLowSurrogate(cp2)) {
            char cp1 = iter.previous();
            if (Character.isHighSurrogate(cp1)) {
                return Character.toCodePoint(cp1, cp2);
            }
            iter.next();
        }
        return cp2;
    }
    return DONE;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:CodePointIterator.java

示例10: getStringUntil

/**
 * Get string from @iter until end of string or until terminator is
 * encountered.
 *
 * @param iter Character iterator.
 */
private static String getStringUntil(CharacterIterator iter, char terminator) {
    StringBuilder sb = new StringBuilder();
    for (char currentChar = iter.current();
            currentChar != CharacterIterator.DONE && currentChar != terminator;
            currentChar = iter.next()) {
        sb.append(currentChar);
    }
    return sb.toString();
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:15,代码来源:LapPath.java

示例11: current

/**
 * @see UCharacterIterator#current()
 */
@Override
public int current() {
    int c = iterator.current();
    if(c==CharacterIterator.DONE){
      return DONE;
    }
    return c;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:11,代码来源:CharacterIteratorWrapper.java

示例12: next

public int next() {
    char cp1 = iter.current();
    if (cp1 != CharacterIterator.DONE) {
        char cp2 = iter.next();
        if (Character.isHighSurrogate(cp1) && cp2 != CharacterIterator.DONE) {
            if (Character.isLowSurrogate(cp2)) {
                iter.next();
                return Character.toCodePoint(cp1, cp2);
            }
        }
        return cp1;
    }
    return DONE;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:CodePointIterator.java

示例13: getNext

/**
 * Returns next character
 */
int getNext() {
    int index = text.getIndex();
    int endIndex = text.getEndIndex();
    if (index == endIndex ||
        (index += getCurrentCodePointCount()) >= endIndex) {
        return CharacterIterator.DONE;
    }
    text.setIndex(index);
    return getCurrent();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:RuleBasedBreakIterator.java

示例14: getText

/**
 * @see UCharacterIterator#getText(char[])
 */
public int getText(char[] fillIn, int offset){
    int length =iterator.getEndIndex() - iterator.getBeginIndex();
    int currentIndex = iterator.getIndex();
    if(offset < 0 || offset + length > fillIn.length){
        throw new IndexOutOfBoundsException(Integer.toString(length));
    }

    for (char ch = iterator.first(); ch != CharacterIterator.DONE; ch = iterator.next()) {
        fillIn[offset++] = ch;
    }
    iterator.setIndex(currentIndex);

    return length;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:CharacterIteratorWrapper.java

示例15: handlePrevious

/**
 * This method backs the iterator back up to a "safe position" in the text.
 * This is a position that we know, without any context, must be a break position.
 * The various calling methods then iterate forward from this safe position to
 * the appropriate position to return.  (For more information, see the description
 * of buildBackwardsStateTable() in RuleBasedBreakIterator.Builder.)
 */
protected int handlePrevious() {
    CharacterIterator text = getText();
    int state = START_STATE;
    int category = 0;
    int lastCategory = 0;
    int c = getCurrent();

    // loop until we reach the beginning of the text or transition to state 0
    while (c != CharacterIterator.DONE && state != STOP_STATE) {

        // save the last character's category and look up the current
        // character's category
        lastCategory = category;
        category = lookupCategory(c);

        // if the current character isn't an ignore character, look up a
        // state transition in the backwards state table
        if (category != IGNORE) {
            state = lookupBackwardState(state, category);
        }

        // then advance one character backwards
        c = getPrevious();
    }

    // if we didn't march off the beginning of the text, we're either one or two
    // positions away from the real break position.  (One because of the call to
    // previous() at the end of the loop above, and another because the character
    // that takes us into the stop state will always be the character BEFORE
    // the break position.)
    if (c != CharacterIterator.DONE) {
        if (lastCategory != IGNORE) {
            getNext();
            getNext();
        }
        else {
            getNext();
        }
    }
    return text.getIndex();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:48,代码来源:RuleBasedBreakIterator.java


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