1 package ixa.kaflib;
2
3 import java.io.Serializable;
4 import java.util.Comparator;
5
6
7
8 public class WF extends IReferable implements Serializable{
9
10 private AnnotationContainer annotationContainer;
11
12
13 private String wid;
14
15
16 private int sent;
17
18
19 private int para;
20
21
22 private int page;
23
24
25 private int offset;
26
27
28 private int length;
29
30
31 private String xpath;
32
33
34 private String form;
35
36 WF(AnnotationContainer annotationContainer, String wid, String form, int sent) {
37 this.annotationContainer = annotationContainer;
38 this.wid = wid;
39 this.form = form;
40 this.setSent(sent);
41 this.para = -1;
42 this.page = -1;
43 this.offset = -1;
44 this.length = -1;
45 }
46
47 WF(WF wf, AnnotationContainer annotationContainer) {
48 this.annotationContainer = annotationContainer;
49 this.wid = wf.wid;
50 this.sent = wf.sent;
51 this.para = wf.para;
52 this.page = wf.page;
53 this.offset = wf.offset;
54 this.length = wf.length;
55 this.xpath = wf.xpath;
56 this.form = wf.form;
57 }
58
59 public String getId() {
60 return wid;
61 }
62
63 public void setId(String wid) {
64 this.wid = wid;
65 }
66
67 public int getSent() {
68 return sent;
69 }
70
71 public void setSent(int sent) {
72 this.sent = sent;
73
74
75
76
77
78
79
80
81 }
82
83 public boolean hasPara() {
84 return para != -1;
85 }
86
87 public int getPara() {
88 return para;
89 }
90
91 public void setPara(int para) {
92 this.para = para;
93 this.annotationContainer.indexSentByPara(this.sent, para);
94 }
95
96 public boolean hasPage() {
97 return page != -1;
98 }
99
100 public int getPage() {
101 return page;
102 }
103
104 public void setPage(int page) {
105 this.page = page;
106 }
107
108 public boolean hasOffset() {
109 return offset != -1;
110 }
111
112 public int getOffset() {
113 return offset;
114 }
115
116 public void setOffset(int offset) {
117 this.offset = offset;
118 }
119
120 public boolean hasLength() {
121 return length != -1;
122 }
123
124 public int getLength() {
125 return length;
126 }
127
128 public void setLength(int length) {
129 this.length = length;
130 }
131
132 public boolean hasXpath() {
133 return xpath != null;
134 }
135
136 public String getXpath() {
137 return xpath;
138 }
139
140 public void setXpath(String xpath) {
141 this.xpath = xpath;
142 }
143
144 public String getForm() {
145 return form;
146 }
147
148 public void setForm(String form) {
149 this.form = form;
150 }
151
152 @Override
153 public String toString() {
154 return this.getForm();
155 }
156
157
158
159 public static final Comparator<WF> OFFSET_COMPARATOR = new Comparator<WF>() {
160
161 @Override
162 public int compare(WF first, WF second) {
163 return first.getOffset() - second.getOffset();
164 }
165
166 };
167 }