File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes CriteriaFind  Confusion 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 "CriteriaFind  Confusion" Watch "CriteriaFind  Confusion" New topic

CriteriaFind Confusion

Raju, Gentle

Joined: Sep 06, 2001
Posts: 28
I have the following question on CriteiaFind method. Help approciated.
1. Does CriteriaFind be Generic or should we do only
Carrier='SpeedyAir',Origin='SFO'" ? I think it should be
generic. But the question is how much generic.
Is the user allowed to enter in the criteria the field name
in any order and in any order. Also user can give some of
the filed names or all of the field names in the criteria.
If so this method becomes very ugly to find out all the field
names and corresponding values and put them in the order that
is acceptable by method find ( or modified version of find
method ). So please give me your advise here.
Marco Barenkamp
Ranch Hand

Joined: Aug 27, 2001
Posts: 94
The user must be able to search for every field using
an arbitrary combination.
But it is not THAT difficult. My solution took about 50 lines.
Have fun!

Marco Barenkamp<br />_ _ _ _ _ ________________________ _ _ _ _ _ <br />L M I N T E R N E T S E R V I C E S AG<br /> <br />Head of Software Development<br /> <br /> <br />BEA Certified Enterprise Developer<br />Sun Certified Programmer for the Java2 Platform<br />Sun Certified Web Component Developer for the Java2 Platform<br />Sun Certified Developer for the Java 2 Platform <br />Sun Certified Business Component Developer for the Java 2 Platform <br />Sun Certified Enterprise Architect for the Java 2 Platform Enterprise Edition<br /> <br />LMIS AG
Raju, Gentle

Joined: Sep 06, 2001
Posts: 28
Hi Marco Barenkamp,
Thanks for the reply. When you say arbitrary combination, does that mean any kind of query should be handled. I can write a
method that can parse the string and arrange them in some order and I can create a method like find and get the results. This will work as long as you use on "filedName=Value" in the criteria string and do not repeat the same filed two time in the query. Also user can enter these fields in all or some and in any order. I can write a method that can handle this requirement.
My Question is: Are we expected to handle
AND, OR < > and etc operators in the criteria String.
For Example:
Origin='DEN' OR Origin='SFO' AND Price > '400' AND Price < 1200.
Queries like this will be very difficult to parse and method requires a lot of intelligence.
You�re Comment please

[This message has been edited by Raju, Gentle (edited September 17, 2001).]
Pratibha Gayake

Joined: May 08, 2001
Posts: 29
I think handling AND, OR, <> in the criteria String will complicate the matter, and which is not required in the assignment.
I think you should consider only "if the name/order/number of the fields is/are changed" then the method criteriaFind() should handle that without changing the implementation.
According to me this is generic implementaion of criteriaFind().
Terry McKee
Ranch Hand

Joined: Sep 29, 2000
Posts: 175
I have approached the criteriaFind method in the following manner:

  • Parse the criteria into field / value combinations (Utility Class)
  • Locate the position within the datasource for each field being searched. (If there is an invalid field the method returns with null).
  • Search the datasource for the actual value for the associated field.
Raju, Gentle

Joined: Sep 06, 2001
Posts: 28
Thanks Mark, Pratibha, Terry
[This message has been edited by Raju, Gentle (edited September 18, 2001).]
I agree. Here's the link:
subject: CriteriaFind Confusion
It's not a secret anymore!