aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes find method in the interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "find method in the interface" Watch "find method in the interface" New topic
Author

find method in the interface

Heilien Tsui
Greenhorn

Joined: Dec 08, 2008
Posts: 20
Hi All,

I am working on urlybird, the find method defined from the interface as this:
// Returns an array of record numbers that match the specified
// criteria. Field n in the database file is described by
// criteria[n]. A null value in criteria[n] matches any field
// value. A non-null value in criteria[n] matches any field
// value that begins with criteria[n]. (For example, "Fred"
// matches "Fred" or "Freddy".)
public int [] find(String [] criteria)

for the find method, i read some of the posts here. They are really useful, cleared most of my doubts.
I still thinking if i need to provide search function for all the room attributes, like date, max_occupancy, price and smoking.

if I add these attribute in the search function, does it mean that i need to use the startWith() for the criteria matching as indicate in the interface.
If I use equal() to match those parameters like price , date. will i violate the requirement ?




SCJP 5, SCJD 5, SCWCD 5, SCDJWS 1.4, SCBCD 5, SCEA 5
Nicolas Kal
Ranch Hand

Joined: Sep 09, 2009
Posts: 69
Heilien ,

In my instructions documents it specifies the following:

It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user.


It is you choise if you will choose to supply search criteria for all the fields, but the instructions sais that you sould provide for and name/location combinations.

Regards,
Nicolas


SCJP 6.0 , SBCD (Preparing..),
MSc Enterprise Systems Development, BSc Computer Science
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5402
    
  13

Hi Heilien,

In my opinion there is a difference between the implementation in your Data class of the find-method and the search criteria you provide in your GUI. My find-method in the Data class is able to search on every possible room attribute (and I tested its functioning with a JUnit test, just like all other methods of my Data class). But in my GUI I provide just the 2 required search criteria: name and location, so in my GUI I just have 2 input fields, 1 for each criterium.

Adding more search criteria now to your gui has no added value, because it is not required.

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Heilien Tsui
Greenhorn

Joined: Dec 08, 2008
Posts: 20
Hi Nicolas , Roel

thanks for the advice. I am planning to implement the find method for all attributes in the data class.
while in the GUI , only search for the location and hotel name for exact match.

in the data class, the interface specified that using
"Fred" matches "Fred" or "Freddy" as the example

In the data class, I think it is appropriate of using startWith() for hotelName and city
but for the maxOccupancy, smoking, price, date and customer using equal() exact match.
I am not sure if I should do this. The interface seems that it only restrict the find method to use startWith() for the search criteria


Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5402
    
  13

Hi Heilien,

I made in find-method no difference between location, name and the other ones, so all attributes were tested with startsWith. Because in the comments of the find-method there is also no difference:
A non-null value in criteria[n] matches any field value that begins with criteria[n]. (For example, "Fred" matches "Fred" or "Freddy".)


Kind regards,
Roel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: find method in the interface