Note that only exact matches need to be handled in this criteriaFind(String) method./QUOTE]so I'd say you're mostly all right. I think it would be fair (though I don't do it this way) to define "Origin" as a field name, however.
Yes... I believe "Origin airpot" (unless you're trying to smuggle marijuana in your luggage).Originally posted by Padmaja Prasad:
Also, the field names in the criteria String must exactly match with the field names of the record. So the criteria "Origin='SFO'" will get an empty DataInfo array.(Only "Origin airpot='SFO'" is valid).
Please let me know if anything is wrong...
Fly by Night Consultants<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr><i>I climbed on the back of a giant albatross<br />which flew through a crack in the cloud<br />to a place where happiness reigned...<br />all year 'round<br />the music played ever so loudly!</i><p><a href="http://thomasfly.com/songs/Traffic/Hole_in_my_Shoe_qt.htm" target="_blank" rel="nofollow">Hole in My Shoe</a><hr></blockquote>
Fly by Night Consultants<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr><i>I climbed on the back of a giant albatross<br />which flew through a crack in the cloud<br />to a place where happiness reigned...<br />all year 'round<br />the music played ever so loudly!</i><p><a href="http://thomasfly.com/songs/Traffic/Hole_in_my_Shoe_qt.htm" target="_blank" rel="nofollow">Hole in My Shoe</a><hr></blockquote>
My criteriaFind() method does not validate each of the field names in the criteria string seperately. Instaed it checks the whole record for name-value pair in the criteria string. It will return an empty DataInfo [] object if the field name is wrong or the criteria String is not valid. Is this approach good??
Also, the field names in the criteria String must exactly match with the field names of the record. So the criteria "Origin='SFO'" will get an empty DataInfo array.(Only "Origin airpot='SFO'" is valid).
Please let me know if anything is wrong...
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Originally posted by Michael Morris:
That's probably OK but may not be as efficient as verifying the field names first since you can short-circuit the search on the first invalid field. Also, how do you handle an ANY situation? It seems to me that yours is an additive method as opposed to the easier subtractive method of gathering the matching records.
That's fine. That's exactly what I did. Since it is assumed that your program builds the criteria, that should always work.
Hope this helps,
Michael Morris
Originally posted by Thomas Fly:
P.S. Obviously this forum software is in need of non-greedy regular expressions...
Originally posted by Thomas Fly:
P.S. Obviously this forum software is in need of non-greedy regular expressions...
Fly by Night Consultants<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr><i>I climbed on the back of a giant albatross<br />which flew through a crack in the cloud<br />to a place where happiness reigned...<br />all year 'round<br />the music played ever so loudly!</i><p><a href="http://thomasfly.com/songs/Traffic/Hole_in_my_Shoe_qt.htm" target="_blank" rel="nofollow">Hole in My Shoe</a><hr></blockquote>
I am constructing HashMaps that maps field name with data value for both the criteria string and every record in DB and then comparing their entrySets(using containsAll()). (Not using the for loop for finding the record match)
I'm handling ANY condition like this :
I'm not adding the field to the criteria string if it has ANY value. If the criteria String is empty, then before constructing the Maps, it'll simply return getAllRecords()(method defined in Data which returns an array of DataInfo containg all records).
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Consider Paul's rocket mass heater. |