1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.pkg;
21
22 import java.util.Collections;
23 import java.util.Iterator;
24 import java.util.LinkedList;
25
26 import org.xnap.XNap;
27
28 /***
29 */
30 public class OrDependencyNode extends AbstractDependencyNode
31 {
32
33
34
35 private LinkedList depends;
36
37
38
39 OrDependencyNode(String token, LinkedList depends)
40 {
41 super(token);
42
43 this.depends = depends;
44 }
45
46 public OrDependencyNode(String token)
47 {
48 this(token, new LinkedList());
49 }
50
51
52
53 public void add(DependencyNode node)
54 {
55 depends.add(node);
56 }
57
58 public Iterator children()
59 {
60 return depends.iterator();
61 }
62
63 public void checkDepends(boolean requireInstalled)
64 throws UnsatisfiedDependenciesException
65 {
66
67
68
69 LinkedList list = new LinkedList(depends);
70 Collections.reverse(list);
71
72 if (!requireInstalled) {
73
74 for (Iterator i = list.iterator(); i.hasNext();) {
75 try {
76 ((DependencyNode)i.next()).require(true);
77 return;
78 }
79 catch (UnsatisfiedDependenciesException e) {
80
81 }
82 }
83 }
84
85 for (Iterator i = list.iterator(); i.hasNext();) {
86 try {
87 ((DependencyNode)i.next()).require(false);
88 return;
89 }
90 catch (UnsatisfiedDependenciesException e) {
91
92 }
93 }
94
95 throw new UnsatisfiedDependenciesException(getID().toString());
96 }
97
98 public String toString()
99 {
100 return XNap.tr("Or");
101 }
102
103 }
104