Package com.googlecode.jumpnevolve.util

Examples of com.googlecode.jumpnevolve.util.LineParser


                                  // sollte
        + "786   ,zdhfjs\n";
    StringReader reader = new StringReader(test);

    // Die geparsten Werte prüfen
    new LineParser("([0-9]+)\\s*,\\s*([a-z]+)", new LineAdapter() {
      public boolean lineParsed(String line, String[] parts) {
        i++;

        assertThat(parts.length, is(2));

        if (i == 1) {
          assertThat(line, is(equalTo("123,abc")));
          assertThat(parts[0], is(equalTo("123")));
          assertThat(parts[1], is(equalTo("abc")));
        } else if (i == 2) {
          assertThat(line, is(equalTo("983, def")));
          assertThat(parts[0], is(equalTo("983")));
          assertThat(parts[1], is(equalTo("def")));
        } else if (i == 3) {
          assertThat(line, is(equalTo("786   ,zdhfjs")));
          assertThat(parts[0], is(equalTo("786")));
          assertThat(parts[1], is(equalTo("zdhfjs")));
        }

        return true;
      }
    }).parse(reader);
    assertThat(i, is(3));

    // Es wird ein Fehler erwartet, da die Syntax nicht mit der Eingabe
    // übereinstimmt.
    try {
      LineParser parser = new LineParser("([0-9]+)");
      parser.parse(new StringReader(test), new LineAdapter());
      throw new AssertionError("The test should not reach this point.");
    } catch (LineFailedException expected) {
    }
  }
View Full Code Here

TOP

Related Classes of com.googlecode.jumpnevolve.util.LineParser

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.