Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

UrlyBird - Question about find method  RSS feed

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mike Tilling
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many thanks

Would it be ok if you can have look on my questions in the section
"Questions about Exceptions Handling"
BEST REGARDS
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!