Package java.text

Examples of java.text.StringCharacterIterator


            throw new IllegalStateException("setSubtext must be called with a valid value before this method can operate");

        if (text.length() == 0)
            return -1;

        final int index = new StringSearch(pattern, new StringCharacterIterator(text), COLLATOR).first();
        return mode == TextMatcherEditor.STARTS_WITH && index != 0 ? -1 : index;
    }
View Full Code Here


        this.in = in;

        this.linkEater = linkEater;
        this.linkReplacer = null;

        this.replaceLink = new StringCharacterIterator("");
        replaceLink.next();
        if (replaceLink.getIndex() > replaceLink.getEndIndex()) {
            System.out.println("hello");
        }
    }
View Full Code Here

        this.in = in;
        this.baseURL = baseURL;
        this.linkEater = linkEater;
        this.linkReplacer = linkReplacer;

        this.replaceLink = new StringCharacterIterator("");
        replaceLink.next();
    }
View Full Code Here

        return c;
    }

    private void initReplaceLink(String link) {
        if (replaceLink == null) {
            replaceLink = new StringCharacterIterator(link);
        } else {
            replaceLink.setText(link);
        }
    }
View Full Code Here

    private StringCharacterIterator replaceWord;

    public WordParserInputStream(InputStream in, WordEater eater) {
        this.in = in;
        this.eater = eater;
        this.replaceWord = new StringCharacterIterator("");
    }
View Full Code Here

    public WordParserInputStream(InputStream in, WordEater eater, WordReplacer replacer) {
        this.in = in;
        this.eater = eater;
        this.replacer = replacer;
        this.replaceWord = new StringCharacterIterator("");
    }
View Full Code Here

    }

    private static String escape(String s, BiMap charToEscape)
    {
        StringBuffer sb = new StringBuffer();
        StringCharacterIterator it = new StringCharacterIterator(s);
        for (int i = 0; i < it.getEndIndex(); i++)
        {
            it.setIndex(i);
            char c = it.current();
            String escaped = (String) charToEscape.get(new Character(c).toString());
            if (escaped != null)
            {
                sb.append(escaped);
            } else
View Full Code Here

  boolean changedString = false;
  int copyTo = 0;
  // it will always be less than the original
  char[] chars = new char[original.length()];
  StringCharacterIterator iter = new StringCharacterIterator(original);
 
  for(char c = iter.first(); c != CharacterIterator.DONE;
      c = iter.next()) {

      if (c == '&') {
    changedString = true;
    copyTo = base64decode(chars, copyTo, iter);
      } else {
View Full Code Here

      StringBuilder nextValue = new StringBuilder();

      int valueIndex = 0;

      final CharacterIterator it = new StringCharacterIterator(line);
      for (char c = it.first(); c != CharacterIterator.DONE; c = it
          .next()) {
        nextValue.append(c);

        final int valueWidth;
        if (constantWidth) {
View Full Code Here

   * required to encode the string.
   * @param string text to encode
   * @return number of UTF-8 bytes required to encode
   */
  public static int utf8Length(String string) {
    CharacterIterator iter = new StringCharacterIterator(string);
    char ch = iter.first();
    int size = 0;
    while (ch != CharacterIterator.DONE) {
      if ((ch >= 0xD800) && (ch < 0xDC00)) {
        // surrogate pair?
        char trail = iter.next();
        if ((trail > 0xDBFF) && (trail < 0xE000)) {
          // valid pair
          size += 4;
        } else {
          // invalid pair
          size += 3;
          iter.previous(); // rewind one
        }
      } else if (ch < 0x80) {
        size++;
      } else if (ch < 0x800) {
        size += 2;
      } else {
        // ch < 0x10000, that is, the largest char value
        size += 3;
      }
      ch = iter.next();
    }
    return size;
  }
View Full Code Here

TOP

Related Classes of java.text.StringCharacterIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.