This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AND or OR in search criteria

 
Rag Srinivasan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
This is what my requirements have to say.
"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."
What did you all implement (those who had similar requirement ofcourse). Did you assume AND or an OR or provide an UI flag to choose between the two ?
The problem is that I have created a Criteria.java class that encapsulates to some extent all the filteration rules and it only supports AND, but I do not know how to create a generic AND/OR expression for example
(parm1 == A OR parm2 == B) AND parm3 == C
The reason to think in this manner is that the find(String[] criteria) in DBMain.java is pretty much useless to capture any nuance and the requirements want this to be extensible. I cannot assume that only location and name fields will be in the expression such as
location == X AND name == Y
location == X OR name == Y

It could be any combination of the 7 DB columns.
Any clues
Thanks
-- Rag
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assumed AND.
"records where the name and/or location fields exactly match values specified by the user"
I think that the use of "and/or" here is just a nod to the fact that either name or location could be left blank, and so might need to search for
(records where name matches)
OR (records where location matches)
OR (record where name AND location match)
This interpretation was influenced by the description of the find() method, which implicitly ANDs all criteria specified (not left blank). It's certainly possible to add an OR button - but I don't think it's necessary. IMO of course.
 
Rag Srinivasan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jim. That was my initial impl, but I started to second guess myself.
regards
-- Rag
Originally posted by Jim Yingst:
I assumed AND.
"records where the name and/or location fields exactly match values specified by the user"
I think that the use of "and/or" here is just a nod to the fact that either name or location could be left blank, and so might need to search for
(records where name matches)
OR (records where location matches)
OR (record where name AND location match)
This interpretation was influenced by the description of the find() method, which implicitly ANDs all criteria specified (not left blank). It's certainly possible to add an OR button - but I don't think it's necessary. IMO of course.
 
Rag Srinivasan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jim. That was my initial impl, but I started to second guess myself.
regards
-- Rag
Originally posted by Jim Yingst:
I assumed AND.
"records where the name and/or location fields exactly match values specified by the user"
I think that the use of "and/or" here is just a nod to the fact that either name or location could be left blank, and so might need to search for
(records where name matches)
OR (records where location matches)
OR (record where name AND location match)
This interpretation was influenced by the description of the find() method, which implicitly ANDs all criteria specified (not left blank). It's certainly possible to add an OR button - but I don't think it's necessary. IMO of course.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic