• 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

URLyBird : about the requirement of search function.

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the GUI part of my instruction:
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.

i have some doubt about 'search the data for all records', i understand it as to retrieve the all records.

so i implement it use two combobox(hotel name and location), and if the use just selected the hotel name, i will search the records with hotel name, if the use selected the location, i will search the records with location, if the use selected two of them, i will search the records with hotel name and location, and if the use didn't selected any of them, i will retrieve the all records.

but i saw somebody understand it as 'full search', i think it means that the use can input a search text(in a JTextField), then match it with all the fields(hotel name,location,size,smoking,date,owner) of the record; if it's match, then return it.

is there any i lost?

Thank you!
Ronggen
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey, partner.

I think I understood what you did. But how about the situation where the user selects hotel name and hotel location (in your implementation, it will perform the "and" search), but he wants to search for the hotel name OR the hotel location? The user wants to perform an "or" search, but he selected these two values... maybe this is a situation to be considered again.

For my full search, I simply retrieved all records. The search that the Data class performs is different from the one that your business layer performs. Here's the signature of my find method of my DBMain interface:



A non-null value in criteria[n] matches any field value. So if you provide criteria[0] = "2005/04/06"; (even if this value should be in criteria[5], since this is the available date of the room, or the 6th field of a record), it still has to retrieve all records that have this value "2005/04/06" in any of the fields... here, you must use the startsWith(). Then, in your business layer, you check if the records retrieved have the right values in the right places; in other words, you filter the results... you check if each record have the searched hotel name and/or hotel location.

I hope this helps!
[ May 27, 2008: Message edited by: Roberto Perillo ]
 
Ronggen Liu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Roberto, Thank you for your reply, i'm clear now.

Thank you!
Ronggen
 
Ronggen Liu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Roberto, but, how do you understand the following description of find method:



it seems in your implementation, the criteria[n] doesn't indicate the field n in the database file, right?

and about the 'or' search, i think we can understand it as 'search the data for filed name or search the data for field location.', so i had implemented it, right?

Thank you!
Ronggen
 
Roberto Perillo
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey my buddy, sorry for the late response.

Roberto, but, how do you understand the following description of find method:



It means that the nth field in the String array represents the nth field of a record. For instance:



String [] criteria = {"Ronggen", null, null, null, null, null, null};

So each of the values represents the corresponding field of a record. However, by the statement:



It means that the nth value of your String array matches any of the fields, no matter where it is. That's why you need to filter it in your business layer. So, using the example of the record above, if you provide:

String [] criteria = {"$150.00", "2005/07/27", "Y", "2", "Smallville", "Palace", null}

The record has to be retrieved, simply because criteria[0] matches the 4th field of the record.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aren't you saying that criteria[n] should be matched against all the record fields, thus negating the sentence "Field n in the database file is described by criteria[n]"?

I'm affraid I got confused by your post, because by those two sentences in instructions, I read that criteria[] and record[] must match in size, as criteria[n] maps to record[n].
 
Roberto Perillo
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, to me, "Field n in the database file is described by criteria[n]" means that the search criteria should have the same number of fields of a record, and "A non-null value in criteria[n] matches any field value that begins with criteria[n]" means that any value in criteria[n] should match any field that is different from null and that starts with criteria[n].
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys,

am a little confused with posted replies on search, from what i understand
it only allows the search of either "name" and/or "location" and not of all fields.

am thinking of having 2 textfields (name & location) and a button, all in the same line. Is this layout user friendly enough?

can someone please comment ...

regards,
Joyce
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Roberto Perillo:
Well, to me, "Field n in the database file is described by criteria[n]" means that the search criteria should have the same number of fields of a record, and "A non-null value in criteria[n] matches any field value that begins with criteria[n]" means that any value in criteria[n] should match any field that is different from null and that starts with criteria[n].



Again, I have interpreted this differently. However your interpretation is also valid to me, so I believe justifying your interpretation as a design decision has to be done. My interpretation is:

