• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

CriteriaFind Question regarding string

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Why am I so drawn to cherry pie? I can't seem to stop. Save me tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic