This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

criteriaFind()

 
Padmaja Prasad
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • 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
 
Thomas Fly
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic