Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Search function

 
Adam Roberts
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm currently banging out the search method for the Data class.
Here's what I'm doing:
I have a vector for search results that match the query(to later be converted into a array of DataInfo objects)
Extracting the Values - no problem, used string tokenizer and substring to get the field name and value then put them in an array of strings.
searching - for loop with getRecord(i). retreives array of strings and fieldInfo from the DataInfo to two separate arrays, respectively.(will use getName() on fieldInfos later)
My problem now lies in acutally comparing the Strings. Coding this will be easy(if a bit tedious), but is there a better way to due this than having a kazillion nested for loops?
Feel free to correct me on the above also.
Thanks
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Adam,
I have a post on the same subject. I pulled mine off with 3 loops and about 50 lines of code. Instead of matching every field name, I keyed on the index of each field and put the criteria value into a HashMap thereby eliminating one of the loops.
Anyway here's the post:
criteriaFind
Hope this helps
Michael Morris
SCJP2
[ March 26, 2002: Message edited by: Michael Morris ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic