Java Code Examples for java.text.CharacterIterator

The following are top voted examples for showing how to use java.text.CharacterIterator. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Reer   File: StartScriptTemplateBindingFactory.java   View source code 6 votes vote down vote up
private String escapeWindowsJvmOpt(String jvmOpts) {
    boolean wasOnBackslash = false;
    StringBuilder escapedJvmOpt = new StringBuilder();
    CharacterIterator it = new StringCharacterIterator(jvmOpts);

    //argument quoting:
    // - " must be encoded as \"
    // - % must be encoded as %%
    // - pathological case: \" must be encoded as \\\", but other than that, \ MUST NOT be quoted
    // - other characters (including ') will not be quoted
    // - use a state machine rather than regexps
    for (char ch = it.first(); ch != CharacterIterator.DONE; ch = it.next()) {
        String repl = Character.toString(ch);

        if (ch == '%') {
            repl = "%%";
        } else if (ch == '"') {
            repl = (wasOnBackslash ? '\\' : "") + "\\\"";
        }
        wasOnBackslash = ch == '\\';
        escapedJvmOpt.append(repl);
    }

    return escapedJvmOpt.toString();
}
 
Example 2
Project: NiuBi   File: Json.java   View source code 6 votes vote down vote up
private void skipWhiteSpace() {
    do {
        if (Character.isWhitespace(c))
            ;
        else if (c == '/') {
            next();
            if (c == '*') {
                // skip multiline comments
                while (c != CharacterIterator.DONE)
                    if (next() == '*' && next() == '/')
                        break;
                if (c == CharacterIterator.DONE)
                    throw new MalformedJsonException("Unterminated comment while parsing JSON string.");
            } else if (c == '/')
                while (c != '\n' && c != CharacterIterator.DONE)
                    next();
            else {
                previous();
                break;
            }
        } else
            break;
    } while (next() != CharacterIterator.DONE);
}
 
Example 3
Project: Maxine-VM   File: StringUtil.java   View source code 6 votes vote down vote up
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;
}
 
Example 4
Project: Maxine-VM   File: StringUtil.java   View source code 6 votes vote down vote up
public static int readIntegerValue(CharacterIterator i) {
    char ch = i.current();
    if (ch == '-') {
        return readDecimalValue(i, 10);
    }
    if (ch == '0') {
        ch = i.next();
        if (ch == 'x' || ch == 'X') {
            i.next();
            return readHexValue(i, 8);
        } else if (ch == 'b' || ch == 'B') {
            i.next();
            return readBinaryValue(i, 32);
        } else {
            return readOctalValue(i, 11);
        }
    }
    return readDecimalValue(i, 10);
}
 
Example 5
Project: openjdk-jdk10   File: WhitespaceBasedBreakIterator.java   View source code 6 votes vote down vote up
/**
 * 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);
}
 
Example 6
Project: jdk8u-jdk   File: DictionaryBasedBreakIterator.java   View source code 6 votes vote down vote up
/**
 * Advances the iterator one step backwards.
 * @return The position of the last boundary position before the
 * current iteration position
 */
@Override
public int previous() {
    CharacterIterator text = getText();

    // if we have cached break positions and we're still in the range
    // covered by them, just move one step backward in the cache
    if (cachedBreakPositions != null && positionInCache > 0) {
        --positionInCache;
        text.setIndex(cachedBreakPositions[positionInCache]);
        return cachedBreakPositions[positionInCache];
    }

    // otherwise, dump the cache and use the inherited previous() method to move
    // backward.  This may fill up the cache with new break positions, in which
    // case we have to mark our position in the cache
    else {
        cachedBreakPositions = null;
        int result = super.previous();
        if (cachedBreakPositions != null) {
            positionInCache = cachedBreakPositions.length - 2;
        }
        return result;
    }
}
 
Example 7
Project: framework   File: JSONValidator.java   View source code 6 votes vote down vote up
private boolean valid(String input) {
	if ("".equals(input)) return true;

	boolean ret = true;
	it = new StringCharacterIterator(input);
	c = it.first();
	col = 1;
	if (!value()) {
		ret = error("value", 1);
	} else {
		skipWhiteSpace();
		if (c != CharacterIterator.DONE) {
			ret = error("end", col);
		}
	}

	return ret;
}
 
