This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes criteriaFind method question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "criteriaFind method question" Watch "criteriaFind method question" New topic
Author

criteriaFind method question

Randy Valadez
Greenhorn

Joined: Feb 08, 2001
Posts: 21
Are we suppose to create this function and place it in the data class. Also do we only use this function for an exact match or to populate all records via a wild character such as *.* or all?
etc etc... Thanks any examples of this search method would be appreciated.
Thanks Randy.
Lisa Foster
Ranch Hand

Joined: Feb 28, 2001
Posts: 116
Hi I have the same question I just started my assignment.
Any Help graetly appreciated for I am new to Java.
Thanks Lisa
Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
criteriaFind method is a method that you need to implement. It basically does the searching of the database. A client will enter a query "Original ariport=SFO", it should return all records that have SFO as its' Original airport.
The "any" criteria is just like a wild card.
Lisa Foster
Ranch Hand

Joined: Feb 28, 2001
Posts: 116
Thanks alot I believe I will use the find method and use alot of its implementation in my criteriaFind method. Am I on the right track?
Thanks Lisa
Rudy Yeung
Ranch Hand

Joined: Dec 27, 2000
Posts: 183
In my opinion, you are not able to use the given find() method to implement your criteriaFind() because it is of limited usuage. For my case, I overload the find() method to extend the usuage, and call ed overloaded find() method from within the criterFind() method.
Hope this helps.
Rudy
Ihor Strutynskyj
Greenhorn

Joined: Mar 28, 2000
Posts: 22
Rudy,
If you call find() from criteriaFind you will be searching
the whole database per EACH column in your search criteria.
More efficient way would be to use the code from find()
as an example of how to write criteriaFind() which will
do one database scan per all columns in the search criteria.
Sun does look at the efficiency of criteriaFind.
Regards, Ihor
Rudy Yeung
Ranch Hand

Joined: Dec 27, 2000
Posts: 183
Ihor,
My overloaded find() method will not scan the whole database per column. Instead it will scan the whole database per record. Simply speaking, I have the criteriaFind() method tokenizes the string criteria passed in. The tokenized criteria in the form of key/value pair will then be passed into my overloaded find() method in the form of a collection object like vector. Inside my overloaded find() method, I will read record one by one, and any record that does not satisfy the criteria specified in the collection object will be skipped.
Please feel free to give comments or any better way to improve the efficiency based on my approach.
Rudy
Ihor Strutynskyj
Greenhorn

Joined: Mar 28, 2000
Posts: 22
Rudy,
Now it's more clear what your overloaded find() does. I did the same but inside the criteriaFind() with the little difference that my criteria is stored in the array of ArrayLists which is a bit more efficient to traverse than synchronized Vector. I also keep separate int[] of indexes for even faster scanning of search criteria.
Regards, Ihor
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: criteriaFind method question
 
Similar Threads
Synchronized block
Web Services submit method?
Execution time of a function using log4j
Delete/Add record
Browser back button problem