From 9ce65c5a963b03ee97fe9cb6c5aa65a3c04a80a8 Mon Sep 17 00:00:00 2001 From: yzhou Date: Tue, 21 Apr 2015 10:34:27 +0100 Subject: initial version --- src/uk/ac/ox/cs/pagoda/summary/Node.java | 65 ++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/uk/ac/ox/cs/pagoda/summary/Node.java (limited to 'src/uk/ac/ox/cs/pagoda/summary/Node.java') 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 @@ +package uk.ac.ox.cs.pagoda.summary; + +import java.util.Collection; +import java.util.Iterator; +import java.util.TreeSet; + +public class Node { + + String name; + Collection concepts = new TreeSet(); + private String label; + + public Node(String nodeName) { + name = nodeName; + } + + public String getName() { return name; } + + public void addConcept(String className) { + concepts.add(className); + label = null; + } + + public String getLabel() { + if (label == null) { + StringBuilder sb = null; + for (Iterator it = concepts.iterator(); it.hasNext(); ) { + if (sb == null) sb = new StringBuilder(); + else sb.append("^"); + sb.append(it.next()); + } + label = sb == null ? "" : sb.toString(); + } + return label; + } + + //TODO to be removed (just used for debug) ... + String simplifiedLabel = null; + + public String toString() { + if (simplifiedLabel == null) + simplifiedLabel = getLabel(); + return name + "@" + simplifiedLabel; + } + + public boolean isSubConceptOf(Node v) { + String s, t = ""; + for (Iterator uIter = concepts.iterator(), vIter = v.concepts.iterator(); uIter.hasNext(); ) { + s = uIter.next(); + if (!vIter.hasNext()) return false; + while (vIter.hasNext() && !s.equals(t = vIter.next())); + if (!s.equals(t)) return false; + } + return true; + } + + public Collection getConcepts() { + return concepts; + } + +} + + + + -- cgit v1.2.3