Package org.springframework.batch.item.file.transform

Examples of org.springframework.batch.item.file.transform.DefaultFieldSet


    mapper.setBeanFactory(context);
    context.getBeanFactory().registerSingleton("bean", testNestedA);
    mapper.setDistanceLimit(2);
    mapper.setPrototypeBeanName("bean");

    FieldSet fieldSet = new DefaultFieldSet(new String[] { "Another dummy", "2" }, new String[] {
        "TestObjectB.ValueA", "TestObjectB.TestObjectC.Value" });

    TestNestedA result = mapper.mapFieldSet(fieldSet);

    assertEquals("Another dummy", result.getTestObjectB().getValueA());
View Full Code Here


    StaticApplicationContext context = new StaticApplicationContext();
    mapper.setBeanFactory(context);
    context.getBeanFactory().registerSingleton("bean", testNestedA);
    mapper.setPrototypeBeanName("bean");

    FieldSet fieldSet = new DefaultFieldSet(new String[] { "Another dummy" }, new String[] { "TestObjectB.foo" });

    try {
      mapper.mapFieldSet(fieldSet);
      fail("Expected NotWritablePropertyException");
    }
View Full Code Here

    StaticApplicationContext context = new StaticApplicationContext();
    mapper.setBeanFactory(context);
    context.getBeanFactory().registerSingleton("bean", testNestedA);
    mapper.setPrototypeBeanName("bean");

    FieldSet fieldSet = new DefaultFieldSet(new String[] { "2" }, new String[] { "TestObjectA.garbage" });

    try {
      mapper.mapFieldSet(fieldSet);
      fail("Expected NotWritablePropertyException");
    }
View Full Code Here

    StaticApplicationContext context = new StaticApplicationContext();
    mapper.setBeanFactory(context);
    context.getBeanFactory().registerSingleton("bean", nestedList);
    mapper.setPrototypeBeanName("bean");

    FieldSet fieldSet = new DefaultFieldSet(new String[] { "1", "2", "3" }, new String[] { "NestedC[0].Value",
        "NestedC[1].Value", "NestedC[2].Value" });

    mapper.mapFieldSet(fieldSet);

    assertEquals(1, nestedList.getNestedC().get(0).getValue());
View Full Code Here

    StaticApplicationContext context = new StaticApplicationContext();
    mapper.setBeanFactory(context);
    context.getBeanFactory().registerSingleton("bean", nestedList);
    mapper.setPrototypeBeanName("bean");

    FieldSet fieldSet = new DefaultFieldSet(new String[] { "1", "2", "3" }, new String[] { "NestedC[0].Value",
        "NestedC[1].Value", "NestedC[2].Value" });

    mapper.mapFieldSet(fieldSet);

    assertEquals(1, nestedList.getNestedC().get(0).getValue());
View Full Code Here

  public void testPaddedLongWithNoEditor() throws Exception {

    BeanWrapperFieldSetMapper<TestObject> mapper = new BeanWrapperFieldSetMapper<TestObject>();
    mapper.setTargetType(TestObject.class);

    FieldSet fieldSet = new DefaultFieldSet(new String[] { "00009" }, new String[] { "varLong" });
    TestObject bean = mapper.mapFieldSet(fieldSet);
    // since Spring 2.5.5 this is OK (before that BATCH-261)
    assertEquals(9, bean.getVarLong());
  }
View Full Code Here

  public void testPaddedLongWithEditor() throws Exception {

    BeanWrapperFieldSetMapper<TestObject> mapper = new BeanWrapperFieldSetMapper<TestObject>();
    mapper.setTargetType(TestObject.class);

    FieldSet fieldSet = new DefaultFieldSet(new String[] { "00009" }, new String[] { "varLong" });

    mapper.setCustomEditors(Collections.singletonMap(Long.TYPE, new CustomNumberEditor(Long.class, NumberFormat
        .getNumberInstance(), true)));
    TestObject bean = mapper.mapFieldSet(fieldSet);
View Full Code Here

  public void testPaddedLongWithDefaultAndCustomEditor() throws Exception {

    BeanWrapperFieldSetMapper<TestObject> mapper = new BeanWrapperFieldSetMapper<TestObject>();
    mapper.setTargetType(TestObject.class);

    FieldSet fieldSet = new DefaultFieldSet(new String[] { "00009", "78" }, new String[] { "varLong", "varInt" });

    mapper.setCustomEditors(Collections.singletonMap(Long.TYPE, new CustomNumberEditor(Long.class, NumberFormat
        .getNumberInstance(), true)));
    TestObject bean = mapper.mapFieldSet(fieldSet);
View Full Code Here

  public void testNumberFormatWithDefaultAndCustomEditor() throws Exception {

    BeanWrapperFieldSetMapper<TestObject> mapper = new BeanWrapperFieldSetMapper<TestObject>();
    mapper.setTargetType(TestObject.class);

    FieldSet fieldSet = new DefaultFieldSet(new String[] { "9.876,1", "7,890.1" }, new String[] { "varDouble",
        "varFloat" });

    Map<Class<?>, PropertyEditor> editors = new HashMap<Class<?>, PropertyEditor>();
    editors.put(Double.TYPE, new CustomNumberEditor(Double.class, NumberFormat.getInstance(Locale.GERMAN), true));
    editors.put(Float.TYPE, new CustomNumberEditor(Float.class, NumberFormat.getInstance(Locale.UK), true));
View Full Code Here

  public void testBinderWithErrors() throws Exception {

    BeanWrapperFieldSetMapper<TestObject> mapper = new BeanWrapperFieldSetMapper<TestObject>();
    mapper.setTargetType(TestObject.class);

    FieldSet fieldSet = new DefaultFieldSet(new String[] { "foo", "7890.1" }, new String[] { "varDouble",
        "varFloat" });
    try {
      mapper.mapFieldSet(fieldSet);
      fail("Expected BindException");
    }
View Full Code Here

TOP

Related Classes of org.springframework.batch.item.file.transform.DefaultFieldSet

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.