1   package ixa.kaflib;
2   
3   import java.io.Serializable;
4   import java.util.List;
5   
6   public class Terminal extends TreeNode implements Serializable {
7   
8       /** The term referenced by this terminal */
9       private Span<Term> span;
10  
11      Terminal(String id, Span<Term> span) {
12  	super(id, false, true);
13  	this.span = span;
14      }
15  
16      /** Returns the Span object */
17      public Span<Term> getSpan() {
18  	return this.span;
19      }
20  
21      private String getStrValue() {
22  	String str = "";
23  	for (Term term : span.getTargets()) {
24  	    if (!str.isEmpty()) {
25  		str += " ";
26  	    }
27  	    str += term.getStr();
28  	}
29  	return str;
30      }
31  
32      public String getStr() {
33  	String strValue = this.getStrValue();
34  	if (strValue.startsWith("-") || strValue.endsWith("-")) {
35  	    return strValue.replace("-", "- ");
36     	}
37     	else if (strValue.contains("--")) { 
38  	    return strValue.replace("--", "-");
39     	}
40     	else {
41  	    return strValue;
42     	}
43      }
44  
45      public void addChild(TreeNode tn) throws Exception {
46  	throw new Exception("It is not possible to add child nodes to Terminal nodes.");
47      }
48  
49      public List<TreeNode> getChildren() {
50  	return null;
51      }
52  
53  }