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 [NX:URLyBird] How to serch the date for record? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "[NX:URLyBird] How to serch the date for record?" Watch "[NX:URLyBird] How to serch the date for record?" New topic
Author

[NX:URLyBird] How to serch the date for record?

Leo Tien
Ranch Hand

Joined: Sep 10, 2002
Posts: 156
Hi, my friends:
It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user.

Whether this said that only can use name and/or location field to search the record. So, in my BrokerModel interface have three method:
public DiscountRoom getDiscountRoom(String name);
public DiscountRoom getDiscountRoom(String locatino);
public DiscountRoom getDiscountRoom(String name, String location);
public DiscountRoom getAllDiscountRooms();
Is it right?
Thanks!
Vlad Rabkin
Ranch Hand

Joined: Jul 07, 2003
Posts: 555
Hi Leo,
Please take a look at the following topic:
http://www.coderanch.com/t/183896/java-developer-SCJD/certification/URLBird-find-Hotel-or-Name
So, I have decided to have only one method as it is in the standard DB interface: array of String. Null value in element of the array means "any" value in the field.
Vlad
Leo Tien
Ranch Hand

Joined: Sep 10, 2002
Posts: 156
Hi, Vlad:
.....array of String.....

As you said, every value of field is String, but in my db.db file, some field data is another type, such as size is int. Whether when I read it out from the db.db file, should convert it to String, then put it in the String array? If not, how can I do?
I have a DiscountRoom class describes a record read from the db.db file. I define some attributes in it to describes every field in the record.

If I do this, how can I create the getDiscountRoom? Whether I put these attributes in a Object array? So, the getDiscountRoom method should
Am I right?
Thanks.
Vlad Rabkin
Ranch Hand

Joined: Jul 07, 2003
Posts: 555
Hi Leo,
In this case I would better provide such method in your DBAdapter/Facade interface:
// for search
DiscountRoom[] getDiscountRooms(DiscountRoom criteria);
// for read
DiscountRoom getDiscountRoom(int recNo);

Of course you have to parse all fields while reading them from database to appropriate types.
I have done all it almost the same way, except my DiscountRoom class. My DiscountRoom has String[] and MetaData (class contating Field[], describing each elemnt in String[]. It allows me to avoid type parsing, but I can do it in future by adding getType() method in Field class. It allows me say that my database framework is generic.
Advantage of your design is clear business interface between client and server.
Advantage of my design database base frawork is a bit more generic and it allows me not parse database fields in the assignement, since it was not required.

Best,
Vlad
Leo Tien
Ranch Hand

Joined: Sep 10, 2002
Posts: 156
Hi, Vlad:
My DiscountRoom has String[] and MetaData (class contating Field[], describing each elemnt in String[].

I think I don't understand your meaning properly. What is MetaData, whether you have two array in the DiscountRoom class? Why do this?
Thanks.
Vlad Rabkin
Ranch Hand

Joined: Jul 07, 2003
Posts: 555
Hi Leo,
Sorry, I didn't want to confuse you with my crazy ideas. If you are interested in my idea about MetaData here is the topic:
http://www.coderanch.com/t/183928/java-developer-SCJD/certification/Database-Schema-Facade-Interface
MetaData is a class, containing one (and only one!) array of Field objects. Field class contains information about the database field: name, length. Type (Long, Date and so on) can be also added in future.
It allows to have a bit more generic framework, rather then declaring the type now. However it looks not so nice like the way you have done.
I beleive your solution can be probably not so flexible, but much more understandable and clear (at list for client). So, I didn't critisize your design, just let you know how I have done it.
In any case the point was the I managed to do search by declaring only one method: DiscountRoom[] find (DiscountRoom criteria).
Best,
Vlad
[ August 28, 2003: Message edited by: Vlad Rabkin ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [NX:URLyBird] How to serch the date for record?