Changeset 833 for trunk/quest-plugin-jfc/src/main/java
- Timestamp:
- 09/20/12 09:46:49 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-plugin-jfc/src/main/java/de/ugoe/cs/quest/plugin/jfc/JFCTraceCorrector.java
r829 r833 1 1 package de.ugoe.cs.quest.plugin.jfc; 2 2 3 import java.io.BufferedOutputStream; 3 4 import java.io.File; 4 5 import java.io.FileInputStream; … … 10 11 import java.io.UnsupportedEncodingException; 11 12 import java.util.ArrayList; 13 import java.util.HashMap; 12 14 import java.util.List; 15 import java.util.Map; 13 16 14 17 import javax.xml.parsers.ParserConfigurationException; … … 68 71 /** 69 72 * <p> 70 * the list of all sources parsed in a file 71 * </p> 72 */ 73 private List<Source> allSources = new ArrayList<Source>(); 73 * the list of all sources parsed in a file identified through their <code>toString</code> 74 * representation 75 * </p> 76 */ 77 private Map<String, List<Source>> allSources = new HashMap<String, List<Source>>(); 74 78 75 79 /** … … 176 180 177 181 try { 178 outFile = new PrintStream(new FileOutputStream(resultFile));182 outFile = new PrintStream(new BufferedOutputStream(new FileOutputStream(resultFile))); 179 183 outFile.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); 180 184 } … … 348 352 */ 349 353 private void rememberSource(Source source) { 350 allSources.add(source); 354 String toStringValue = getToStringParam(source); 355 356 List<Source> sources = allSources.get(toStringValue); 357 358 if (sources == null) { 359 sources = new ArrayList<Source>(); 360 allSources.put(toStringValue, sources); 361 } 362 363 sources.add(source); 364 } 365 366 /** 367 * <p> 368 * convenience method to find a source based on its <code>toString</code> parameter value. 369 * The method only returns sources, which match the provided <code>toString</code> 370 * representation and which have a valid list of components. 371 * </p> 372 * 373 * @param toStringValue the value of the <code>toString</code> parameter the source to find 374 * must have 375 * 376 * @return the source matching the parameter and having a valid list of components or null if 377 * none is found 378 */ 379 private Source findSource(String toStringValue) { 380 Source existingSource = null; 381 382 List<Source> candidates = allSources.get(toStringValue); 383 384 if (candidates != null) { 385 for (Source candidate : candidates) { 386 if (toStringValue.equals(getToStringParam(candidate)) && 387 (candidate.components != null) && (candidate.components.size() > 0)) 388 { 389 existingSource = candidate; 390 } 391 } 392 } 393 394 return existingSource; 351 395 } 352 396 … … 395 439 396 440 if (toStringValue != null) { 397 for (Source candidate : allSources) { 398 if (toStringValue.equals(getToStringParam(candidate)) && 399 (candidate.components != null) && (candidate.components.size() > 0)) 400 { 401 existingSource = candidate; 402 } 403 } 441 existingSource = findSource(toStringValue); 404 442 } 405 443
Note: See TracChangeset
for help on using the changeset viewer.