aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Schema handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Schema handling" Watch "Schema handling" New topic
Author

Schema handling

Matthew Undy
Greenhorn

Joined: Jul 24, 2007
Posts: 3
Hi All,

I'd like to ask a quick question about handling the schema in the data file for the URLyBird assignment. Apologies if this has been asked before, but I could not find a clear answer when searching.

As the instructions are clear about the format of the file, can we assume that any data file must match this format and access can therefore be 'hard coded' (basically skipping the schema to access records), or must we read in the schema and use those field lengths when reading in data?

Thanks,
Matt
Matthew Undy
Greenhorn

Joined: Jul 24, 2007
Posts: 3
At the moment I am considering using a class as below to hold constants that describe the schema, for use in the file access class. A similar idea was used in the SCJD Exam with J2SE5 book, however these were placed in the DVD class, but to me it seems like information that is disconnected from the value object.

Can anyone see any problems with this approach?



Thanks,
Matt
rinke hoekstra
Ranch Hand

Joined: Apr 06, 2007
Posts: 152
I hardcoded it. My motivation was: the database file is unlikely to change. And if they are rebuilding the database anyway, then I'd strongly recommend a complete rebuilt or better, a switch to a relational database.

I've seen lots of people pass hardcoding it.
[ July 24, 2007: Message edited by: rinke hoekstra ]

_ _ ________________________ _ _ <br /> <br />Just SCJP (but 93%)
Marcelo Camargo
Ranch Hand

Joined: Jul 05, 2007
Posts: 43
I think hardcoding is acceptable and is a good solution, because the file are not going to change.
But, I am reading the schema and storing it in a array list, because it is easier to implement, and it demands less code. for example, to write all fields of a record to the file I just need the folowing code:



See, with just a few lines all the fields are saved. Using constants, you need to use each one of them, and the code will have more lines.

Marcelo.


SCJP5(93%), SCJD(in progress...), SCEA(not started yet...)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Schema handling