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