aboutsummaryrefslogtreecommitdiff
path: root/src/uk/ac/ox/cs/pagoda/summary/Node.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/summary/Node.java')
-rw-r--r--src/uk/ac/ox/cs/pagoda/summary/Node.java65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/summary/Node.java b/src/uk/ac/ox/cs/pagoda/summary/Node.java
new file mode 100644
index 0000000..6fca4bb
--- /dev/null
+++ b/src/uk/ac/ox/cs/pagoda/summary/Node.java
@@ -0,0 +1,65 @@
1package uk.ac.ox.cs.pagoda.summary;
2
3import java.util.Collection;
4import java.util.Iterator;
5import java.util.TreeSet;
6
7public class Node {
8
9 String name;
10 Collection<String> concepts = new TreeSet<String>();
11 private String label;
12
13 public Node(String nodeName) {
14 name = nodeName;
15 }
16
17 public String getName() { return name; }
18
19 public void addConcept(String className) {
20 concepts.add(className);
21 label = null;
22 }
23
24 public String getLabel() {
25 if (label == null) {
26 StringBuilder sb = null;
27 for (Iterator<String> it = concepts.iterator(); it.hasNext(); ) {
28 if (sb == null) sb = new StringBuilder();
29 else sb.append("^");
30 sb.append(it.next());
31 }
32 label = sb == null ? "" : sb.toString();
33 }
34 return label;
35 }
36
37 //TODO to be removed (just used for debug) ...
38 String simplifiedLabel = null;
39
40 public String toString() {
41 if (simplifiedLabel == null)
42 simplifiedLabel = getLabel();
43 return name + "@" + simplifiedLabel;
44 }
45
46 public boolean isSubConceptOf(Node v) {
47 String s, t = "";
48 for (Iterator<String> uIter = concepts.iterator(), vIter = v.concepts.iterator(); uIter.hasNext(); ) {
49 s = uIter.next();
50 if (!vIter.hasNext()) return false;
51 while (vIter.hasNext() && !s.equals(t = vIter.next()));
52 if (!s.equals(t)) return false;
53 }
54 return true;
55 }
56
57 public Collection<String> getConcepts() {
58 return concepts;
59 }
60
61}
62
63
64
65