0

I'm trying to map records in fixed length file to a POJO.

Fixed length file content looks like this

AlexSA1
JoeyCA0BNB
CarlPM1B B

That is mapped like below

<record name="xyz" class="POJO">
     <field name="name" type="string" position="0" length="4" required="false"/>
     <field name="state" type="string" position="4" length="2" required="true"/>
     <field name="enrolled" position="6" type="byte" length="1" required="true"/>
     <field name="label1" type="string" position="7" length="1" minOccurs="0"/>
     <field name="label2" type="string"  position="8" length="1" minOccurs="0"/>
     <field name="label3" type="string"  position="9" length="1" minOccurs="0"/>
</record>

Result pojo is looking like this

{Alex,SA,1,null,null,null}. //all the last feilds are setting to null
{Joey,CA,0,B,N,N}
{Carl,PM,1,B,,N} //it's not being set to null

If value is not present ,I want to to map that to empty

So , POJO should look like

 {Alex,SA,1,,,} //all the last feilds are setting to empty
 {Joey,CA,0,B,N,N}
 {Carl,PM,1,B,,N} 

How can i do this?

ammy
  • 306
  • 1
  • 6
  • 23

1 Answers1

0

I've never worked with bean.io but I suspect that you need to supply a default value for the fields. See Field properties

kimbert
  • 2,376
  • 1
  • 10
  • 20