Example 8
Project: framework   File: JSONValidator.java   View source code 6 votes vote down vote up
private boolean literal(String text) {
	CharacterIterator ci = new StringCharacterIterator(text);
	char t = ci.first();
	if (c != t) return false;

	int start = col;
	boolean ret = true;
	for (t = ci.next(); t != CharacterIterator.DONE; t = ci.next()) {
		if (t != nextCharacter()) {
			ret = false;
			break;
		}
	}
	nextCharacter();

	if (!ret) error("literal " + text, start);
	return ret;
}
 
Example 9
Project: framework   File: JSONValidator.java   View source code 6 votes vote down vote up
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);
}
 
Example 10
Project: jdk8u-jdk   File: RuleBasedBreakIterator.java   View source code 6 votes vote down vote up
/**
 * Returns true if the specified position is a boundary position.  As a side
 * effect, leaves the iterator pointing to the first boundary position at
 * or after "offset".
 * @param offset the offset to check.
 * @return True if "offset" is a boundary position.
 */
@Override
public boolean isBoundary(int offset) {
    CharacterIterator text = getText();
    checkOffset(offset, text);
    if (offset == text.getBeginIndex()) {
        return true;
    }

    // to check whether this is a boundary, we can use following() on the
    // position before the specified one and return true if the position we
    // get back is the one the user specified
    else {
        return following(offset - 1) == offset;
    }
}
 
Example 11
Project: wechat-pay-sdk   File: JSONValidator.java   View source code 6 votes vote down vote up
private boolean valid(String input) {
    if ("".equals(input)) return true;

    boolean ret = true;
    it = new StringCharacterIterator(input);
    c = it.first();
    col = 1;
    if (!value()) {
        ret = error("value", 1);
    } else {
        skipWhiteSpace();
        if (c != CharacterIterator.DONE) {
            ret = error("end", col);
        }
    }

    return ret;
}
 
Example 12
Project: wechat-pay-sdk   File: JSONValidator.java   View source code 6 votes vote down vote up
private boolean literal(String text) {
    CharacterIterator ci = new StringCharacterIterator(text);
    char t = ci.first();
    if (c != t) return false;

    int start = col;
    boolean ret = true;
    for (t = ci.next(); t != CharacterIterator.DONE; t = ci.next()) {
        if (t != nextCharacter()) {
            ret = false;
            break;
        }
    }
    nextCharacter();

    if (!ret) error("literal " + text, start);
    return ret;
}
 
Example 13
Project: wechat-pay-sdk   File: JSONValidator.java   View source code 6 votes vote down vote up
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);
}
 
Example 14
Project: MaxSim   File: StringUtil.java   View source code 6 votes vote down vote up
public static int readIntegerValue(CharacterIterator i) {
    char ch = i.current();
    if (ch == '-') {
        return readDecimalValue(i, 10);
    }
    if (ch == '0') {
        ch = i.next();
        if (ch == 'x' || ch == 'X') {
            i.next();
            return readHexValue(i, 8);
        } else if (ch == 'b' || ch == 'B') {
            i.next();
            return readBinaryValue(i, 32);
        } else {
            return readOctalValue(i, 11);
        }
    }
    return readDecimalValue(i, 10);
}
 
Example 15
Project: vexillo   File: Base64InputStream.java   View source code 6 votes vote down vote up
private void readWord() throws IOException {
	for (;;) {
		int c = -1;
		if (ci != null) { c = ci.current(); ci.next(); }
		if (in != null) { c = in.read(); }
		if (c < 0 || c == '=' || c == CharacterIterator.DONE) {
			padWord();
			eof = true;
			return;
		}
		c = b64d(c);
		if (c >= 0) {
			word <<= 6;
			word |= c;
			count++;
			if (count > 3) {
				count = 3;
				return;
			}
		}
	}
}
 
Example 16
Project: MaxSim   File: StringUtil.java   View source code 6 votes vote down vote up
public static String readDecimalString(CharacterIterator i, int maxchars) {
    final StringBuffer buf = new StringBuffer();

    if (peekAndEat(i, '-')) {
        buf.append('-');
    }

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

        if (!Character.isDigit(c)) {
            break;
        }

        buf.append(c);
        i.next();
    }

    return buf.toString();
}
 
Example 17
Project: fitnotifications   File: ScientificNumberFormatter.java   View source code 6 votes vote down vote up
@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();
}
 
