I’ve just received the approval email for my latest java tool: JRecordBind.
If you are familiar with JAXB, JRecordBind is just the same (from a functional point of view) but it targets host files, a.k.a. “fixed length text files“.
If you are not familiar with (un)marshalling tools, let me present you JRecordBind.
When you need to import some fixed length file, you usually have an extensive documentation about which field is where. Something like
- from char 1 to 20 there are name and surname, filled with spaces
- from 21 to 28 the birthdate in the format YYYYMMDD
and so on.
Speaking XML, this is the XSD, the definition of the structure of the data file, with the types of each field.
JRecordBind needs you to write this definition into a “.properties” file.
The RecordBeanGenerator will then create a java bean suitable for storing each line of the data file.
The Marshaller object will transform this bean into a text line: that’s useful when you need to export data.
The Unmarshaller will do the contrary, that’s transforming every single line into a bean: useful when you need to import data.
JRecordBind allows the developer to focus of the varying part of such import procedures: how to spread imported data into a database. JRecordBind will care about reading/parsing/validating.
JRecordBind is still in the incubator since I plan to add multiline support (beans defined in multiple lines) and multibean support (different types of beans defined in different lines)
Nonetheless, it’s quite fast: on my pentium-m, unit tests have unmashalled 100.000 lines in 5 seconds.
If you want to blame me for this tiny little piece of code, drop me an email at federico _Oo_ fissore.org
A final note
I must admit that JRecordBind is currently compiled with Java 6. But it could be easily ported to Java 1.4. Do you think I should? My ego says “Noo! Java 1.4 is dead. Long live Java 1.4!” but since host files are old, maybe old 1.4 software could benefit of this tool.
Uhmm, I’m at a crossroad.