unlockha / beanio

Automatically exported from code.google.com/p/beanio
Apache License 2.0
1 stars 0 forks source link

Trimming spaces from input number fields #40

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?  If applicable, please provide a mapping 
configuration and sample record input to recreate the problem.
- mapping: 
<beanio xmlns="http://www.beanio.org/2012/03" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.beanio.org/2012/03 http://www.beanio.org/2012/03/mapping.xsd">
  <stream name="blahblah" format="csv">
    <parser>
      <property name="delimiter" value="|" />
    </parser>
    <record name="foobar" minOccurs="1" maxOccurs="unbounded" class="blah">
      <field name="someNumber" type="java.lang.Long" format="#0" />
      <field name="somethingElse" />
    </record> 
  </stream>
</beanio>

- input:
156000033 |Hello World

What is the expected output?
- Pojo with someNumber=156000033 and somethingElse="Hello World"

What do you see instead?
Invalid 'someNumber': Type conversion error: Invalid Long value '156000033 '
at 
org.beanio.internal.parser.UnmarshallingContext.validate(UnmarshallingContext.ja
va:196)
at 
org.beanio.internal.parser.BeanReaderImpl.internalRead(BeanReaderImpl.java:105)
at org.beanio.internal.parser.BeanReaderImpl.read(BeanReaderImpl.java:64)
at 
org.apache.camel.dataformat.beanio.BeanIODataFormat.readModels(BeanIODataFormat.
java:148)
at 
org.apache.camel.dataformat.beanio.BeanIODataFormat.unmarshal(BeanIODataFormat.j
ava:110)
....

What version of BeanIO are you using? What JDK version?
- Java 1.6.0_26
- BeanIO 2.0.1

Original issue reported on code.google.com by paolo...@gmail.com on 27 Aug 2012 at 7:07

GoogleCodeExporter commented 8 years ago
Hello, this looks like a duplicate of issue #38.  Please try the snapshot jar 
attached to that issue.  And you must set trim="true" on any field you want 
trimmed- otherwise you will continue to get type conversion errors.

Thanks,
Kevin

Original comment by kevin.s...@gmail.com on 29 Aug 2012 at 3:20