Package java.text

Examples of java.text.StringCharacterIterator.current()


      // empty
    }
    assertEquals("fixture".length(), fixture.getIndex());
    fixture.setIndex(0);
    assertEquals(0, fixture.getIndex());
    assertEquals('f', fixture.current());
    fixture.setIndex("fixture".length() - 1);
    assertEquals('e', fixture.current());
    try {
      fixture.setIndex(-1);
      fail("no illegal argument");
View Full Code Here


    assertEquals("fixture".length(), fixture.getIndex());
    fixture.setIndex(0);
    assertEquals(0, fixture.getIndex());
    assertEquals('f', fixture.current());
    fixture.setIndex("fixture".length() - 1);
    assertEquals('e', fixture.current());
    try {
      fixture.setIndex(-1);
      fail("no illegal argument");
    } catch (IllegalArgumentException e) {
      // expected
View Full Code Here

   * @tests java.text.StringCharacterIterator.setText(String)
   */
  public void test_setText() {
    StringCharacterIterator fixture = new StringCharacterIterator("fixture");
    fixture.setText("fix");
    assertEquals('f', fixture.current());
    assertEquals('x', fixture.last());

    try {
      fixture.setText(null);
      fail("no null pointer");
View Full Code Here

       
        StringCharacterIterator it = new StringCharacterIterator("testing");
    assertEquals("Wrong begin index", 0, it.getBeginIndex());
    assertEquals("Wrong end index", 7, it.getEndIndex());
    assertEquals("Wrong current index", 0, it.getIndex());
    assertEquals("Wrong current char", 't', it.current());
    assertEquals("Wrong next char", 'e', it.next());
    }

    /**
     * @tests java.text.StringCharacterIterator#StringCharacterIterator(java.lang.String,
View Full Code Here

    public void test_ConstructorLjava_lang_StringI() {
        StringCharacterIterator it = new StringCharacterIterator("testing", 3);
    assertEquals("Wrong begin index", 0, it.getBeginIndex());
    assertEquals("Wrong end index", 7, it.getEndIndex());
    assertEquals("Wrong current index", 3, it.getIndex());
    assertEquals("Wrong current char", 't', it.current());
    assertEquals("Wrong next char", 'i', it.next());
    }

    /**
     * @tests java.text.StringCharacterIterator#StringCharacterIterator(java.lang.String,
View Full Code Here

        StringCharacterIterator it = new StringCharacterIterator("testing", 2,
                6, 4);
    assertEquals("Wrong begin index", 2, it.getBeginIndex());
    assertEquals("Wrong end index", 6, it.getEndIndex());
    assertEquals("Wrong current index", 4, it.getIndex());
    assertEquals("Wrong current char", 'i', it.current());
    assertEquals("Wrong next char", 'n', it.next());
    }

    /**
     * @tests java.text.StringCharacterIterator#getIndex()
View Full Code Here

     * Note that JSTL's {@code <c:out>} escapes the exact same set of characters as this method.
     */
    public static String escapeCharsForXML(String aText) {
        final StringBuilder result = new StringBuilder();
        final StringCharacterIterator iterator = new StringCharacterIterator(aText);
        char character = iterator.current();
        while (character != CharacterIterator.DONE) {
            if (character == '<') {
                result.append("&lt;");
            }
            else if (character == '>') {
View Full Code Here

{

    public static String decode(String source) throws IllegalArgumentException {
        StringBuffer result = new StringBuffer();
        StringCharacterIterator sci = new StringCharacterIterator(source);
        for (char c = sci.current(); c != CharacterIterator.DONE; c = sci.next()) {
            if (c == '$') {
                c = sci.next();
                if (c != CharacterIterator.DONE) {
                    if (c == '$') {
                        result.append('$');
View Full Code Here

    }

    public static String encode(String source) {
        StringBuffer result = new StringBuffer();
        StringCharacterIterator sci = new StringCharacterIterator(source);
        for (char c = sci.current(); c != CharacterIterator.DONE; c = sci.next()) {
            if (c == '$') {
                result.append("$$");
            }
            else if (c == ',') {
                result.append("$k");
View Full Code Here

  public static synchronized String escapeForRegExp(String aRegexFragment) {
    final StringBuilder result = new StringBuilder();

    final StringCharacterIterator iterator = new StringCharacterIterator(aRegexFragment);
    char character = iterator.current();
    while (character != CharacterIterator.DONE) {
      /*
       * All literals need to have backslashes doubled.
       */
      if (character == '.') {
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.