• 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 String

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Hi Ranchers, I have quick couple of questions regarding criteriaFind()
Here is what my criteriaFind does ....

if(emptyString) {

return all rows;
} else {
parseCriteria();

return appropriateRows
}
Here are my questions:
1) Is the above logic fine ? My precise question is : We need to treat the
case of "Empty String" seperately .. is that right ..?
2) a) Should my criteriaFind be generic enough to support this kind of argument to criteriaFind ?


"Carrier='Travel's,Inc',Destination airport='SFO'" ..?
Please, carefully look at the value of the carrier ....

b) Another related question: As we are storing the values for the fields in the database as "SFO", what we are doing
when thw user sends string "Destination airport='SFO'" is, we are essentially, stripping off
it into "SFO" and comparing instead of stripping it into "'SFO'" and comparing... is that right ..?
Please,clear this confusion for me.
Thank You guys,
Regards,
Krishna Varma Adluru
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
For my case,
1) I didn't handle the empty string as I think the requirement says that other than 'Any', only exact match needs to be handled.
So, I thought that there wouldn't be an exact match for an empty string
2) a) I handle the ' within a String. I use a CriteriaParser to parse the Criteria string to handle the Key/Value pair accordingly and return it to the calling method.
b) I think stripping the beginning and ending ' must be the case. Otherwise, there won't be an exact match for 'SFO' in the database.
Hope this helps.
Han Ming
 
Krishna Varma Adluru
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HanMing Low,
Thank You very much for the reply. Your answer cleared my 2nd question. But, my 1st question is still valid.
Let me give an example.
If we need to search for "ANY" carrier, "ANY" origin airport, "ANY" destination airport, then there is NO specific query. So, we need to pass
an EMPTY string to criteriaFind method and it needs to give all the records in the table.
Is my understanding correct ?
Thanks in advance.
Regards,
Krishna Varma Adluru
 
Krishna Varma Adluru
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HanMing Low,
Thank You very much for the reply. Your answer cleared my 2nd question. But, my 1st question is still valid.
Let me give an example.
If we need to search for "ANY" carrier, "ANY" origin airport, "ANY" destination airport, then there is NO specific query. So, we need to pass
an EMPTY string to criteriaFind method and it needs to give all the records in the table.
Is my understanding correct ?
Thanks in advance.
Regards,
Krishna Varma Adluru
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Is the above logic fine ? My precise question is : We need to treat the
case of "Empty String" seperately .. is that right ..?
That is absolutely correct. An empty criteria string means all records.
Mark
 
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont beleive an empty String is the same as ANY. EMPTY String is when the field is expected to be blank. So if Origin="" then the criteria means find me those flights only whose Origin is a blank. ANY is a wild card like *. Only exact matches were specified.My 2cents here.
 
HanMing Low
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Krishna,
Yup, I think I miss your point for the second part.
For my case, I did handle ' within the ' '.
But I guess so long you document your limitation in your documentation if you decide not to support it, then you should be fine.
As for the empty string, my interpretation is the same as Kalichar where empty does not means Any. The calling method has to specifically specify 'Any' to have the wildcard.
Again, I think if you document it, then you're fine.
Hope that helps.

Han Ming
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What record in your db.db file is blank? None, so don't go overboard
Mark
 
Willie Smits increased rainfall 25% in three years by planting trees. 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