Example 18
Project: fitnotifications   File: StringSearch.java   View source code 6 votes vote down vote up
/**
 * Sets the {@link RuleBasedCollator} to be used for language-specific searching.
 * <p>
 * The iterator's position will not be changed by this method.
 * @param collator to use for this <tt>StringSearch</tt>
 * @throws IllegalArgumentException thrown when collator is null
 * @see #getCollator
 * @stable ICU 2.0
 */
public void setCollator(RuleBasedCollator collator) {
    if (collator == null) {
        throw new IllegalArgumentException("Collator can not be null");
    }
    collator_ = collator;
    ceMask_ = getMask(collator_.getStrength());

    ULocale collLocale = collator.getLocale(ULocale.VALID_LOCALE);
    search_.internalBreakIter_ = BreakIterator.getCharacterInstance(collLocale == null ? ULocale.ROOT : collLocale);
    search_.internalBreakIter_.setText((CharacterIterator)search_.text().clone());  // We need to create a clone

    toShift_ = collator.isAlternateHandlingShifted();
    variableTop_ = collator.getVariableTop();
    textIter_ = new CollationElementIterator(pattern_.text_, collator);
    utilIter_ = new CollationElementIterator(pattern_.text_, collator);

    // initialize() _after_ setting the iterators for the new collator.
    initialize();
}
 
Example 19
Project: OpenJSharp   File: BMPattern.java   View source code 6 votes vote down vote up
int matchesIgnoreCase(CharacterIterator iterator, int start, int limit) {
    int plength = this.pattern.length;
    if (plength == 0)  return start;
    int index = start+plength;
    while (index <= limit) {
        int pindex = plength;
        int nindex = index+1;
        char ch;
        do {
            char ch1 = ch = iterator.setIndex(--index);
            char ch2 = this.pattern[--pindex];
            if (ch1 != ch2) {
                ch1 = Character.toUpperCase(ch1);
                ch2 = Character.toUpperCase(ch2);
                if (ch1 != ch2 && Character.toLowerCase(ch1) != Character.toLowerCase(ch2))
                    break;
            }
            if (pindex == 0)
                return index;
        } while (pindex > 0);
        index += this.shiftTable[ch % this.shiftTable.length]+1;
        if (index < nindex)  index = nindex;
    }
    return -1;
}
 
Example 20
Project: pay   File: JSONValidator.java   View source code 6 votes vote down vote up
private boolean valid(String input) {
    if ("".equals(input)) return true;
    
    boolean ret = true;
    it = new StringCharacterIterator(input);
    c = it.first();
    col = 1;
    if (!value()) {
        ret = error("value", 1);
    } else {
        skipWhiteSpace();
        if (c != CharacterIterator.DONE) {
            ret = error("end", col);
        }
    }
    
    return ret;
}
 
Example 21
Project: OpenJSharp   File: RuleBasedBreakIterator.java   View source code 6 votes vote down vote up
/**
 * Returns true if the specified position is a boundary position.  As a side
 * effect, leaves the iterator pointing to the first boundary position at
 * or after "offset".
 * @param offset the offset to check.
 * @return True if "offset" is a boundary position.
 */
@Override
public boolean isBoundary(int offset) {
    CharacterIterator text = getText();
    checkOffset(offset, text);
    if (offset == text.getBeginIndex()) {
        return true;
    }

    // to check whether this is a boundary, we can use following() on the
    // position before the specified one and return true if the position we
    // get back is the one the user specified
    else {
        return following(offset - 1) == offset;
    }
}
 
Example 22
Project: openjdk-jdk10   File: AttributedStringTest.java   View source code 6 votes vote down vote up
private static final void checkIteratorSubranges(AttributedCharacterIterator iterator, int[] expectedLimits) throws Exception {
    int previous = 0;
    char c = iterator.first();
    for (int i = 0; i < expectedLimits.length; i++) {
         if (iterator.getRunStart() != previous || iterator.getRunLimit() != expectedLimits[i]) {
             throwException(iterator, "run boundaries are not as expected: " + iterator.getRunStart() + ", " + iterator.getRunLimit());
         }
         previous = expectedLimits[i];
         c = iterator.setIndex(previous);
    }
    if (c != CharacterIterator.DONE) {
        throwException(iterator, "iterator's run sequence doesn't end with DONE");
    }
}
 
Example 23
Project: openjdk-jdk10   File: RuleBasedBreakIterator.java   View source code 6 votes vote down vote up
/**
 * Returns true if the specified position is a boundary position.  As a side
 * effect, leaves the iterator pointing to the first boundary position at
 * or after "offset".
 * @param offset the offset to check.
 * @return True if "offset" is a boundary position.
 */
@Override
public boolean isBoundary(int offset) {
    CharacterIterator text = getText();
    checkOffset(offset, text);
    if (offset == text.getBeginIndex()) {
        return true;
    }

    // to check whether this is a boundary, we can use following() on the
    // position before the specified one and return true if the position we
    // get back is the one the user specified
    else {
        return following(offset - 1) == offset;
    }
}
 
Example 24
Project: MaxSim   File: StringUtil.java   View source code 6 votes vote down vote up
public static int readDecimalValue(CharacterIterator i, int maxchars) {
    final StringBuffer buf = new StringBuffer();

    if (peekAndEat(i, '-')) {
        buf.append('-');
    }

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

        if (!Character.isDigit(c)) {
            break;
        }

        buf.append(c);
        i.next();
    }

    return Integer.parseInt(buf.toString());
}
 
Example 25
Project: openjdk-jdk10   File: BMPattern.java   View source code 6 votes vote down vote up
/**
 *
 * @return -1 if <var>iterator</var> does not contain this pattern.
 */
public int matches(CharacterIterator iterator, int start, int limit) {
    if (this.ignoreCase)  return this.matchesIgnoreCase(iterator, start, limit);
    int plength = this.pattern.length;
    if (plength == 0)  return start;
    int index = start+plength;
    while (index <= limit) {
        int pindex = plength;
        int nindex = index+1;
        char ch;
        do {
            if ((ch = iterator.setIndex(--index)) != this.pattern[--pindex])
                break;
            if (pindex == 0)
                return index;
        } while (pindex > 0);
        index += this.shiftTable[ch % this.shiftTable.length]+1;
        if (index < nindex)  index = nindex;
    }
    return -1;
}
 
Example 26
Project: fitnotifications   File: CharacterIteratorWrapper.java   View source code 6 votes vote down vote up
/**
 * @see UCharacterIterator#getText(char[])
 */
@Override
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;
}
 
Example 27
Project: openjdk-jdk10   File: Font.java   View source code 6 votes vote down vote up
/**
 * Indicates whether or not this {@code Font} can display the
 * text specified by the {@code iter} starting at
 * {@code start} and ending at {@code limit}.
 *
 * @param iter  a {@link CharacterIterator} object
 * @param start the specified starting offset into the specified
 *              {@code CharacterIterator}.
 * @param limit the specified ending offset into the specified
 *              {@code CharacterIterator}.
 * @return an offset into {@code iter} that points
 *          to the first character in {@code iter} that this
 *          {@code Font} cannot display; or {@code -1} if
 *          this {@code Font} can display all characters in
 *          {@code iter}.
 * @since 1.2
 */
public int canDisplayUpTo(CharacterIterator iter, int start, int limit) {
    Font2D font2d = getFont2D();
    char c = iter.setIndex(start);
    for (int i = start; i < limit; i++, c = iter.next()) {
        if (font2d.canDisplay(c)) {
            continue;
        }
        if (!Character.isHighSurrogate(c)) {
            return i;
        }
        char c2 = iter.next();
        // c2 could be CharacterIterator.DONE which is not a low surrogate.
        if (!Character.isLowSurrogate(c2)) {
            return i;
        }
        if (!font2d.canDisplay(Character.toCodePoint(c, c2))) {
            return i;
        }
        i++;
    }
    return -1;
}
 
Example 28
Project: openjdk-jdk10   File: CodePointIterator.java   View source code 5 votes vote down vote up
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;
}
 
Example 29
Project: fort_j   File: Strings.java   View source code 5 votes vote down vote up
/**
* Return <tt>aText</tt> with all <tt>'<'</tt> and <tt>'>'</tt> characters
* replaced by their escaped equivalents.
*/
@ApiMethod
@Comment(value = "Return text with all '<' and '>' characters replaced by their escaped equivalents.")
public static String toDisableTags(String text)
{
   final StringBuilder result = new StringBuilder();
   final StringCharacterIterator iterator = new StringCharacterIterator(text);
   char character = iterator.current();
   while (character != CharacterIterator.DONE)
   {
      if (character == '<')
      {
         result.append("&lt;");
      }
      else if (character == '>')
      {
         result.append("&gt;");
      }
      else
      {
         //the char is not a special one
         //add it to the result as is
         result.append(character);
      }
      character = iterator.next();
   }
   return result.toString();
}
 
