In the event of an invalid field name being provided as part of the criteria the behavior of this method is the same as if no records matched correctly specified criteria.
Have you considered using a Map instead of your two lists?
Have you considered using StringTokenizer instead of the substring()/indexof()
I had thought to put the indexes and the values into a map, but when I go through all the records and do the comparing, I don't know how to take them out from the map one by one without knowing what is in the map.
Do you think this method is to big, and I should divide it into several little methods?
it is too easy for someone reading your code to be confused.
Your findByCriteria method works on an array of activeRecords. However there is nothing to stop additional records being added, or existing records being deleted while you are inside this method. Is this OK for you? Are you commenting this?
As with my comment to Damu - why are you iterating through the returnList to put the items it contains into an array, when the toArray() method will do this for you?
But if the records are deleted, after collecting list of active records, while reading the record with record number, it will throw RNF exception.
Originally posted by Andrew Monkhouse:
In you match() method - nice use of &= (last time I did that, my team spent 15 minutes reviewing 200 lines of code, and 45 minutes reviewing my use of &= ) but I wonder if it is worthwhile?
Regular expression will make the code simple.
The only difference is that you are now using double quotes instead of single quotes. This solves the issue I raised: Your regex will fail if either the column name or the criteria to match contains a single quote (e.g. "O'briensContractors") - does this concern you?
1. Has anyone used StringTokenizer to parse the criteria String instead of the java.util.regx package and passed the exam without losing points on criteriaFind method implementation ?
2. I have both the "Origin City" and "Destination City" as input TextFields, has anyone implemented them this way and passed without being penalized, or do I have to implement a ComboBox with a selection of cities for these two input fields ?
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton