blob: 6067d9db9b7a1937efb28a9923ce06334c88f224 [file] [log] [blame]
Eliza Margaretha23f98762014-10-30 17:34:47 +00001package de.ids_mannheim.korap.query.spans;
2
3import java.io.IOException;
4import java.util.Map;
5
Akron700c1eb2015-09-25 16:57:30 +02006import org.apache.lucene.index.LeafReaderContext;
Eliza Margaretha23f98762014-10-30 17:34:47 +00007import org.apache.lucene.index.Term;
8import org.apache.lucene.index.TermContext;
9import org.apache.lucene.util.Bits;
10
margaretha50c76332015-03-19 10:10:39 +010011import de.ids_mannheim.korap.query.SimpleSpanQuery;
Eliza Margaretha493bfa92015-01-13 16:16:38 +000012import de.ids_mannheim.korap.query.SpanElementQuery;
13import de.ids_mannheim.korap.query.SpanRelationQuery;
Eliza Margaretha23f98762014-10-30 17:34:47 +000014
Eliza Margaretha493bfa92015-01-13 16:16:38 +000015/**
Nils Diewaldbb33da22015-03-04 16:24:25 +000016 * RelationBaseSpans is a base class for relation spans containing
Eliza Margarethadc98dc12016-11-16 14:33:42 +010017 * properties about the start and end positions of right side of the
18 * relation. It can also store information about the id of the
19 * left/right side, for instance, when it is an element or another
20 * relation.
Eliza Margaretha493bfa92015-01-13 16:16:38 +000021 *
22 * @author margaretha
23 *
24 */
margaretha50c76332015-03-19 10:10:39 +010025public abstract class RelationBaseSpans extends SimpleSpans {
Eliza Margaretha23f98762014-10-30 17:34:47 +000026
Nils Diewaldbb33da22015-03-04 16:24:25 +000027 protected short leftId, rightId;
28 protected int leftStart, leftEnd;
29 protected int rightStart, rightEnd;
Eliza Margaretha2db5e232015-03-04 10:20:01 +000030
Nils Diewaldbb33da22015-03-04 16:24:25 +000031
margaretha50c76332015-03-19 10:10:39 +010032 public RelationBaseSpans () {
33 this.hasSpanId = true;
Eliza Margarethadc98dc12016-11-16 14:33:42 +010034 }
Nils Diewaldbb33da22015-03-04 16:24:25 +000035
Eliza Margaretha23f98762014-10-30 17:34:47 +000036
Eliza Margaretha493bfa92015-01-13 16:16:38 +000037 /**
Nils Diewaldbb33da22015-03-04 16:24:25 +000038 * Constructs RelationBaseSpans based on the given
39 * SpanWithIdQuery.
Eliza Margaretha493bfa92015-01-13 16:16:38 +000040 *
Nils Diewaldbb33da22015-03-04 16:24:25 +000041 * @param spanWithIdQuery
42 * a SpanWithIdQuery, for instance a
43 * {@link SpanElementQuery} or
44 * {@link SpanRelationQuery}.
Eliza Margaretha493bfa92015-01-13 16:16:38 +000045 * @param context
46 * @param acceptDocs
47 * @param termContexts
48 * @throws IOException
49 */
margaretha50c76332015-03-19 10:10:39 +010050 public RelationBaseSpans (SimpleSpanQuery spanWithIdQuery,
Akron700c1eb2015-09-25 16:57:30 +020051 LeafReaderContext context, Bits acceptDocs,
Nils Diewaldbb33da22015-03-04 16:24:25 +000052 Map<Term, TermContext> termContexts)
53 throws IOException {
Eliza Margaretha493bfa92015-01-13 16:16:38 +000054 super(spanWithIdQuery, context, acceptDocs, termContexts);
margaretha50c76332015-03-19 10:10:39 +010055 this.hasSpanId = true;
Eliza Margaretha493bfa92015-01-13 16:16:38 +000056 }
Eliza Margaretha23f98762014-10-30 17:34:47 +000057
Nils Diewaldbb33da22015-03-04 16:24:25 +000058
Eliza Margaretha493bfa92015-01-13 16:16:38 +000059 /**
60 * Returns the id of the left hand side of the relation.
61 *
62 * @return an id
63 */
Nils Diewaldbb33da22015-03-04 16:24:25 +000064 public short getLeftId () {
Eliza Margaretha493bfa92015-01-13 16:16:38 +000065 return leftId;
66 }
Eliza Margaretha23f98762014-10-30 17:34:47 +000067
Nils Diewaldbb33da22015-03-04 16:24:25 +000068
Eliza Margaretha493bfa92015-01-13 16:16:38 +000069 /**
70 * Sets the id of the left hand side of the relation.
71 *
Nils Diewaldbb33da22015-03-04 16:24:25 +000072 * @param leftId
73 * the id of the left hand side of the relation.
Eliza Margaretha493bfa92015-01-13 16:16:38 +000074 */
Nils Diewaldbb33da22015-03-04 16:24:25 +000075 public void setLeftId (short leftId) {
Eliza Margaretha493bfa92015-01-13 16:16:38 +000076 this.leftId = leftId;
77 }
Eliza Margaretha23f98762014-10-30 17:34:47 +000078
Eliza Margaretha2db5e232015-03-04 10:20:01 +000079
Nils Diewaldbb33da22015-03-04 16:24:25 +000080 public int getLeftStart () {
81 return leftStart;
82 }
Eliza Margaretha2db5e232015-03-04 10:20:01 +000083
Eliza Margaretha2db5e232015-03-04 10:20:01 +000084
Nils Diewaldbb33da22015-03-04 16:24:25 +000085 public void setLeftStart (int leftStart) {
86 this.leftStart = leftStart;
87 }
Eliza Margaretha2db5e232015-03-04 10:20:01 +000088
Nils Diewaldbb33da22015-03-04 16:24:25 +000089
90 public int getLeftEnd () {
91 return leftEnd;
92 }
93
94
95 public void setLeftEnd (int leftEnd) {
96 this.leftEnd = leftEnd;
97 }
98
99
100 /**
101 * Returns the id of the right hand side of the relation.
102 *
103 * @return an id
104 */
105 public short getRightId () {
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000106 return rightId;
107 }
Eliza Margaretha23f98762014-10-30 17:34:47 +0000108
Nils Diewaldbb33da22015-03-04 16:24:25 +0000109
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000110 /**
111 * Sets the id of the right hand side of the relation.
112 *
Nils Diewaldbb33da22015-03-04 16:24:25 +0000113 * @param rightId
114 * the id of the right hand side of the relation.
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000115 */
Nils Diewaldbb33da22015-03-04 16:24:25 +0000116 public void setRightId (short rightId) {
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000117 this.rightId = rightId;
118 }
Eliza Margaretha23f98762014-10-30 17:34:47 +0000119
Nils Diewaldbb33da22015-03-04 16:24:25 +0000120
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000121 /**
Nils Diewaldbb33da22015-03-04 16:24:25 +0000122 * Returns the start position of the right hand side of the
123 * relation.
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000124 *
125 * @return the start position
126 */
Nils Diewaldbb33da22015-03-04 16:24:25 +0000127 public int getRightStart () {
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000128 return rightStart;
129 }
Eliza Margaretha23f98762014-10-30 17:34:47 +0000130
Nils Diewaldbb33da22015-03-04 16:24:25 +0000131
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000132 /**
133 * Sets the start position of the right hand side of the relation.
134 *
Nils Diewaldbb33da22015-03-04 16:24:25 +0000135 * @param rightStart
136 * the start position of the right hand side of the
137 * relation.
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000138 */
Nils Diewaldbb33da22015-03-04 16:24:25 +0000139 public void setRightStart (int rightStart) {
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000140 this.rightStart = rightStart;
141 }
142
Nils Diewaldbb33da22015-03-04 16:24:25 +0000143
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000144 /**
Nils Diewaldbb33da22015-03-04 16:24:25 +0000145 * Returns the end position of the right hand side of the
146 * relation.
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000147 *
148 * @return the end position
149 */
Nils Diewaldbb33da22015-03-04 16:24:25 +0000150 public int getRightEnd () {
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000151 return rightEnd;
152 }
153
Nils Diewaldbb33da22015-03-04 16:24:25 +0000154
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000155 /**
156 * Sets the start position of the right hand side of the relation.
157 *
Nils Diewaldbb33da22015-03-04 16:24:25 +0000158 * @param rightEnd
159 * the end position of the right hand side of the
160 * relation.
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000161 */
Nils Diewaldbb33da22015-03-04 16:24:25 +0000162 public void setRightEnd (int rightEnd) {
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000163 this.rightEnd = rightEnd;
164 }
Eliza Margaretha23f98762014-10-30 17:34:47 +0000165}