• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CriteriaFind Question regarding string

 
Lisa Foster
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lisa,
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.
Deb
 
Lisa Foster
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lisa,
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.
Rudy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic