tags:

views:

178

answers:

4

Has anybody written any classes for reading and writing Palm Database (PDB) files in Java? (I mean on a server, not on the Palm device itself.) I tried to google, but all I got were Protein Data Bank references.

I wrote a Perl program that does it using Palm::PDB.pm, but I want to turn it into a servlet for a GWT app.

+1  A: 

There are a few ways that you can go about this;

  1. Easiest but slowest: Find a perl-> java bridge. This will not be quick, but it will work and it should involve the least amount of work.
  2. Find a C++/C# implementation that you have the source to and convert it (this should be the fastest solution)
  3. Find a Java reader ... there seems to be a few listed under google... however I do not have any experience with these.
monksy
The only java reader I can find turns out to be a C program written in Java. Ie. all the code was in main or in a couple of static methods. No class structure at all.
Paul Tomblin
+1  A: 

Depending on what your intended usage is, you might look into writing a simple reader yourself. The format is pretty simple and you only need to handle a couple of simple fields to parse it.

Basically there is a header for the entire file which has a 2 byte integer at the end which specifies the number of record. So just skip your way through the bytes for all the other fields in the header and then read the last field which is the number of records in the file. Be aware that the PDB format writes integers with most significant byte first.

Following this, there will be a record header for each record, the first field of which is the actual offset into the file for the record itself. Again, be aware of the byte order.

So, now you have the offsets into the file for each record in the file, which should make it very easy to read the actual records as long as you know the format of these for the type of PDB file you are trying to read.

Wikipedia has a nice overview of the header formats.

kasperjj
+1  A: 

Maybe JPilot can help? They must have a lot of Java code dealing with Palm OS data.

alexander.egger
JPilot is written in C, not Java. Important lesson: not every program whose name begins with "J" has anything to do with Java.
Paul Tomblin
Ups. I used JPilot years ago. I was convinced it was Java. But of course your right. No Java in JPilot.
alexander.egger
+1  A: 

The jSyncManager project at http://www.jsyncmanager.org/ is under the LGPL and includes classes to read and write PDB files -- look in jSyncManager/API/Protocol/Util/DLPDatabase.java in its source code. It looks like the core code you need from this could be isolated from the rest of the library with a little effort.

Ben Combee
I think this has what I need. Thanks very much.
Paul Tomblin