my dog learned polymorphism*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: URLyBird1.1.3, about the find method in Data class. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX: URLyBird1.1.3, about the find method in Data class." Watch "NX: URLyBird1.1.3, about the find method in Data class." New topic
Author

NX: URLyBird1.1.3, about the find method in Data class.

Jamy Wang
Ranch Hand

Joined: Sep 21, 2003
Posts: 83
I'm a little confused about the find method in DB interface:

public interface DB
{
...
// 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);
...
}

My question is : should I return the records which has been set the deleted flag?
Thanks a lot!
James


Best Regards<br /> <br />SCJP1.4 SCJD1.4 SCEA
Satish Avadhanam
Ranch Hand

Joined: Aug 12, 2003
Posts: 697
Hi James here's how we should intrepret that. Say suppose "criteria" is a String array of length 7(it depends on the number of fields in each record of your assignment), then if you call find like below

The above search exaclty gives one record and so only that particular record number is returned in integer array.
Suppose now the criteria is like this

Now all of the hotels with "Hilton" as their name in db file are returned. We shuold treat "null" as "*" i.e. wild card match.
If criteria is

Now as all null, the entire db records(to be specific, record numbers) should be returned from find method.

My question is : should I return the records which has been set the deleted flag?
Thanks a lot!
James
Nope. Deleted flags are treated to be deleted. I tried to explain with some examples above. If you have any questions, please ask them. Good Luck
George Marinkovich
Ranch Hand

Joined: Apr 15, 2003
Posts: 619
Hi James,
Originally posted by james wang:
My question is : should I return the records which has been set the deleted flag?

I agree with Satish, deleted records should never be returned. The only use for a deleted record is in the create method where the space taken by a deleted record can be reused to store the new record. Deleted records are skipped when doing a find. Attempting to access a particular deleted record in the other database methods should cause the RecordNotFoundException to be thrown.


Regards, George
SCJP, SCJD, SCWCD, SCBCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX: URLyBird1.1.3, about the find method in Data class.
 
Similar Threads
search method in business layer
How deep is the automatic failure analyze?
about the search method
NX: Contractors Search
URLyBird: about find method.