File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Initial schema read 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 "Initial schema read" Watch "Initial schema read" New topic
Author

Initial schema read

Graham Maloon
Greenhorn

Joined: Jul 23, 2004
Posts: 3
I was thinking of reading the first part of the file in a singleton that will then keep the schema of the file. This can be accessed by the Data class. Should this be available to the client.
Philippe Maquet
Bartender

Joined: Jun 02, 2003
Posts: 1872
Hi Graham,

Welcome to JavaRanch and this forum!

I was thinking of reading the first part of the file in a singleton that will then keep the schema of the file. This can be accessed by the Data class. Should this be available to the client.


Only if you need it, but it's probable. Two comments:

1) Do you really need a Singleton? Anyway, I think it'll look more natural, to the clients of your Data class, to call some getMetaData() method on their Data instance, instead of calling some static MetaData.getInstance(), IMO.
2) By "client", I guess you mean your business tier, wherever it lies (client-side or server-side).

Regards,

Phil.
Graham Maloon
Greenhorn

Joined: Jul 23, 2004
Posts: 3
I understand that it would be easier to call getMetaData, but would I not need to save the meta data somewhere?
Robert Konigsberg
Ranch Hand

Joined: Jun 23, 2004
Posts: 172
I suspect you don't need the metadata on the client. If you're handling the B&S certification, you may not have requirements to have variable metadata. I'd handled that by documenting, loosely, what would be required to add a field to the database, showing where all the different parts are. That was documentation for any new developer coming in. So just assume that the metadata is not changing and go from there.

Also regarding metadata as a Singleton, what if you wanted to open multiple databases? It might be better to use composition to make the metadata an attribute of your data class.

Good luck!


SCJP 1.4 (91%)<br />SCJD 1.4 (376/400, 94%)
Graham Maloon
Greenhorn

Joined: Jul 23, 2004
Posts: 3
Thanks for your responses.

I think it would be nice to show the field names on the client and therefore the metadata. If I were to put the reading of the schema into the Data class, I would have to make it static. Is that a good idea?
Robert Konigsberg
Ranch Hand

Joined: Jun 23, 2004
Posts: 172
I still don't think making it static is a good idea. Again, what if you have two databases open? What would you do then? Keep the metadata as an attribute of your data class. The same data object you access through your middle-tier is the same one that could deliver the metadata.

A singleton database connection might be reasonable and has different implications. It's easier to manage two databases, each with their own metadata than two databases and one static metadata.

RK
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Initial schema read