Package org.kitesdk.morphline.shaded.com.googlecode.jcsv.fastreader

Examples of org.kitesdk.morphline.shaded.com.googlecode.jcsv.fastreader.CSVTokenizer


    split(Lists.newArrayList(), "", '|', false, false);
    split(Arrays.asList("x"), "x", '|', false, false);
    split(Arrays.asList(null,"x"), "|x", '|', false, false);
   
    Record record = new Record();
    CSVTokenizer tokenizer = new SimpleCSVTokenizer(',', true, true, new ArrayList<String>());
    tokenizer.tokenizeLine(" x ", null, record);
    assertEquals(Arrays.asList("x"), record.get("column0"));
  }
View Full Code Here


    assertEquals(Arrays.asList("x"), record.get("column0"));
  }
 
  private void split(List expected, String line, char separator, boolean isQuoted, boolean addEmptyStrings) throws IOException {
    Record record = new Record();
    CSVTokenizer tokenizer;
    if (isQuoted) {
      tokenizer = new QuotedCSVTokenizer(separator, false, addEmptyStrings, new ArrayList<String>(), 1000, false, '"');
      tokenizer.tokenizeLine(line, new BufferedReader(new StringReader("")), record);     
    } else {
      tokenizer = new SimpleCSVTokenizer(separator, false, addEmptyStrings, new ArrayList<String>());
      tokenizer.tokenizeLine(line, null, record);
    }
    for (int i = 0; i < expected.size(); i++) {
      assertEquals(expected.get(i), record.getFirstValue("column" + i));
    }
    assertTrue(record.getFields().asMap().size() <= expected.size());
View Full Code Here

  @Test(expected=IllegalArgumentException.class)
  public void testThrowExceptionIfRecordTooLong() throws Exception {
    boolean ignoreTooLongRecords = false;
    int maxCharactersPerRecord = 10;
    CSVTokenizer tokenizer = new QuotedCSVTokenizer(
        ',', false, false, new ArrayList<String>(), maxCharactersPerRecord, ignoreTooLongRecords, '"');
    tokenizer.tokenizeLine(
        "\"",
        new BufferedReader(new StringReader("line tooooooooo long\"")),
        new Record());
  }
View Full Code Here

  @Test
  public void testIgnoreRecordTooLong() throws Exception {
    boolean ignoreTooLongRecords = true;
    int maxCharactersPerRecord = 10;
    CSVTokenizer tokenizer = new QuotedCSVTokenizer(
        ',', false, false, new ArrayList<String>(), maxCharactersPerRecord, ignoreTooLongRecords, '"');
    assertFalse(tokenizer.tokenizeLine(
        "\"",
        new BufferedReader(new StringReader("line tooooooooo long\"")),
        new Record()));
  }
View Full Code Here

TOP

Related Classes of org.kitesdk.morphline.shaded.com.googlecode.jcsv.fastreader.CSVTokenizer

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.