Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

find(String[] criteria)

 
Tony Bouer
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please, help me with this confuse sentence:
A null value in criteria[n] matches any field.
My doubt is if I send a null value at any possition it does mean that I'm going to have all records included in my return array.

I'm a bit confused !

Tks,
Tony





 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a small method that compares two arrays according to the findByCriteria(String[]) specification.

I compare field by field, if one criterium is null, then assume the comparison is true. If the criterium is non-null then I compare them using the String.startsWith() method.

If all the field comparisons are true (either because the criterium is null or the criterium matches the field), then I add the field number into the long[] required by the findByCriteria() method..

Therefore If I pass an criteria[] that just contains nulll valuse I would get all the records back. On the other hand, I just provide one criterium in the criteria[] and not even one record matches, then the method findByCriteria should return an empty array.
[ July 31, 2006: Message edited by: Edwin Dalorzo ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic