|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--PalmDB
Converts between the Palm OS on-disk PRC format (used for applications and some data files) and a simple Java in-memory representation. With a slight effort, this could be extended to write and read PDB (the more common data format) as well.
The header fields are stored as publicly-accessible fields, along with a
list of the records, each of which is stored as a PalmDB.PRCRecord
.
All the internals are visible, so be careful; this is quick and dirty, but
it ain't rocket science anyway. Note especially that the records in a parsed
file all initially share the same buffer of data. When modifying, replace it
with a new buffer rather than overwriting other records' data!
Note: appInfo
records and sortInfo
records are
ignored (with a warning) if present, and cannot be generated.
Used from the command line, reads a PRC file and dumps its entire contents to the console. This is equivalent to:
PalmDB db = load(new File(args[0])); System.out.println(db);
See http://www.palmos.com/ for more information on the file format.
TODO:
- Convert dates to and from a java date format (Calendar?)
- read and write appInfo and sortInfo records
- implement/test PDB support
Nested Class Summary | |
static class |
PalmDB.Resource
Note: when parsing, each record has a pointer into the same block of data, so either treat it as read-only (in terms of length, at least), or replace it with your own byte array to modify it. |
Field Summary | |
int |
attributes
Somewhat mysterious bits. |
int |
creationDate
Seconds since 1/1/1904. |
java.lang.String |
creator
A four-character String containing a unique, registered database creator code. |
int |
lastBackupDate
Seconds since 1/1/1904. |
int |
modificationDate
Seconds since 1/1/1904. |
int |
modificationNumber
Related to syncing, perhaps? |
java.lang.String |
name
The name given to the file when it is written. |
java.util.LinkedList |
records
Contains the Resources that contain the database's contents. |
java.lang.String |
type
A four-character String containing a unique, registered database type. |
int |
uniqueIDSeed
Not used for PRC. |
int |
version
A version field (encoding is application-specific?) |
Constructor Summary | |
PalmDB()
|
Method Summary | |
static PalmDB |
load(java.io.File file)
Reads a PRC file from the filesystem and parses its contents. |
static void |
main(java.lang.String[] args)
Loads the PRC file named by the first argument and dumps its contents. |
static PalmDB |
parse(byte[] data)
Breaks the elements of a PRC file into header and records for further processing. |
void |
save(java.io.File file)
Write the contents of this PRCFile to the filesystem. |
java.lang.String |
toString()
|
byte[] |
write()
Captures the output of write(OutputStream) in a byte array, mostly for symmetry
with the parsing side, and to simplify debugging. |
void |
write(java.io.OutputStream os)
Writes the contents of this PRCFile to the given stream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public java.lang.String name
public int attributes
public int version
public int creationDate
public int modificationDate
public int lastBackupDate
public int modificationNumber
public java.lang.String type
public java.lang.String creator
public int uniqueIDSeed
public java.util.LinkedList records
Constructor Detail |
public PalmDB()
Method Detail |
public static void main(java.lang.String[] args)
public static PalmDB load(java.io.File file) throws java.io.IOException
java.io.IOException
public static PalmDB parse(byte[] data)
data
- The unparsed contents of a PRC file.public void write(java.io.OutputStream os) throws java.io.IOException
java.io.IOException
public byte[] write()
write(OutputStream)
in a byte array, mostly for symmetry
with the parsing side, and to simplify debugging.
public void save(java.io.File file) throws java.io.IOException
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |