Hi there,
I am posting how I am going to implement the
public long[] findByCriteria(String[] criteria) to know Is my approach reasonable or do I need some changes.
For each search Name, Location, Name or Location, Name and Location client has separate form.
Clint will call findByCriteria(String[] criteria) if it was from the search Name form then {"ABC", null, null, null, null, null} if location then {null, "Can", null, null, null, null} if Name and/or location {"ABC", "Can", null, null, null, null} will be set in the array (to pass String[] criteria) now control will transfer to findByCriteria() method in data file. Here it will check does first element in array has (non null)value then need to call Search(name) or 2nd has value then call Search(location) or 1st and 2nd both have values then call Search(name, OrLocation) ) / Search(name, andLocation) (or any of array item is non null). then according to array elements it will call Search(name), Search(Location), , (Search(specialty), Search(size), ...). These all methods I'll keep in another file. so findByCriteria() actually only tranfers control to the appropriate method in another file, is it okay.
If 1st value in array will non null then Program'll get it know that it need to search by name. If 2nd value in array will non null then Program'll get it know that it need to search by location.
Now problem is when it is Name or Location / name and Location then how to differenciate or/and to call the exact method.
I am thinking to pass and extra value in array (String[] criteria) to tell "Or condition will apply/ and condition will apply" Is it right or how should I recognize the and/or condition.
PS:
One function may also be enough that search according to any one or more non-null value(s) but still thinking how to identify AND/OR. may be instance variable or pass some extra value in array parameter
Thanks! in advance
Best Regards