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

criteriaFind()

 
fengqiao cao
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, everyone
i am stuck in the criteriaFind().
could you give me some hints?
//some codes from my criteraFind()
outer:for (int r = 1; r <= recordCount; r++){
values = readRecord();
middle:for(int a=1;a<V.size();a+=2){
found= false;

for( int i=0;i<description.length;i++){
if (values[i].equals(V.get(a))){
found=true;
System.out.print("ok");//line 2
break;
}
}
continue middle;
}

if(found){
recordContainer.add(new DataInfo(r, description, values));
}
continue outer;}
//******
V is a vector which holds the object that originate from tokenizing "criteria".
RecorderContainer is an Arraylist which holds records matching criteria.
could you let me know why it can't never reach line2? Am i on the right track?
Thanks in advance....
Note: for the moment i just compare the values.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if (values[i].equals(V.get(a))){

you are using the equals method, which I believe returns true when they are the same Object, that is returns the same "Hashcode"
so you have a values array comparing against a "Object" that returns from a Vector. Hmm. sounds like it will never be equal to me. But I could be wrong.
Mark
 
Mathew Sam
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In criteria string you may not have all the field names.So Don't you think before checking for equality of values you need to check the fieldnames.
 
fengqiao cao
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, Mark and Mathew
Thanks for your reply, and i really appreciate it.
It is ok that an objcet from Vecton compare with a string.
Also now i am just tryint to make comparing values work and then i will compare the fieldname as well.
Any hint?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic