1 package jdiff; 2 3 import java.io.*; 4 import java.util.*; 5 6 16 class MethodAPI implements Comparable { 17 18 19 public String name_ = null; 20 21 22 public String returnType_ = null; 23 24 29 public String inheritedFrom_ = null; 30 31 35 public String exceptions_ = "no exceptions"; 36 37 38 public boolean isAbstract_ = false; 39 40 41 public boolean isNative_ = false; 42 43 44 public boolean isSynchronized_ = false; 45 46 47 public Modifiers modifiers_; 48 49 public List params_; 51 52 public String doc_ = null; 53 54 55 public MethodAPI(String name, String returnType, boolean isAbstract, 56 boolean isNative, boolean isSynchronized, 57 Modifiers modifiers) { 58 name_ = name; 59 returnType_ = returnType; 60 isAbstract_ = isAbstract; 61 isNative_ = isNative; 62 isSynchronized_ = isSynchronized; 63 modifiers_ = modifiers; 64 params_ = new ArrayList(); } 66 67 68 public MethodAPI(MethodAPI m) { 69 name_ = m.name_; 70 returnType_ = m.returnType_; 71 inheritedFrom_ = m.inheritedFrom_; 72 exceptions_ = m.exceptions_; 73 isAbstract_ = m.isAbstract_; 74 isNative_ = m.isNative_; 75 isSynchronized_ = m.isSynchronized_; 76 modifiers_ = m.modifiers_; params_ = m.params_; doc_ = m.doc_; 79 signature_ = m.signature_; } 81 82 86 public int compareTo(Object o) { 87 MethodAPI oMethod = (MethodAPI)o; 88 int comp = name_.compareTo(oMethod.name_); 89 if (comp != 0) 90 return comp; 91 comp = returnType_.compareTo(oMethod.returnType_); 92 if (comp != 0) 93 return comp; 94 if (APIComparator.changedInheritance(inheritedFrom_, oMethod.inheritedFrom_) != 0) 95 return -1; 96 if (isAbstract_ != oMethod.isAbstract_) { 97 return -1; 98 } 99 if (Diff.showAllChanges && 100 isNative_ != oMethod.isNative_) { 101 return -1; 102 } 103 if (Diff.showAllChanges && 104 isSynchronized_ != oMethod.isSynchronized_) { 105 return -1; 106 } 107 comp = exceptions_.compareTo(oMethod.exceptions_); 108 if (comp != 0) 109 return comp; 110 comp = modifiers_.compareTo(oMethod.modifiers_); 111 if (comp != 0) 112 return comp; 113 comp = getSignature().compareTo(oMethod.getSignature()); 114 if (comp != 0) 115 return comp; 116 if (APIComparator.docChanged(doc_, oMethod.doc_)) 117 return -1; 118 return 0; 119 } 120 121 124 public boolean equals(Object o) { 125 if (name_.compareTo(((MethodAPI)o).name_) == 0) 126 return true; 127 return false; 128 } 129 130 133 public boolean equalSignatures(Object o) { 134 if (getSignature().compareTo(((MethodAPI)o).getSignature()) == 0) 135 return true; 136 return false; 137 } 138 139 140 public String signature_ = null; 141 142 143 public String getSignature() { 144 if (signature_ != null) 145 return signature_; 146 String res = ""; 147 boolean first = true; 148 Iterator iter = params_.iterator(); 149 while (iter.hasNext()) { 150 if (!first) 151 res += ", "; 152 ParamAPI param = (ParamAPI)(iter.next()); 153 res += param.toString(); 154 first = false; 155 } 156 signature_ = res; 157 return res; 158 } 159 } 160 | Popular Tags |