1 package org.catacomb.druid.xtext.base;
2
3 import org.catacomb.druid.xtext.data.XType;
4 import org.catacomb.interlish.structure.TextDisplayed;
5
6
7
8
9 public class WordBlock extends TextBlock implements TextDisplayed {
10
11
12 WordBlock linkee;
13
14 public WordBlock() {
15 super();
16 }
17
18 public WordBlock(String s) {
19 super(s);
20 }
21
22 public TextBlock makeCopy() {
23 return new WordBlock();
24 }
25
26
27 public String getExtendedText() {
28 String txt = text;
29 if (linkee != null) {
30 txt += " " + linkee.getExtendedText();
31 }
32 return txt;
33 }
34
35
36 public boolean matches(TextBlock tb) {
37 return (tb instanceof WordBlock);
38 }
39
40
41 public void toggleLink(WordBlock wb) {
42 if (linkee == null) {
43 linkee = wb;
44 } else {
45 linkee = null;
46 }
47 }
48
49 public boolean hasLinkee() {
50 return (linkee != null);
51 }
52
53 public WordBlock getLinkee() {
54 return linkee;
55 }
56
57
58 public void weakSetType(XType xt) {
59 if (getType() == null) {
60 setType(xt);
61 if (linkee != null) {
62 linkee.weakSetType(xt);
63 }
64 } else {
65
66 }
67 }
68
69
70 public String getDisplayText() {
71 return getExtendedText();
72 }
73
74
75 }