diff options
| author | yzhou <yujiao.zhou@gmail.com> | 2015-04-21 10:34:27 +0100 |
|---|---|---|
| committer | yzhou <yujiao.zhou@gmail.com> | 2015-04-21 10:34:27 +0100 |
| commit | 9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8 (patch) | |
| tree | 47511c0fb89dccff0db4b5990522e04f294d795b /src/uk/ac/ox/cs/pagoda/summary/Node.java | |
| parent | b1ac207612ee8b045244253fb94b866104bc34f2 (diff) | |
| download | ACQuA-9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8.tar.gz ACQuA-9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8.zip | |
initial version
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/summary/Node.java')
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/summary/Node.java | 65 |
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 @@ | |||
| 1 | package uk.ac.ox.cs.pagoda.summary; | ||
| 2 | |||
| 3 | import java.util.Collection; | ||
| 4 | import java.util.Iterator; | ||
| 5 | import java.util.TreeSet; | ||
| 6 | |||
| 7 | public 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 | |||
