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

Search feature

David Goate
Greenhorn

Joined: Jan 08, 2013
Posts: 7
Hi all,

I am implementing the search feature required by the interface that Oracle provides. The JavaDoc that Oracle also provides says something similar to the following:

A non-null value in criteria[n] matches any field value that begins with criteria[n]. (For example, "Bill" matches "Bill" or "Billy".)


My implementation currently performs a case sensitive match (essentially uses String.startsWith). From the point of view of implementing the required interface I believe that this code therefore passes the requirements. However, from a usability point of view for the user it is not very good as the search feature would not return any results for "bill", whereas it would for "Bill"...

I would much prefer to perform a case insensitive match, but I am nervous that I might violate a requirement of the Data class implementation and automatically fail. I would appreciate it if anyone could give any guidance on this.

Thanks,
David.
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2265
    
    3

Howdy, David!

I'd say this is pretty much a matter of choice, which you'll have to explain in your choices.txt file. For instance, you could say that you read the JavaDoc, and since it said "Bill" matches "Bill" or "Billy", you assumed that it had to be case sensitive, because of the 'B' character. Or you can also say that your search is case insensitive because it is more user friendly. Either choices are fine. I don't have my code here right now, but I think my search was case sensitive too (startsWith()).


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
David Goate
Greenhorn

Joined: Jan 08, 2013
Posts: 7
Thanks for the advise Roberto.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5266
    
  13

David Goate wrote:I would much prefer to perform a case insensitive match, but I am nervous that I might violate a requirement of the Data class implementation and automatically fail. I would appreciate it if anyone could give any guidance on this.

No need to be nervous: I implemented a case insensitive search in Data class and passed with full marks Of course in the GUI itself only the exact matches are shown when searching.


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
David Goate
Greenhorn

Joined: Jan 08, 2013
Posts: 7
Hi Roel,

Thanks for the reply and great to hear that you got full marks. I'm not very clear on what you mean by
Of course in the GUI itself only the exact matches are shown when searching.
I assume the search feature of your GUI utilised the search method in your Data class, therefore if your data class allowed case insensitive search, I would imagine that so did your GUI?

Thanks in advance for your time.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5266
    
  13

David Goate wrote:if your data class allowed case insensitive search, I would imagine that so did your GUI?

No, it does NOT. My Data class uses a case insensitive search. But according to instructions only exact matches should be shown in the table when searching. So the records returned by the find-method of Data class are filtered by my business service and only the ones exactly matching the criteria entered by the user are shown in the table.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Search feature