Apche camel Bindy How to make IllegalArguementException for fields which are blank

36 Views Asked by At

I am trying to parse an input text file ( not CSV) which is fixedFormat.

@FixedLengthDataRecord(ignoreMissingChars = true, ignoreTrailingChars= true)
public class ParsedDataRec {

@DataField(pos = 3, length=5, required=false)
public String field1;

@DataField(pos = 9, length=5, required=false, default="0")
public int field2;

@DataField(pos = 15, length=4, required=false)
public String field3;

}

I have input text file like this:

000ACBDC099867AAAAAAZZZZZZ

000ACBDC0 < space ->< space ->< space ->< space ->< space -> AAAAAAZZZZZZ

Please note that Record1 = 000ACBDC099867AAAAAAZZZZZZ Record2 = 000ACBDC0< space ->< space ->< space ->< space ->< space ->AAAAAAZZZZZZ The error is happenning as camel tries to parse the field2 which in some records is just spaces. How to avoid error in those records

For the second record I get IllegalArguementException. I already made the record optional. Also please note ignoreMissingChars = true.

Please let me know how i can resolve this issue.

Thanks a lot in advance

0

There are 0 best solutions below