Example 30
Project: OpenJSharp   File: CharacterIteratorWrapper.java   View source code 5 votes vote down vote up
/**
 * @see UCharacterIterator#previous()
 */
public int previous() {
    int i = iterator.previous();
    if(i==CharacterIterator.DONE){
        return DONE;
    }
    return i;
}
 
Example 31
Project: OpenJSharp   File: TextConstructionTests.java   View source code 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    TCContext tcctx = (TCContext)ctx;
    final Font font = tcctx.font;
    final CharacterIterator ci = tcctx.ci;
    final FontRenderContext frc = tcctx.frc;
    GlyphVector gv;
    do {
        gv = font.createGlyphVector(frc, ci);
    } while (--numReps >= 0);
}
 
Example 32
Project: alipay-sdk   File: JSONReader.java   View source code 5 votes vote down vote up
public Object read(CharacterIterator ci, int start) {
    it = ci;
    switch (start) {
    case FIRST:
        c = it.first();
        break;
    case CURRENT:
        c = it.current();
        break;
    case NEXT:
        c = it.next();
        break;
    }
    return read();
}
 
Example 33
Project: OpenJSharp   File: CharacterIteratorWrapper.java   View source code 5 votes vote down vote up
/**
 * Creates a clone of this iterator.  Clones the underlying character iterator.
 * @see UCharacterIterator#clone()
 */
public Object clone(){
    try {
        CharacterIteratorWrapper result = (CharacterIteratorWrapper) super.clone();
        result.iterator = (CharacterIterator)this.iterator.clone();
        return result;
    } catch (CloneNotSupportedException e) {
        return null; // only invoked if bad underlying character iterator
    }
}
 
Example 34
Project: Maxine-VM   File: StringUtil.java   View source code 5 votes vote down vote up
public static boolean peekAndEat(CharacterIterator i, char c) {
    final char r = i.current();
    if (r == c) {
        i.next();
        return true;
    }
    return false;
}
 
Example 35
Project: openjdk-jdk10   File: RuleBasedBreakIterator.java   View source code 5 votes vote down vote up
@Override
public Object clone() {

    SafeCharIterator copy = null;
    try {
        copy = (SafeCharIterator) super.clone();
    }
    catch(CloneNotSupportedException e) {
        throw new Error("Clone not supported: " + e);
    }

    CharacterIterator copyOfBase = (CharacterIterator) base.clone();
    copy.base = copyOfBase;
    return copy;
}
 
Example 36
Project: Pogamut3   File: LapPath.java   View source code 5 votes vote down vote up
/**
 * 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();
}
 
Example 37
Project: MaxSim   File: StringUtil.java   View source code 5 votes vote down vote up
public static void skipWhiteSpace(CharacterIterator i) {
    while (true) {
        final char c = i.current();
        if (c != ' ' && c != '\n' && c != '\t') {
            break;
        }
        i.next();
    }
}
 
Example 38
Project: jdk8u-jdk   File: CharacterIteratorWrapper.java   View source code 5 votes vote down vote up
/**
 * Creates a clone of this iterator.  Clones the underlying character iterator.
 * @see UCharacterIterator#clone()
 */
public Object clone(){
    try {
        CharacterIteratorWrapper result = (CharacterIteratorWrapper) super.clone();
        result.iterator = (CharacterIterator)this.iterator.clone();
        return result;
    } catch (CloneNotSupportedException e) {
        return null; // only invoked if bad underlying character iterator
    }
}
 
Example 39
Project: jdk8u-jdk   File: TextConstructionTests.java   View source code 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    TCContext tcctx = (TCContext)ctx;
    final Font font = tcctx.font;
    final CharacterIterator ci = tcctx.ci;
    final FontRenderContext frc = tcctx.frc;
    GlyphVector gv;
    do {
        gv = font.createGlyphVector(frc, ci);
    } while (--numReps >= 0);
}
 
Example 40
Project: wechat-pay-sdk   File: JSONReader.java   View source code 5 votes vote down vote up
public Object read(CharacterIterator ci, int start) {
    it = ci;
    switch (start) {
        case FIRST:
            c = it.first();
            break;
        case CURRENT:
            c = it.current();
            break;
        case NEXT:
            c = it.next();
            break;
    }
    return read();
}