aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S - Searching 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 "B&S - Searching" Watch "B&S - Searching" New topic
Author

B&S - Searching

Michael Skog
Greenhorn

Joined: Jan 16, 2006
Posts: 3
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?


SCJP<br />SCJD<br />SCBCD
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11279
    
  59

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


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Surya De
Greenhorn

Joined: Nov 06, 2005
Posts: 28
Andrew is right. Could you please clarify? I am most interested.

Cheers!
Surya
Slava Garin
Greenhorn

Joined: Dec 23, 2005
Posts: 3
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...


SCJP<br />SCJD (B&S in progress)
Surya De
Greenhorn

Joined: Nov 06, 2005
Posts: 28
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

Joined: Mar 28, 2003
Posts: 11279
    
  59

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

Joined: Dec 09, 2005
Posts: 6
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: B&S - Searching
 
Similar Threads
find method in B&S
NX URLyBird 1.3.2: Discrepency in find interface with specs.
Another Question about findByCriteria
[NX] Question about the findByCriteria.
URLyBird 1.2.2: findByCriteria()