Archive for August, 2008

IFS 2008-08-24: Cobra

Tuesday, August 26th, 2008

I’ve found and proposed a solution for a bug in the Cobra Toolkit, a HTML parser with a Javascript engine attached.

New category: Improving Free Software

Tuesday, August 26th, 2008

I divide free software people this way:

  • almost everybody can proudly say to be a free/open source software user
  • most of us develop software with free software
  • some of us participate to free software development
  • and a tiny small group of coders does the hard work

I stick on the first and second groups.
On time to time, I release a new free software, taking part in the last group, at least for a few lines of code.
More often I’m part of the third group, by submitting bugs and (sometimes) patches.
I’ve decided to list those patches here, since somehow they give a feeling on how, why and when I do what I say to do to friends and colleagues asking me about linux and the rest.
And by the way, that improves my curriculum.

JRecordBind - (un)marshalling host files

Friday, August 1st, 2008

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.