KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > jayasoft > ivy > conflict > StrictConflictManager


1 /*
2  * This file is subject to the license found in LICENCE.TXT in the root directory of the project.
3  *
4  * #SNAPSHOT#
5  */

6 package fr.jayasoft.ivy.conflict;
7
8 import java.util.Collection JavaDoc;
9 import java.util.Collections JavaDoc;
10 import java.util.Iterator JavaDoc;
11
12 import fr.jayasoft.ivy.IvyNode;
13 import fr.jayasoft.ivy.conflict.AbstractConflictManager;
14 import fr.jayasoft.ivy.util.Message;
15
16
17 public class StrictConflictManager extends AbstractConflictManager
18 {
19
20     public StrictConflictManager() {
21     }
22
23
24     public Collection JavaDoc resolveConflicts(IvyNode parent, Collection JavaDoc conflicts)
25     {
26         IvyNode lastNode = null;
27         for (Iterator JavaDoc iter = conflicts.iterator(); iter.hasNext();) {
28             IvyNode node = (IvyNode)iter.next();
29
30             if (lastNode != null && !lastNode.equals(node)) {
31                 String JavaDoc msg = lastNode + " (needed by " + lastNode.getParent() + ") conflicts with " + node + " (needed by " + node.getParent() + ")";
32                 Message.error(msg);
33                 Message.sumupProblems();
34                 throw new StrictConflictException(msg);
35             }
36             lastNode = node;
37         }
38
39         return Collections.singleton(lastNode);
40     }
41
42 }
43
Popular Tags