Package java.text

Examples of java.text.StringCharacterIterator.previous()


        int i = 0;
        while (i != -1) {
            i = s.indexOf(marker, i);
            if (i != -1) {
                sci.setIndex(i);
                char c1 = sci.previous();
                sci.setIndex(i);
                char c2 = sci.next();
                boolean isQuote = (c1 == '\'') && (c2 == '\'');
                boolean isSpace = Character.isWhitespace(c2);
                if (!isQuote && !isSpace && (c2 != CharacterIterator.DONE)) {
View Full Code Here


    */
   public static String truncate(int maxChars, String s) {
      if (maxChars < 0 || s == null || s.length() <= maxChars)
         return s;
      StringCharacterIterator stringIterator = new StringCharacterIterator(s, maxChars);
      for (char c = stringIterator.current(); c != CharacterIterator.DONE; c = stringIterator.previous()) {
         if (!Character.isLetterOrDigit(c)) {
            return s.substring(0, stringIterator.getIndex());
         }
      }
      // we didn't find a non-LetterOrDigit character prior to maxChars
View Full Code Here

          // valid pair
          size += 4;
        } else {
          // invalid pair
          size += 3;
          iter.previous(); // rewind one
        }
      } else if (ch < 0x80) {
        size++;
      } else if (ch < 0x800) {
        size += 2;
View Full Code Here

      c = iter.next();
    }
    int start_offset = iter.getIndex();
    c = iter.last();
    while (c != iter.DONE && Character.isWhitespace(c)) {
      c = iter.previous();
    }
    int end_offset = iter.getIndex();
    if (end_offset <= start_offset) {
      return "";
    }
View Full Code Here

          // valid pair
          size += 4;
        } else {
          // invalid pair
          size += 3;
          iter.previous(); // rewind one
        }
      } else if (ch < 0x80) {
        size++;
      } else if (ch < 0x800) {
        size += 2;
View Full Code Here

          // valid pair
          size += 4;
        } else {
          // invalid pair
          size += 3;
          iter.previous(); // rewind one
        }
      } else if (ch < 0x80) {
        size++;
      } else if (ch < 0x800) {
        size += 2;
View Full Code Here

          // valid pair
          size += 4;
        } else {
          // invalid pair
          size += 3;
          iter.previous(); // rewind one
        }
      } else if (ch < 0x80) {
        size++;
      } else if (ch < 0x800) {
        size += 2;
View Full Code Here

       
        while(movesIndex<moves.length()) {
            m=moves.charAt(movesIndex++);
            if(m=='-') {
                c1=wrap_ci.previous();
                c2=ci.previous();
            } else if(m=='0') {
                c1=wrap_ci.current();
                c2=ci.current();
            } else  {// m=='+'
                c1=wrap_ci.next();
View Full Code Here

  /**
   * @tests java.text.StringCharacterIterator.previous()
   */
  public void test_previous() {
    StringCharacterIterator fixture = new StringCharacterIterator("fixture");
    assertEquals(CharacterIterator.DONE, fixture.previous());
    assertEquals('i', fixture.next());
    assertEquals('x', fixture.next());
    assertEquals('t', fixture.next());
    assertEquals('u', fixture.next());
    assertEquals('r', fixture.next());
View Full Code Here

    assertEquals('e', fixture.next());
    assertEquals(CharacterIterator.DONE, fixture.next());
    assertEquals(CharacterIterator.DONE, fixture.next());
    assertEquals(CharacterIterator.DONE, fixture.next());
    assertEquals(7, fixture.getIndex());
    assertEquals('e', fixture.previous());
    assertEquals(6, fixture.getIndex());
    assertEquals('r', fixture.previous());
    assertEquals(5, fixture.getIndex());
    assertEquals('u', fixture.previous());
    assertEquals(4, fixture.getIndex());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.