aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes URLyBird : about the requirement of search function. 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 "URLyBird : about the requirement of search function." Watch "URLyBird : about the requirement of search function." New topic
Author

URLyBird : about the requirement of search function.

Ronggen Liu
Ranch Hand

Joined: Jul 29, 2007
Posts: 40
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


SCJP 1.4,<br />SCJD Java 2,<br />...
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2267
    
    3

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 ]

Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Ronggen Liu
Ranch Hand

Joined: Jul 29, 2007
Posts: 40
Roberto, Thank you for your reply, i'm clear now.

Thank you!
Ronggen
Ronggen Liu
Ranch Hand

Joined: Jul 29, 2007
Posts: 40
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

Joined: Dec 28, 2007
Posts: 2267
    
    3

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.
Jo�o Batista
Ranch Hand

Joined: May 25, 2008
Posts: 40
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

Joined: Dec 28, 2007
Posts: 2267
    
    3

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].
Joyce Lopez
Greenhorn

Joined: Jun 08, 2008
Posts: 5
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
Aaron John
Ranch Hand

Joined: May 30, 2005
Posts: 74
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

Joined: Dec 28, 2007
Posts: 2267
    
    3

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

Joined: Jun 08, 2008
Posts: 5
thanks guys..
Chih-Wei Lee
Ranch Hand

Joined: Feb 20, 2008
Posts: 129
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".


SCEA, SCJD, SCDJWS, SCWCD, SCJP
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2267
    
    3

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

Joined: Jun 08, 2008
Posts: 5
hi,


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


as mentioned in the The User Interface.

regards!
Joshua Fix
Ranch Hand

Joined: Sep 18, 2007
Posts: 57
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.


SCJP 5.0
Jo�o Batista
Ranch Hand

Joined: May 25, 2008
Posts: 40
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

Joined: Dec 28, 2007
Posts: 2267
    
    3

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

Joined: Sep 18, 2007
Posts: 57
I completely agree
Jo�o Batista
Ranch Hand

Joined: May 25, 2008
Posts: 40
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

Joined: Jul 29, 2007
Posts: 40
agree...
Anirban Das Gupta
Greenhorn

Joined: May 13, 2008
Posts: 28
Yes, I agree.

Anirban
SCJP(1.4)
[ June 26, 2008: Message edited by: Anirban Das Gupta ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URLyBird : about the requirement of search function.