Package batch.internal

Examples of batch.internal.FieldSet


    }
    String[] result = tokenizer.tokenize(line);
    for (int i = 0; i < result.length; i++) {
      result[i] = result[i].trim();
    }
    return new FieldSet(result);
  }
View Full Code Here


  public void testRead() throws Exception {
    Resource resource = new InputStreamResource(
        new ByteArrayInputStream("foo,bar,spam\nbucket,crap,man".getBytes()));
    ResourceFieldSetReader reader = new ResourceFieldSetReader(resource);
    int count = 0;
    FieldSet fieldSet;
    while ((fieldSet = reader.read()) != null) {
      count++;
      assertNotNull(fieldSet);
      assertEquals(3, fieldSet.getFieldCount());
    }
    assertEquals(2, count);
  }
View Full Code Here

  public void testDelimiter() throws Exception {
    Resource resource = new InputStreamResource(new ByteArrayInputStream("foo.bar.spam".getBytes()));
    ResourceFieldSetReader reader = new ResourceFieldSetReader(resource, '.');
    int count = 0;
    FieldSet fieldSet;
    while ((fieldSet = reader.read()) != null) {
      count++;
      assertNotNull(fieldSet);
      assertEquals(3, fieldSet.getFieldCount());
      assertEquals("foo", fieldSet.readString(0));
    }
    assertEquals(1, count);
  }
View Full Code Here

  }

  public void testWhitespace() throws Exception {
    Resource resource = new InputStreamResource(new ByteArrayInputStream(" foo ,bar,spam".getBytes()));
    ResourceFieldSetReader reader = new ResourceFieldSetReader(resource);
    FieldSet fieldSet = reader.read();
    assertNotNull(fieldSet);
    assertEquals("foo", fieldSet.readString(0));
  }
View Full Code Here

  }

  public void testQuotes() throws Exception {
    Resource resource = new InputStreamResource(new ByteArrayInputStream("\" foo \",bar,\"spam\"".getBytes()));
    ResourceFieldSetReader reader = new ResourceFieldSetReader(resource);
    FieldSet fieldSet = reader.read();
    assertNotNull(fieldSet);
    // TODO: maybe this should be with the whitespace still?
    assertEquals("foo", fieldSet.readString(0));
    assertEquals("spam", fieldSet.readString(2));
  }
View Full Code Here

  }

  public void testMultiLineField() throws Exception {
    Resource resource = new InputStreamResource(new ByteArrayInputStream("foo,bar,\"s\npam\"".getBytes()));
    ResourceFieldSetReader reader = new ResourceFieldSetReader(resource);
    FieldSet fieldSet = reader.read();
    assertNotNull(fieldSet);
    assertEquals("foo", fieldSet.readString(0));
    System.err.println(fieldSet);
    assertEquals("s\npam", fieldSet.readString(2));
  }
View Full Code Here

TOP

Related Classes of batch.internal.FieldSet

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.