|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| package org.jconfig.utils; |
|
8 |
| |
|
9 |
| import java.util.HashMap; |
|
10 |
| import java.util.Vector; |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| public class ExtensionGraph { |
|
16 |
| |
|
17 |
| private HashMap extensions = new HashMap(); |
|
18 |
| |
|
19 |
1
| public ExtensionGraph() {
|
|
20 |
| } |
|
21 |
| |
|
22 |
17
| public void addExtension(String current,String extension) {
|
|
23 |
17
| extensions.put(current,extension);
|
|
24 |
| } |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
17
| public boolean checkDependencies(String current) {
|
|
30 |
17
| Vector all = new Vector();
|
|
31 |
17
| return check(current,all);
|
|
32 |
| } |
|
33 |
| |
|
34 |
35
| private boolean check(String current,Vector all) {
|
|
35 |
35
| if ( extensions.containsKey(current)) {
|
|
36 |
19
| String ext = (String)extensions.get(current);
|
|
37 |
19
| if ( all.indexOf(ext) != - 1 ) {
|
|
38 |
1
| return true;
|
|
39 |
| } |
|
40 |
18
| all.add(ext);
|
|
41 |
18
| return check(ext,all);
|
|
42 |
| } |
|
43 |
16
| return false;
|
|
44 |
| } |
|
45 |
| |
|
46 |
| } |