Menu

#5 Error checking Field Intersections

open
nobody
None
5
2008-02-12
2008-02-12
No

Hello,

The example you give in your doc works :

LineFormat format = new LineFormat();
format.defineField(0, 5); // declares a field from position 0 to 4 (length 5)
format.defineField(5, 7); // declares a field at positions 5 and 6 (length 2)
format.defineField(7, 12); // declares a field from position 7 to 11 (length 5)

But if you just change the order of the declaration, the parser throws an exception :

LineFormat format = new LineFormat();

format.defineField(5, 7); // declares a field at positions 5 and 6 (length 2)
format.defineField(0, 5); // declares a field from position 0 to 4 (length 5)
format.defineField(7, 12); // declares a field from position 7 to 11 (length 5)

org.sadun.text.ffp.FieldDefinitionException: Programming error: the fields field_1_1 (from position 0 to position5, length 5, type undefined type) and field_1_1 (from position 5 to position7, length 2, type undefined type) intersect

This is due to a wrong test in the LineFormat.FieldInfo.intersect() method.

Thanks for your correction

Discussion


Log in to post a comment.