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

NX: Contactor: Query on Search method

Manoj Gundawar
Ranch Hand

Joined: Nov 17, 2002
Posts: 169
Hi all,
In the interface provided by Sun, the search method is:
public int[] find(String[] criteria
1. Suppose in my GUI I have a search option, with two textfields, one for name and one for location.
As user enters name I can search for name and same for location.
2. But when users enter both 'name' and 'location' how to decide weather to search for 'name and location' or 'name or location' ?
(this is first question)
'Name and location' search will result into smaller result compared to 'name or location'
Also another doubt.
The interface comments for this methods are:
// 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".)

Here it says this, which is not in synch with what it says at other place in the doc. Somewhere in the doc it says:
"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. "

Here it says it should exactly match.
So how you guys are interpreting this one? (this is my second question)
[ August 05, 2003: Message edited by: Jmannu gundawar ]

Manoj<br />SCJP, SCJD, SCWCD, IBM WSAD.
Ta Ri Ki Sun
Ranch Hand

Joined: Mar 26, 2002
Posts: 442
1) if the user provides name and location then search for both, ie AND
2) provide the user with a drop down which will meet the exact match because he/she can only select values already in the database, however on the backend you can check if it starts with the given criteria and as a result satisfying Sun's ambiguous spec.
Manoj Gundawar
Ranch Hand

Joined: Nov 17, 2002
Posts: 169
Thanks Ta Ri Ki Sun,
I guess I will use the AND condition. But idea of drop down dosent sound good to me, as it is like loading the whole DB there. Anyway.. thanks.
Manoj
Manoj Gundawar
Ranch Hand

Joined: Nov 17, 2002
Posts: 169
Any more ideas on this one?
Manoj
Ta Ri Ki Sun
Ranch Hand

Joined: Mar 26, 2002
Posts: 442
Originally posted by Jmannu gundawar:
Thanks Ta Ri Ki Sun,
I guess I will use the AND condition. But idea of drop down dosent sound good to me, as it is like loading the whole DB there. Anyway.. thanks.
Manoj

you dont have to load the entire DB, I only load the first 100 on startup, which really is the entire DB for this DB as it is now, but only if the user provides empty search criteria do I supply everything
George Fung
Ranch Hand

Joined: Jun 12, 2003
Posts: 98
I will write another API find for seraching exact criteria... It's more efficient and faster


SCJP, SCJD, SCWCD, SCBCD, SCEA, SCJP6
To be obtained: SCEA 5
George Fung
Ranch Hand

Joined: Jun 12, 2003
Posts: 98
I will write another API find for seraching exact criteria... It's more efficient and faster
Manoj Gundawar
Ranch Hand

Joined: Nov 17, 2002
Posts: 169
Thanks.
But I dont think I need API just for this. I could achieve this with very small amount of code.
1. I take search parameter along with the string to be searched. For ex
String criteria [] will contain "Name" and "Mannu", if the search is to be made on name, "LOC" "LA" if it is for LOcation and Both and 2 strings for name and location. (this is in reference to the Contractor assignment)
And the code to find is pretty small. Just 3-4 lines:
The core for it is:
((record[k].indexOf(find2)) == 0))
(record is one file record)
Where record[k] is first or second string of the file record based on Name or location criteria. find2 is the string provided.
I guess this will work for me.
Thanks,
Manoj
[ August 07, 2003: Message edited by: Jmannu gundawar ]
[ August 07, 2003: Message edited by: Jmannu gundawar ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX: Contactor: Query on Search method
 
Similar Threads
URLyBird: What is "exactly match" in URLyBird?
Do we need to filter the search result data?
URLyBird 1.2.1 findByCriteria()
how to define criteria for search
Urly bird find method: are search criteria "and"- or "or"-composed?