• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

find method in the interface

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?



 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Heilien Tsui
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic