Hi chaps
Just starting on the project, and thought that I'd start with criteriaFind(). I'm modifying Data to do this (as it seems the right place to put it), and my implementation is very simple: I use a private method to tokenize the criteria
String into a Map of name/value pairs (searchMap), and then I loop over all the records and use a second private method to turn each record into a second map (recordMap). I compare the two with
The whole implementation is about 25 lines of code. This seems to work fine, and implicitly satisfies the requirement that a criteria string with invalid field names returns no entries (as containsAll will never match). However, I'm wondering how much sanity checking I should do when parsing the criteria String? The GUI should always drive it correctly, but as criteriaFind is completely generic it should presumably defend against invalid criteria Strings (e.g. "Origin ="), duplicates ("Origin='LHR',Origin='SFO'", although I guess it could OR), nulls etc. How far do I need to go with this, and is it better to treat invalid selectors as producing no matches (i.e. return an empty DataInfo array, as is the case for unknown field names) or should I throw an InvalidSelector exception back to the user?
Also, I presume that it *is* OK to add short private utility methods to the Data class? It remains completely generic, and splitting criteriaFind up makes the code much easier to read.
Finally, as an aside, I ran the Data class through JTest and there are 5 uncaught Runtime exceptions (NullPointer, ArrayIndexOutOfBounds, NegativeArraySize). Are these worth fixing?