-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPackageStructure.java
More file actions
87 lines (72 loc) · 1.68 KB
/
Copy pathPackageStructure.java
File metadata and controls
87 lines (72 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
* Created on 19-10-2003 by jesper
* This class should
*/
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
/**
* @author jesper
*/
public class PackageStructure {
private Node superNode;
//private Set all;
private ArrayList all;
public PackageStructure(Node superNode){
this.superNode = superNode;
//all = new LinkedHashSet();
all = new ArrayList();
all.add(superNode);
}
public void addPackageToParent(Node parentPack, Node childPack){
childPack.setPackage(true);
if(!all.contains(childPack))
all.add(childPack);
Node n = findNode(parentPack);
if(n==null){
superNode.addChild(childPack);
}else{
n.addChild(childPack);
}
}
public void addFileToParent(Node parentPack, Node file){
file.setFile(true);
if(!all.contains(file))
all.add(file);
Node n = findNode(parentPack);
if(n==null){
superNode.addChild(file);
}else{
n.addChild(file);
}
}
public void addTopLevelPackage(Node n){
if(!all.contains(n))
all.add(n);
Node no = findNode(superNode);
if(no!=null){
superNode.addChild(n);
}
}
public Node findNode(Node n){
for (Iterator iter = all.iterator(); iter.hasNext();) {
Node element = (Node) iter.next();
if(element.equals(n)){
return element;
}
}
return null;
}
public Node getTopNode(){
for (Iterator iter = all.iterator(); iter.hasNext();) {
Node element = (Node) iter.next();
//System.out.println(element);
}
return this.superNode;
}
public String toString(){
return superNode.toString();
}
}