File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes criteriaFind() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "criteriaFind()" Watch "criteriaFind()" New topic
Author

criteriaFind()

Padmaja Prasad
Ranch Hand

Joined: Nov 14, 2001
Posts: 76
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

Joined: Sep 09, 2002
Posts: 164
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.


Fly by Night Consultants<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr><i>I climbed on the back of a giant albatross<br />which flew through a crack in the cloud<br />to a place where happiness reigned...<br />all year 'round<br />the music played ever so loudly!</i><p><a href="http://thomasfly.com/songs/Traffic/Hole_in_my_Shoe_qt.htm" target="_blank" rel="nofollow">Hole in My Shoe</a><hr></blockquote>
Padmaja Prasad
Ranch Hand

Joined: Nov 14, 2001
Posts: 76
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

Joined: Sep 09, 2002
Posts: 164
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

Joined: Nov 14, 2001
Posts: 76
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: criteriaFind()