• 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
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

criteriaFind()

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Is there any harm if I implement the criteriaFind() method in Data class (as sync'd method)? I have seen some posts here stating that they implemented this method in their Local & Remote Data implementation classes. What is the significance of implementing the search method in local & remote data classes over implementing in Data class??
Also, the parameter String passed to this method is of the form:
"carrier='speedy air', Origin = 'DEN'"
Whether the method implementation should solve parameters like "carrier = 'speedy, air'"?(a comma inside the string value)
Thanks in advance
Padmaja
 
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's where I implemented it- and after all, that's where Sun puts the template for it.
I don't see where it absolutely has to be synchronized however, since you'll likely just looping through already synchronized readRecord's, and you may as well give other clients a chance to slip in and do some work.
As for badly formatted search strings, the requirements say that your search only needs to succeed if the search criteria are an exact match.
 
Padmaja Prasad
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Thomas.
Regarding badly formatted search string, if a carrier name contains a comma or if the user mistakenly types a comma in the search string, whether my criteriaFind method should deal with this??
Thanks
Padmaja
 
Thomas Fly
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I just checked, and in fact Sun does not put a template in Data for criteriaFind. However, your criteriaFind will likely work a whole lot like (or make use of) the existing find(String toMatch) method, which suggests that the Data class is not an obviously bad place to put criteriaFind.
You're responsible for parsing the search string. Again, if it fails to follow the prescribed syntax however, then something or other will fail somehow- just like something will fail if you put "if (x = 1)" in your program code and then try to compile.
You might want to take a look at SCJD Study Companion
 
Padmaja Prasad
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Thomas Fly:

You're responsible for parsing the search string. Again, if it fails to follow the prescribed syntax however, then something or other will fail somehow- just like something will fail if you put "if (x = 1)" in your program code and then try to compile.


Can I assume that there will not be any comma in the text values inside the database (like "Carrier = 'speedyair, california'" - This will be an error?). Because neither DataInfo nor Data class are checking this condition before adding records.Ofcourse, the currently available records are not violating this.
I am using StringTokenizer to parse the String argument.Is there any other better approach??
Thanks
Padmaja
reply
    Bookmark Topic Watch Topic
  • New Topic