當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。