File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Schema handling

 
Matthew Undy
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 152
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Marcelo Camargo
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic