• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

B&S - Searching

 
Michael Skog
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thought about the requirements of the Data interface combined with the requirements of the GUI.

The GUI:
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.

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

Which would mean in my opinion that the findByCriteria method of the Data class will be practically useless. Am I right?
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11853
185
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael,

I didn't think the B&S assignment had a findByCriteria method in the Data class. Can you provide any more information on it?

Regards, Andrew
 
Surya De
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew is right. Could you please clarify? I am most interested.

Cheers!
Surya
 
Slava Garin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm also working on B&S assigment. And yes, there is "findByCriteria" method.

So, my business search method first calls Data.findByCriteria, than reads all records this method returned and displays records with exact matches only...
 
Surya De
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So am I to take it for example when you are creating the entire tablemodel for all the records...your business method calls the read method a whole bunch of times? The read method is I think specified in the DB file of B&S.

Surya
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11853
185
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Slava,

I assume that this method replaces the find() method that is in my copy of the B&S assignment:So - back to Michael's question / comment:
Which would mean in my opinion that the findByCriteria method of the Data class will be practically useless. Am I right?
Do you also have the comment "Field n in the database file is described by criteria[n]" (see my code snippet)?

I think what we have here is another case where Sun's instructions require interpretation (Sun have indicated that there are places where they have deliberately left confusing instructions just to force candidates to show that they can get through them).

So, while the sentence you picked out, and the words you highlighted, make it appear that the findByCriteria() method (and the find() method in my case) are going to return far too much, the earlier sentence indicates (to me) that a better interpretation would be: "A non-null value in criteria[n] matches any record where field[n]'s value begins with criteria[n]."

Does that make sense?

Regards, Andrew
 
woo sung
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wnat to make sure about discussion above.
I am doing B&S 2.1.1.

I have
"public int[] find(String[] criteria)."

And I have a sentese in The User Interface specification:
"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."

In the DB schema, name is first field and location is second field.

Therefore, can i call find method like :
String[] criteria = new String[];
criteria[0]="fred";
criteria[1]="adel";

int[] returnResult = DBImp.find(criteria);

and result will have int array of record numbers matching the value in name field( i.e both of "fred" and "freddy") and/or match the value in location (i.e both of "adel" and "adelaide")

Am i right?

another question is about "AND/OR" in "where the name AND/OR location fields exactly match values specified by the user."

I have no idea how i can make code "name and location" and "name or location".
if i pass the criteria array value below

String[] criteria = new String[];
criteria[0]="fred";
criteria[1]="adel";
criteria[2]="and"; or criteria[2]="or";

do you think it will be fine?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic