aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes question on 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 "question on criteriaFind()" Watch "question on criteriaFind()" New topic
Author

question on criteriaFind()

Prakash Krishnamurthy
Ranch Hand

Joined: Oct 08, 2002
Posts: 154
Hello everybody,
I am having a problem with the criteriaFind method. I have reached a point where I have parsed the string argument that has the criteria String. So say for example the criteria is "Carrier='Speedy Air',Origin='SFO'" . I have parsed the string to,say for example, temp[0]=Carrier temp[1]=Speedy Air temp[2]=Origin an so on and so forth.
My question is how do you use the find method to say "where column Carrier=Speedy Air"? Or is it an assumption on my part that there is a need to use the find mehtod that they have.
The other reason is because, I wrote a sample program which did a find on "SFO" and "carrier" and it did not find anything.
I need to get this done today. ANy suggestions would help a lot
Prakash
Dave Teare
Ranch Hand

Joined: Oct 09, 2002
Posts: 80
I extended the Data class and created a criteriaFind method that takes a single String as an argument (as per the instructions). This method parses the incoming Sting to determine what the flight destination and origin are, and then calls a private method findFlights(origin, destination).
The findFlights method then simply iterates through all the Flights within the database, looking for a match, as in the following code:

I am not terribly happy with the performance of this implementation, but hey, we have to work with the database we were given. If we were based on Oracle or DB2, things would be better
Hope this helps!
--Dave.
Vikas Sood
Ranch Hand

Joined: Sep 03, 2002
Posts: 109
HI Dave,
Your implementation though correct in essence is not a ideal implementation for criteriafind,We need to have a generic implementation of criteria find as these set of classes might be used with other datbase files in future ,and if u have something specific to FBN in these classes then that future enhancement will require lot of rework and rethinking.
VikasSood
Dave Teare
Ranch Hand

Joined: Oct 09, 2002
Posts: 80
My search code was implemented within my FlightData class which extends the Data class. That is why I thought it was okay for me to make the search flight specific.
However, others have mentioned that the criteraFind(String) method should be able to handle the matching of all fields, not just origin and destination (as per the UI requirements)
Given this, do you recommend that we implement a generic criteriaFind within the Data class?
Vikas Sood
Ranch Hand

Joined: Sep 03, 2002
Posts: 109
HI Dave,
AS much as i get from whatever u have quoted above is that u are trying to create FBN specific implementation for Data services.I think we are supposed to provide a generic implementation as Sun talks about enhancement of this project so as to cater to wider requirements.If u make it specific to FBN than u are not following the spec fully.And for the criteriaFind method i would say u need a generic search that will beahve the same even when we go in for a different database file instead of the FBNdatabase file.
Hope it helps.
VikasSood
 
 
subject: question on criteriaFind()