* Field n in the database file is described by criteria[n].
I have interpreted this to mean: field[0] in the database file is described by criteria[0]. In the B&S assignment, field[0] is the name field. To search by name, the appropriate element in the criteria array must be used, i.e. criteria[0].

* 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".)
I have interpreted this to mean: A null value in criteria[0] matches any value in field[0]. A non-null value in criteria[0] matches any value in field[0] that begins with criteria[0], ignoring case sensitivity. For example, criteria[0] is "dog". It will match any value in field[0] beginning with "dog", such as "Dogs with Tools", "Dog and Cat care", "Doggolono Sellers Ltd"
 
Roberto Perillo
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is almost what I said. For instance, criteria[0] describes field[0] (which in the URLyBird assignment is also the "Name" field). That's what I had said. However, by the statement "A non-null value in criteria[n] matches any field value that begins with criteria[n]", to me it clearly says that criteria[n] matches any field value (any, no matter its position) that starts with criteria[n]. So, for instance, criteria[0] can match field[4] if field[4] starts with criteria[0].
 
Joyce Lopez
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks guys..
 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Roberto Perillo:
This is almost what I said. For instance, criteria[0] describes field[0] (which in the URLyBird assignment is also the "Name" field). That's what I had said. However, by the statement "A non-null value in criteria[n] matches any field value that begins with criteria[n]", to me it clearly says that criteria[n] matches any field value (any, no matter its position) that starts with criteria[n]. So, for instance, criteria[0] can match field[4] if field[4] starts with criteria[0].



"A non-null value in criteria[n] matches any field value that begins with criteria[n]"
means

A non-nul value in criteria[n] matches "any value in field[n]" that begins with criteria[n]

It doesn't make sense you have criteria "Name" matched field "Size".
 
Roberto Perillo
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Chih-Wei Lee:
It doesn't make sense you have criteria "Name" matched field "Size"



Yeah, I know it doesn't. I believe this is one of the points of the assignment that can be interpreted in many ways. I believe the best thing to do here is to justify what you did based on your understanding. Maybe the statement "A non-null value in criteria[n] matches any field value that begins with criteria[n]" suggests that the order of the fields of the database may change in the future.
 
Joyce Lopez
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,


matches ANY field value that BEGINS with criteria[n] (refers to "EITHER" name or location)



as mentioned in the The User Interface.

regards!
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it's like a broken record topic...

Field n in the database file is described by criteria[n]



A non-null value in criteria[n] matches any field value that begins with criteria[n]



this is one of the points of the assignment that can be interpreted in many ways



These statements seem to contradict each other. The first one just makes more sense to me. I interpret the second statement to mean "any field[n] value that begins with criteria[n]", and I documented it accordingly. I also interpret the requirement to imply that it is an "AND" search, where I am looking for results where field[n] begins with criteria[n] AND field[n+1] begins with criteria[n+1], etc.
 
Jo�o Batista
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Joshua Fix:
These statements seem to contradict each other.



It's an unfortunate play of words. The "any" in "any field value" is referring to "value", not "field". If you go that way it does not contradict the previous sentence.
 
Roberto Perillo
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

It's an unfortunate play of words. The "any" in "any field value" is referring to "value", not "field". If you go that way it does not contradict the previous sentence.



Hahahahaha!!! I just cannot believe it!!!



Since criteria[n] describes field[n], what Joao said totally makes a lot of sense. Any value that appears in criteria[n] will match field[n], as long as field[n] starts with criteria[n]. I can't believe I almost got screwed here! That is what it was saying all the time!

Does everybody agree that any value that appears in criteria[n] will match field[n], as long as field[n] starts with criteria[n]?
[ June 18, 2008: Message edited by: Roberto Perillo ]
 
Joshua Fix
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I completely agree
 
Jo�o Batista
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hehe, glad to help. You made me suspicious that this point would need a bullet in choices.txt. Nice to agree on that point now!
 
Ronggen Liu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
agree...
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I agree.

Anirban
SCJP(1.4)
[ June 26, 2008: Message edited by: Anirban Das Gupta ]
 
Hang a left on main. Then read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic