Bookmark Topic Watch Topic
  • New Topic

NX: findByCriteria Method

 
Dirk Band
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,
I have some concerns about the implementation of the �public long[] fingByCriteria(String[] criteria)� method.
The Assignment says:
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.
Should it by possible to serach for records where name AND location match and where name OR location match? But then, how to implement this in the findByCriteriaMethod? There is no parameter for the binding AND OR.
 
Vlad Rabkin
Ranch Hand
Posts: 555
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Dirk,
Here is discussion thread:
http://www.coderanch.com/t/183896/java-developer-SCJD/certification/URLBird-find-Hotel-or-Name
You will find an answer there.
Regards,
Vlad
 
Dirk Band
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks for this quick answer. I read it.
But my assignment says:
// Returns an array of record numbers that match the specified
// criteria. Field n in the database file is described by
// criteria[n]. A null value in criteria[n] matches any field
// value. A non-null value in criteria[n] matches any field
// value that begins with criteria[n]. (For example, "Fred"
// matches "Fred" or "Freddy".)
public long[] findByCriteria(String[] criteria);
I understand that criteria[0] is the first database field. In my case it's name.
criteria[1] is second database field (location). and so on.
Example: findByCriteria({"Fred","Dallas","80$","",""})
Am I rigth?
Cheers Dirk
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11914
209
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Report post to moderator
Closing this thread as the discussion seems to have moved here.
 
    Bookmark Topic Watch Topic
  • New Topic