Retriving a repeating group as a collection or an array.

169 views
Skip to first unread message

Raj

unread,
Aug 14, 2009, 1:03:54 AM8/14/09
to Fixedformat4j User List
I have fixed length string similiar to
"ADDRESS......CCYYMMDDCCYYMMDDCCYYMMDD...." where a group of
characters will be repeating a fixed number of times. In the above
example the date "CCYYMMDD" is repeating 3 times. How do I get the
date values as a collection or an array using Fixedformat4j?

Ann Campbell

unread,
Aug 14, 2009, 8:10:57 PM8/14/09
to fixedformat...@googlegroups.com
Raj,

I believe you're going to have to write your own formatter(s).

I'd do it in two steps:
* Write a simple object formatter to parse the individual CCYYMMDD groups and then construct your array manually,
* Add a second formatter (which will call the first) to construct the array for you.

If the second formatter is type-specific, it can be as simple as this to annotate:
@Field(offset=12, length=24, formatter=CalendarArrayFormatter.class)

If you haven't already, I'd download the source for example formatters.


Ann
Reply all
Reply to author
Forward
0 new messages