Hello,
I am just starting with urlybird 1.2.1 and already have some questions! :-) So, far I have answered quite a few of them searching this forum. Great help!
I have doubts regarding the file format, its contents and how to manipulate them. Obviously all development and
testing will be done on a copy of that file.
The format given is shown below: ( I hope posting this part of the instructions does not violate JavaRanch rules - If removed I will rephrase my question )
Data file Format
The format of data in the database file is as follows:
Start of file
4 byte numeric, magic cookie value. Identifies this as a data file
4 byte numeric, total overall length in bytes of each record
2 byte numeric, number of fields in each record
Schema description section.
Repeated for each field in a record:
2 byte numeric, length in bytes of field name
n bytes (defined by previous entry), field name
2 byte numeric, field length in bytes
end of repeating block
Data section.
Repeat to end of file:
1 byte "deleted" flag. 0 implies valid record, 1 implies deleted record
Record containing fields in order specified in schema section, no separators between fields, each field fixed length at maximum specified in schema information
End of file
All numeric values are stored in the header information use the formats of the DataInputStream and DataOutputStream classes. All text values, and all fields (which are text only), contain only 8 bit characters, null terminated if less than the maximum length for the field. The character encoding is 8 bit US ASCII.
I can see the structure is clearly defined, but have some doubts about the byte numeric values. Initially I used a hex editor to open the .db file, but found only symbols or blank spaces for the numeric values - text is showing fine. Is a hex editor perhaps not the best way to look into the header information of a file?
I will use
RandomAccessFile for writing on the file when the time comes, but to place the seek pointer to the right location (beginning of the record) I would need the correct offset (The record length is given in the instructions). That offset I will calculate from the file format information. The big issue is to determine those byte numeric values. Are they left blank on purpose (for me to define) or am I trying to find them the wrong way? How would you suggest I retrieve the header information?
I appreciate any advice on this.
Thanks!