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 Question regarding string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "CriteriaFind Question regarding string" Watch "CriteriaFind Question regarding string" New topic

CriteriaFind Question regarding string

Lisa Foster
Ranch Hand

Joined: Feb 28, 2001
Posts: 116
In my criteria find it works find but I must say
in my instructions
the string is "Carrier='SpeedyAir',Origin='SFO'"
but what I do is populate my comboBoxes origin and destination with all origin and destination not allowing duplicates.
In my CriteriaFind I pass a string such as below:
String criteria = new String(origin+","+destination);
although its not the same but it works find I use the StringTokenizer an it works find but I dont have = as others have talked about
"Carrier='SpeedyAir',Origin='SFO'" Suns Example
"origin+","+destination" my example I dont search airlines specifically just origin and destination...
Is this OK??
Thanks Lisa
Debajyoti Pathak
Ranch Hand

Joined: Dec 18, 2000
Posts: 39
the specification mentions the format in which you have to pass the query string to criteriaFind method. Why would you want to change that ? Your approach may work but in my opinion you should not change the format of the query string unless you have a very good reason to do so.
Lisa Foster
Ranch Hand

Joined: Feb 28, 2001
Posts: 116
I can appreciate that, should I hardcode the fields in then parse it with the String Tokenizer class???

Such as "Origin='FRA',Destination='SFO'"
Thanks Lisa
Rudy Yeung
Ranch Hand

Joined: Dec 27, 2000
Posts: 183
In your criteriaFind() method, you can use two StringTokenizer to break down the criteria into a whole bunch of key/value pair like Origin/SFO. You can then store those pairs in a vector or arraylist, and then pass it to your find() method for a linear search.
I agree. Here's the link:
subject: CriteriaFind Question regarding string
jQuery in Action, 3rd edition