blob: b00dc438b3fecf83365d7cf0d21386ec38894c3c [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
17 * properties
18 * about the start and end positions of right side of the relation. It
19 * can also
20 * store information about the id of the left/right side, for
21 * instance, when it
Eliza Margaretha493bfa92015-01-13 16:16:38 +000022 * is an element or another relation.
23 *
24 * @author margaretha
25 *
26 */
margaretha50c76332015-03-19 10:10:39 +010027public abstract class RelationBaseSpans extends SimpleSpans {
Eliza Margaretha23f98762014-10-30 17:34:47 +000028
Nils Diewaldbb33da22015-03-04 16:24:25 +000029 protected short leftId, rightId;
30 protected int leftStart, leftEnd;
31 protected int rightStart, rightEnd;
Eliza Margaretha2db5e232015-03-04 10:20:01 +000032
Nils Diewaldbb33da22015-03-04 16:24:25 +000033
margaretha50c76332015-03-19 10:10:39 +010034 public RelationBaseSpans () {
35 this.hasSpanId = true;
36 };
Nils Diewaldbb33da22015-03-04 16:24:25 +000037
Eliza Margaretha23f98762014-10-30 17:34:47 +000038
Eliza Margaretha493bfa92015-01-13 16:16:38 +000039 /**
Nils Diewaldbb33da22015-03-04 16:24:25 +000040 * Constructs RelationBaseSpans based on the given
41 * SpanWithIdQuery.
Eliza Margaretha493bfa92015-01-13 16:16:38 +000042 *
Nils Diewaldbb33da22015-03-04 16:24:25 +000043 * @param spanWithIdQuery
44 * a SpanWithIdQuery, for instance a
45 * {@link SpanElementQuery} or
46 * {@link SpanRelationQuery}.
Eliza Margaretha493bfa92015-01-13 16:16:38 +000047 * @param context
48 * @param acceptDocs
49 * @param termContexts
50 * @throws IOException
51 */
margaretha50c76332015-03-19 10:10:39 +010052 public RelationBaseSpans (SimpleSpanQuery spanWithIdQuery,
Akron700c1eb2015-09-25 16:57:30 +020053 LeafReaderContext context, Bits acceptDocs,
Nils Diewaldbb33da22015-03-04 16:24:25 +000054 Map<Term, TermContext> termContexts)
55 throws IOException {
Eliza Margaretha493bfa92015-01-13 16:16:38 +000056 super(spanWithIdQuery, context, acceptDocs, termContexts);
margaretha50c76332015-03-19 10:10:39 +010057 this.hasSpanId = true;
Eliza Margaretha493bfa92015-01-13 16:16:38 +000058 }
Eliza Margaretha23f98762014-10-30 17:34:47 +000059
Nils Diewaldbb33da22015-03-04 16:24:25 +000060
Eliza Margaretha493bfa92015-01-13 16:16:38 +000061 /**
62 * Returns the id of the left hand side of the relation.
63 *
64 * @return an id
65 */
Nils Diewaldbb33da22015-03-04 16:24:25 +000066 public short getLeftId () {
Eliza Margaretha493bfa92015-01-13 16:16:38 +000067 return leftId;
68 }
Eliza Margaretha23f98762014-10-30 17:34:47 +000069
Nils Diewaldbb33da22015-03-04 16:24:25 +000070
Eliza Margaretha493bfa92015-01-13 16:16:38 +000071 /**
72 * Sets the id of the left hand side of the relation.
73 *
Nils Diewaldbb33da22015-03-04 16:24:25 +000074 * @param leftId
75 * the id of the left hand side of the relation.
Eliza Margaretha493bfa92015-01-13 16:16:38 +000076 */
Nils Diewaldbb33da22015-03-04 16:24:25 +000077 public void setLeftId (short leftId) {
Eliza Margaretha493bfa92015-01-13 16:16:38 +000078 this.leftId = leftId;
79 }
Eliza Margaretha23f98762014-10-30 17:34:47 +000080
Eliza Margaretha2db5e232015-03-04 10:20:01 +000081
Nils Diewaldbb33da22015-03-04 16:24:25 +000082 public int getLeftStart () {
83 return leftStart;
84 }
Eliza Margaretha2db5e232015-03-04 10:20:01 +000085
Eliza Margaretha2db5e232015-03-04 10:20:01 +000086
Nils Diewaldbb33da22015-03-04 16:24:25 +000087 public void setLeftStart (int leftStart) {
88 this.leftStart = leftStart;
89 }
Eliza Margaretha2db5e232015-03-04 10:20:01 +000090
Nils Diewaldbb33da22015-03-04 16:24:25 +000091
92 public int getLeftEnd () {
93 return leftEnd;
94 }
95
96
97 public void setLeftEnd (int leftEnd) {
98 this.leftEnd = leftEnd;
99 }
100
101
102 /**
103 * Returns the id of the right hand side of the relation.
104 *
105 * @return an id
106 */
107 public short getRightId () {
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000108 return rightId;
109 }
Eliza Margaretha23f98762014-10-30 17:34:47 +0000110
Nils Diewaldbb33da22015-03-04 16:24:25 +0000111
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000112 /**
113 * Sets the id of the right hand side of the relation.
114 *
Nils Diewaldbb33da22015-03-04 16:24:25 +0000115 * @param rightId
116 * the id of the right hand side of the relation.
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000117 */
Nils Diewaldbb33da22015-03-04 16:24:25 +0000118 public void setRightId (short rightId) {
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000119 this.rightId = rightId;
120 }
Eliza Margaretha23f98762014-10-30 17:34:47 +0000121
Nils Diewaldbb33da22015-03-04 16:24:25 +0000122
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000123 /**
Nils Diewaldbb33da22015-03-04 16:24:25 +0000124 * Returns the start position of the right hand side of the
125 * relation.
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000126 *
127 * @return the start position
128 */
Nils Diewaldbb33da22015-03-04 16:24:25 +0000129 public int getRightStart () {
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000130 return rightStart;
131 }
Eliza Margaretha23f98762014-10-30 17:34:47 +0000132
Nils Diewaldbb33da22015-03-04 16:24:25 +0000133
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000134 /**
135 * Sets the start position of the right hand side of the relation.
136 *
Nils Diewaldbb33da22015-03-04 16:24:25 +0000137 * @param rightStart
138 * the start position of the right hand side of the
139 * relation.
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000140 */
Nils Diewaldbb33da22015-03-04 16:24:25 +0000141 public void setRightStart (int rightStart) {
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000142 this.rightStart = rightStart;
143 }
144
Nils Diewaldbb33da22015-03-04 16:24:25 +0000145
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000146 /**
Nils Diewaldbb33da22015-03-04 16:24:25 +0000147 * Returns the end position of the right hand side of the
148 * relation.
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000149 *
150 * @return the end position
151 */
Nils Diewaldbb33da22015-03-04 16:24:25 +0000152 public int getRightEnd () {
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000153 return rightEnd;
154 }
155
Nils Diewaldbb33da22015-03-04 16:24:25 +0000156
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000157 /**
158 * Sets the start position of the right hand side of the relation.
159 *
Nils Diewaldbb33da22015-03-04 16:24:25 +0000160 * @param rightEnd
161 * the end position of the right hand side of the
162 * relation.
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000163 */
Nils Diewaldbb33da22015-03-04 16:24:25 +0000164 public void setRightEnd (int rightEnd) {
Eliza Margaretha493bfa92015-01-13 16:16:38 +0000165 this.rightEnd = rightEnd;
166 }
Eliza Margaretha23f98762014-10-30 17:34:47 +0000167}