- Timestamp:
- 02/20/12 11:54:55 (13 years ago)
- Location:
- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/jfc/data
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/jfc/data/JFCEvent.java
r380 r390 45 45 */ 46 46 private Map<String, String> parentParameters; 47 48 private boolean targetChanged = false; 49 50 private int targetHash = -1; 47 51 48 52 /** … … 145 149 target += "." + extension; 146 150 } 151 targetChanged = true; 147 152 } 148 153 … … 187 192 @Override 188 193 protected int targetHashCode() { 189 int hashCode = 0; 190 int multiplier = 29; 191 if (target != null) { 192 String[] targetParts = target.split("\\]\\.\\["); 193 if (targetParts.length == 0) { 194 hashCode = widgetHashCode(target); 195 } else { 196 for (String widgetString : targetParts) { 197 hashCode = hashCode * multiplier 198 + widgetHashCode(widgetString); 194 if( targetChanged || targetHash==-1 ) { 195 targetHash = 0; 196 int multiplier = 29; 197 if (target != null) { 198 String[] targetParts = target.split("\\]\\.\\["); 199 if (targetParts.length == 0) { 200 targetHash = widgetHashCode(target); 201 } else { 202 for (String widgetString : targetParts) { 203 targetHash = targetHash * multiplier 204 + widgetHashCode(widgetString); 205 } 199 206 } 200 207 } 208 targetChanged = false; 201 209 } 202 203 return hashCode; 210 return targetHash; 204 211 } 205 212 … … 221 228 hashCode = hashCode * multiplier + widgetInfo[1].hashCode(); 222 229 hashCode = hashCode * multiplier + widgetInfo[2].hashCode(); 223 hashCode = hashCode * multiplier + widgetInfo[3].hashCode();230 //hashCode = hashCode * multiplier + widgetInfo[3].hashCode(); 224 231 } 225 232 return hashCode; -
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/jfc/data/JFCTargetComparator.java
r385 r390 2 2 3 3 import java.util.ArrayList; 4 import java.util.HashMap; 5 import java.util.HashSet; 4 6 import java.util.LinkedHashSet; 5 7 import java.util.List; 8 import java.util.Map; 6 9 import java.util.Set; 10 11 import org.apache.commons.collections15.CollectionUtils; 7 12 8 13 /** … … 18 23 */ 19 24 public class JFCTargetComparator { 25 26 private static boolean mutable = true; 27 28 private static Set<String> knownTargets = new LinkedHashSet<String>(); 29 30 private static Map<String, Set<String>> equalTargets; 31 32 public static void setMutable(boolean mutable) { 33 if( JFCTargetComparator.mutable==true && mutable == false ) { 34 equalTargets = new HashMap<String, Set<String>>(); 35 for( String target1 : knownTargets ) { 36 Set<String> curEqualTargets = new HashSet<String>(); 37 for( String target2 : knownTargets ) { 38 if( compare(target1, target2) ) { 39 curEqualTargets.add(target2); 40 } 41 } 42 equalTargets.put(target1, curEqualTargets); 43 } 44 } 45 JFCTargetComparator.mutable = mutable; 46 } 20 47 21 48 /** … … 41 68 */ 42 69 public static boolean compare(String target1, String target2) { 43 instance.addTarget(target1); 44 instance.addTarget(target2); 45 46 JFCWidget widget1 = instance.find(target1); 47 JFCWidget widget2 = instance.find(target2); 48 49 return widget1 == widget2; 70 boolean result = false; 71 if( mutable ) { 72 instance.addTarget(target1); 73 instance.addTarget(target2); 74 knownTargets.add(target1); 75 knownTargets.add(target2); 76 JFCWidget widget1 = instance.find(target1); 77 JFCWidget widget2 = instance.find(target2); 78 result = (widget1==widget2); 79 } 80 81 82 if( !mutable ) { 83 Set<String> curEquals = equalTargets.get(target1); 84 if( curEquals!=null ) { 85 result = curEquals.contains(target2); 86 } 87 } 88 89 return result; 50 90 } 51 91 … … 287 327 */ 288 328 String text; 329 330 int hashCode=0; 289 331 290 332 /** … … 309 351 if (obj instanceof JFCWidget) { 310 352 JFCWidget other = (JFCWidget) obj; 353 354 355 boolean titleEqual = CollectionUtils.containsAny(titles, other.titles); 356 boolean hashEqual = CollectionUtils.containsAny(hashCodes, other.hashCodes); 357 358 /* 311 359 Set<String> titlesCopy = new LinkedHashSet<String>(titles); 312 360 Set<String> hashCodesCopy = new LinkedHashSet<String>(hashCodes); 313 361 314 362 titlesCopy.retainAll(other.titles); 315 hashCodesCopy.retainAll(other.hashCodes); 363 hashCodesCopy.retainAll(other.hashCodes);*/ 316 364 317 365 boolean retVal; 366 367 if (widgetClass.equals("Class")) { 368 retVal = (widgetClass.equals(other.widgetClass) 369 && text.equals(other.text) && (titleEqual || hashEqual)); 370 } else { 371 retVal = (widgetClass.equals(other.widgetClass) 372 && index.equals(other.index) 373 && text.equals(other.text) && (titleEqual || hashEqual)); 374 } 375 /* 318 376 if (widgetClass.equals("Class")) { 319 377 retVal = (widgetClass.equals(other.widgetClass) … … 325 383 && text.equals(other.text) && (!titlesCopy 326 384 .isEmpty() || !hashCodesCopy.isEmpty())); 327 } 385 }*/ 328 386 return retVal; 329 387 } … … 338 396 @Override 339 397 public int hashCode() { 340 int multiplier = 7; 341 int hashCode = 0; 342 hashCode = multiplier * hashCode + widgetClass.hashCode(); 343 if (!widgetClass.equals("Class")) { 344 hashCode = multiplier * hashCode + index.hashCode(); 345 } 346 hashCode = multiplier * hashCode + text.hashCode(); 398 if( hashCode==0 ) { 399 int multiplier = 7; 400 hashCode = multiplier * hashCode + widgetClass.hashCode(); 401 if (!widgetClass.equals("Class")) { 402 hashCode = multiplier * hashCode + index.hashCode(); 403 } 404 hashCode = multiplier * hashCode + text.hashCode(); 405 } 347 406 return hashCode; 348 407 }
Note: See TracChangeset
for help on using the changeset viewer.