camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikaelfj <>
Subject BindyFixedLengthDataFormat trimming lines
Date Mon, 07 Feb 2011 12:11:06 GMT


We are running Camel 2.4 and are to unmarshal FixedLength lines to objects
using Bindy.

The FLV record is defined with:
@FixedLengthRecord(length = 128, paddingChar = ' ')
I.e. 128 character long with spaces as default paddingchar.

The last "field" in the line is defined as:
@DataField(pos = 62, length = 67, align = "L")
I.e. it takes up the last 67 characters, left aligned using the default

This implies, that if this last field does not contain any data, the last 67
characters of the FixedLength line will be spaces.

When feeding a line with no data in the last field into the
BindyFixedLengthDataFormat it will fail, because the codes does this when
reading the line:

while (scanner.hasNextLine()) {

  // Read the line
  String line = scanner.nextLine().trim();

  LOG.debug("Handling line : " + line);

The trim() will remove the last 67 characters in the line (as they are
spaces) and then this part of the code:

  // Check if the record length corresponds to the parameter
  // provided in the @FixedLengthRecord
  if ((line.length() < factory.recordLength()) || (line.length() >
factory.recordLength())) {
    throw new java.lang.IllegalArgumentException("Size of the record : " +
line.length() + " is not equal to   the value provided in the model : " +
factory.recordLength() + " !");

will throw an exception telling that the size of the record length is not
equal ....

The same problem will arise in the case of leading spaces in the line.

How come the lines are trimmed? 
When working with FixedLength records it must be the resposibility of the
user to ensure the records are of proper length - so the code should, in my
view, not perform any modifications (like trimming) of the records.

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message