Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes AND or OR in search criteria 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 "AND or OR in search criteria " Watch "AND or OR in search criteria " New topic
Author

AND or OR in search criteria

Rag Srinivasan
Greenhorn

Joined: Jun 05, 2003
Posts: 11
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

Joined: Jan 30, 2000
Posts: 18671
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.


"I'm not back." - Bill Harding, Twister
Rag Srinivasan
Greenhorn

Joined: Jun 05, 2003
Posts: 11
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

Joined: Jun 05, 2003
Posts: 11
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: AND or OR in search criteria
 
Similar Threads
Searching Criteria - GUI
Lock and Search
NX: Search Condition - AND/OR
GUI Search Question
About URLBirld booking!