1 package org.incava.java; 2 3 import java.util.*; 4 import net.sourceforge.pmd.ast.*; 5 6 7 10 public class MethodMatchCriteria extends MatchCriteria 11 { 12 private ASTMethodDeclaration meth; 13 14 private String name = null; 15 16 private ASTFormalParameters params = null; 17 18 public MethodMatchCriteria(ASTMethodDeclaration m) 19 { 20 meth = m; 21 } 22 23 public double compare(MatchCriteria other) 24 { 25 if (other instanceof MethodMatchCriteria) { 26 MethodMatchCriteria mmother = (MethodMatchCriteria)other; 27 28 30 String aName = getName(); 31 String bName = mmother.getName(); 32 33 double score = 0.0; 34 35 if (aName.equals(bName)) { 36 ASTFormalParameters afp = getParameters(); 37 ASTFormalParameters bfp = mmother.getParameters(); 38 39 score = ParameterUtil.getMatchScore(afp, bfp); 40 } 41 else { 42 } 45 46 return score; 47 48 } 49 else { 50 return super.compare(other); 51 } 52 } 53 54 protected String getName() 55 { 56 if (name == null) { 57 name = MethodUtil.getName(meth).image; 58 } 59 return name; 60 } 61 62 protected ASTFormalParameters getParameters() 63 { 64 if (params == null) { 65 params = MethodUtil.getParameters(meth); 66 } 67 return params; 68 } 69 70 } 71 | Popular Tags |