Java 中的 Palm 数据库 (PDB) 文件?
有人用 Java 编写过用于读写 Palm 数据库 (PDB) 文件的类吗? (我的意思是在服务器上,而不是在 Palm 设备本身上。)我尝试用谷歌搜索,但我得到的只是蛋白质数据库参考。
我编写了一个使用 Palm::PDB.pm 执行此操作的 Perl 程序,但我想将其转换为 GWT 应用程序的 servlet。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
http://www.jsyncmanager.org/ 上的 jSyncManager 项目位于 LGPL 下,包含要读取的类并编写 PDB 文件——查看 jSyncManager/API/Protocol/Util/DLPDatabase.java 的源代码。看起来您需要的核心代码可以通过一点努力与库的其余部分隔离。
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.
有几种方法可以解决这个问题;
There are a few ways that you can go about this;
根据您的预期用途,您可能会考虑自己编写一个简单的阅读器。格式非常简单,您只需要处理几个简单的字段即可解析它。
基本上,整个文件有一个标头,其末尾有一个 2 字节整数,用于指定记录数。因此,只需跳过标头中所有其他字段的字节,然后读取最后一个字段,即文件中的记录数。请注意,PDB 格式首先写入最高有效字节的整数。
接下来,每个记录都会有一个记录头,其中第一个字段是记录本身在文件中的实际偏移量。再次注意字节顺序。
因此,现在您已经有了文件中每条记录的偏移量,只要您知道要读取的 PDB 文件类型的这些记录的格式,就可以很容易地读取实际记录。
Wikipedia 对标头格式有很好的概述。
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.
也许 JPilot 可以提供帮助?他们必须有大量处理 Palm OS 数据的 Java 代码。
Maybe JPilot can help? They must have a lot of Java code dealing with Palm OS data.