*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes [URLyBird] Question about data file! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "[URLyBird] Question about data file!" Watch "[URLyBird] Question about data file!" New topic
Author

[URLyBird] Question about data file!

Leo Ho
Ranch Hand

Joined: Mar 31, 2005
Posts: 36
Hi all, in the instruction file I receive from Sun, I see both the field length (specified explicitly such as: name - 64, size - 4, smoking - 1), and the schema description which allows me to get the length of the field programmatically:
---------------------------
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
---------------------------

My question is that since I can determine the fields' lengths by examine the schema description, why on earth they already explicitly show me that name is of length 64, smoking is of length 1 and so on??? Should I just use one mechanism, either use constants or read the schema, to extract the fields' values and ignore the other?
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

Hi Leo


The schema description vary from a file to an other - more simpe you can have different database file with different (data) scheme.
If the database format changes in the future your applcation must be flexible enought to support this changes with minimal (or preferable with none) code changing.
The docuement from sun presents the actual database form but as I said this can change in the future.

Regards Mihai
[ April 10, 2006: Message edited by: Mihai Radulescu ]

SCJP, SCJD, SCWCD, OCPJBCD
B Chen
Ranch Hand

Joined: Dec 27, 2005
Posts: 89
Its a design decision you need to make.
Using constants is easier, but will require program changes if the database changes.
Using the schema description may allow the program to continue to work if the database changes, but such design will be complex. I said may because you have to ask yourself, would you be able to anticipate all possible database changes and properly design and code for them?


SCJD<br />SCJP 1.4
Leo Ho
Ranch Hand

Joined: Mar 31, 2005
Posts: 36
Thanks, Mihai & Chen. I guess I would use the schema instead of the constants.

Leo
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [URLyBird] Question about data file!