Java Camel Bindy固定长度格式:如何使用继承的类?

Java Camel Bindy固定长度格式:如何使用继承的类?,java,apache,apache-camel,fixed-length-record,bindy,Java,Apache,Apache Camel,Fixed Length Record,Bindy,我有两个类CommonRequest和AccountRequest @FixedLengthRecord(paddingChar=' ',ignoreTrailingChars=true) public class CommonRequest { @Id private String corelationID; @DataField(pos=1,length=8) private String cmNumber; @DataField(pos=2,length=16) private St

我有两个类CommonRequest和AccountRequest

@FixedLengthRecord(paddingChar=' ',ignoreTrailingChars=true)
public class CommonRequest {

@Id
private String corelationID;

@DataField(pos=1,length=8)
private String cmNumber;

@DataField(pos=2,length=16)
private String accountNumber;

}
和AccountRequest.java

@FixedLengthRecord(paddingChar=' ',ignoreTrailingChars=true)
public class AccountRequest extends CommonRequest {

@Id
private String corelationID;

@DataField(pos=3,length=14)
private String accountType;

@DataField(pos=4,length=15)
private String accountLocation;

}
当我尝试解组一条记录时,如cmNumberaccountNumberaccountTypeaccountLocation

它会正确地解组公共请求,但当我尝试解组AccountRequest时,它会从开始位置开始,而不是从公共请求中留下的位置继续


这会使AccountRequest中的整个字段不匹配。

更改位置以匹配长度,但仍然不会设置基类中的字段,它们将为null,但会设置子类字段。检查此站点以了解如何执行此操作。

更改位置以匹配长度,但仍然不会设置基类中的字段,它们将为空,但将设置子类字段。查看此网站以了解如何完成此操作。

将此视为文本记录 01 32孙达摩尔

@FixedLengthRecord(length = 20,ignoreTrailingChars=true)
public class Employee {
@DataField(pos = 1, length = 2)
private int serialNo;
@DataField(pos = 4, length = 2)
private int age;
@DataField(pos = 7, length = 6)
private String firstName;
....getters and setters
}

@FixedLengthRecord(length=20)
public class Employee2 extends Employee{
@DataField(pos=14, length=7)
private String lastName;
....
getters and setters..
}
现在,如果您使用Camel来使用Employee类来解组文本文件,那么结果将是序列号、年龄和名字将设置为model。 132Sundar 如果您使用camel来使用Employee2类对文本文件进行解组,结果将是lastname设置为model。 摩尔蒂


这是camel 2.16.0版,如果有任何其他问题,请告诉我,但基类中的字段将不会设置。

将此视为文本记录 01 32孙达摩尔

@FixedLengthRecord(length = 20,ignoreTrailingChars=true)
public class Employee {
@DataField(pos = 1, length = 2)
private int serialNo;
@DataField(pos = 4, length = 2)
private int age;
@DataField(pos = 7, length = 6)
private String firstName;
....getters and setters
}

@FixedLengthRecord(length=20)
public class Employee2 extends Employee{
@DataField(pos=14, length=7)
private String lastName;
....
getters and setters..
}
现在,如果您使用Camel来使用Employee类来解组文本文件,那么结果将是序列号、年龄和名字将设置为model。 132Sundar 如果您使用camel来使用Employee2类对文本文件进行解组,结果将是lastname设置为model。 摩尔蒂


这是骆驼2.16.0版,如果有任何其他问题,请告诉我,但基类中的字段将不会设置。

尝试更改位置,实际上跳过了2个字符,因为我们在子类中给出了pos=3。它在2.13.0版本中运行良好,但在2.16.0版本中,它给了我一个问题提供子类中的实际位置号,如pos=25代替pos=3。尝试更改位置时,它实际上跳过了2个字符,因为我们在子类中给出了pos=3。它在2.13.0版本中运行良好,但现在在2.16.0版本中,它给了我一个问题提供子类中的实际位置号,如pos=25代替pos=3。