wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes UrlyBird - Question about find method 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 "UrlyBird - Question about find method" Watch "UrlyBird - Question about find method" New topic
Author

UrlyBird - Question about find method

Mike Tilling
Ranch Hand

Joined: Feb 17, 2006
Posts: 86
Hi

It was mentionned in my assignement spec :

Data.java must implement DBMain interface which contains the method :
public int[] find (String[] criteria) throws RecordNotFoundException

a non null vcalue in criteria[n] matches any field value that begins with criteria[n]

On the other hand,it was mentionned that : the user interface must allow the user to search the data for all records, or for records where the name/or location fields exactly match value specified by the user.

-I need to implement find so that it returns String[][] values not int[] and the returned data must match exactly the criteria specified by the user not begining with it

Please help me how can I fix this issue

Best Regards
Eiji Seki
Ranch Hand

Joined: Feb 15, 2006
Posts: 88
1)
About returning String[][], you can just get the int[] and then call the read(int) method for each of the ID's. Although it certainly is not an optimized solution, is the one that uses only the given interface.

You can also assume that the interface is required but not necessarily needs to be used by you. In this case, the given interface will probably be used by an automated test engine. You may then create another interface that is used by your business layer that contains a String[][] findValues(String[]) method (or subclass the existing interface). I am not sure this is a valid way out, though. Since I had no such problems with my interface, I am just sticking with the given interface (and doing like the first solution I mentioned).

2)
Now, the exact match is problematic. You could use the starts-with (SW) method and then re-test the matches in the business layer.

You could also take advantage of the fact data on the data file has blank spaces filling the space (at least in my case) and send a query also with blank spaces.

If you are using a different interface as the second solution for the first problem, you may just specify that the String[][] findValues(String[]) method just do exact matches.

Well, you get the point... it looks like some weird solution is necessary.


SCJD URLyBird (WIP)<br />SCJP 1.5
Ed Tse
Ranch Hand

Joined: Sep 18, 2003
Posts: 183
That's why a lot of people use an adapter class to call int[] find(String[]). The code will make more sense instead of puting all the client side requirment onto Data class


SCJP, Pre-SCJD (URLyBird 1.3.1), Teradata Cert'd Prof
Mike Tilling
Ranch Hand

Joined: Feb 17, 2006
Posts: 86
Many thanks

Would it be ok if you can have look on my questions in the section
"Questions about Exceptions Handling"
BEST REGARDS
Sergey Zolotaryov
Greenhorn

Joined: Mar 14, 2006
Posts: 26
I totally rejected the idea of padding search criteria with spaces in order to match the database values. Instead I offer two combo boxes name and location filled with all respective values from the database (duplicates excluded, of course), so that the user does not have to enter spaces manually. In addition the combo boxes are made editable, so that if the user wants to enter a value, he can do this. Of course, the last possibility does not make sense for this assignment but the requirement is fulfilled, anyway.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: UrlyBird - Question about find method