| Eliza Margaretha | 23f9876 | 2014-10-30 17:34:47 +0000 | [diff] [blame] | 1 | package de.ids_mannheim.korap.query.spans; |
| 2 | |
| 3 | import java.io.IOException; |
| 4 | import java.util.Map; |
| 5 | |
| Akron | 700c1eb | 2015-09-25 16:57:30 +0200 | [diff] [blame] | 6 | import org.apache.lucene.index.LeafReaderContext; |
| Eliza Margaretha | 23f9876 | 2014-10-30 17:34:47 +0000 | [diff] [blame] | 7 | import org.apache.lucene.index.Term; |
| 8 | import org.apache.lucene.index.TermContext; |
| 9 | import org.apache.lucene.util.Bits; |
| 10 | |
| margaretha | 50c7633 | 2015-03-19 10:10:39 +0100 | [diff] [blame] | 11 | import de.ids_mannheim.korap.query.SimpleSpanQuery; |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 12 | import de.ids_mannheim.korap.query.SpanElementQuery; |
| 13 | import de.ids_mannheim.korap.query.SpanRelationQuery; |
| Eliza Margaretha | 23f9876 | 2014-10-30 17:34:47 +0000 | [diff] [blame] | 14 | |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 15 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 16 | * RelationBaseSpans is a base class for relation spans containing |
| Eliza Margaretha | dc98dc1 | 2016-11-16 14:33:42 +0100 | [diff] [blame] | 17 | * 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 Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 21 | * |
| 22 | * @author margaretha |
| 23 | * |
| 24 | */ |
| margaretha | 50c7633 | 2015-03-19 10:10:39 +0100 | [diff] [blame] | 25 | public abstract class RelationBaseSpans extends SimpleSpans { |
| Eliza Margaretha | 23f9876 | 2014-10-30 17:34:47 +0000 | [diff] [blame] | 26 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 27 | protected short leftId, rightId; |
| 28 | protected int leftStart, leftEnd; |
| 29 | protected int rightStart, rightEnd; |
| Eliza Margaretha | 2db5e23 | 2015-03-04 10:20:01 +0000 | [diff] [blame] | 30 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 31 | |
| margaretha | 50c7633 | 2015-03-19 10:10:39 +0100 | [diff] [blame] | 32 | public RelationBaseSpans () { |
| 33 | this.hasSpanId = true; |
| Eliza Margaretha | dc98dc1 | 2016-11-16 14:33:42 +0100 | [diff] [blame] | 34 | } |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 35 | |
| Eliza Margaretha | 23f9876 | 2014-10-30 17:34:47 +0000 | [diff] [blame] | 36 | |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 37 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 38 | * Constructs RelationBaseSpans based on the given |
| 39 | * SpanWithIdQuery. |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 40 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 41 | * @param spanWithIdQuery |
| 42 | * a SpanWithIdQuery, for instance a |
| 43 | * {@link SpanElementQuery} or |
| 44 | * {@link SpanRelationQuery}. |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 45 | * @param context |
| 46 | * @param acceptDocs |
| 47 | * @param termContexts |
| 48 | * @throws IOException |
| 49 | */ |
| margaretha | 50c7633 | 2015-03-19 10:10:39 +0100 | [diff] [blame] | 50 | public RelationBaseSpans (SimpleSpanQuery spanWithIdQuery, |
| Akron | 700c1eb | 2015-09-25 16:57:30 +0200 | [diff] [blame] | 51 | LeafReaderContext context, Bits acceptDocs, |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 52 | Map<Term, TermContext> termContexts) |
| 53 | throws IOException { |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 54 | super(spanWithIdQuery, context, acceptDocs, termContexts); |
| margaretha | 50c7633 | 2015-03-19 10:10:39 +0100 | [diff] [blame] | 55 | this.hasSpanId = true; |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 56 | } |
| Eliza Margaretha | 23f9876 | 2014-10-30 17:34:47 +0000 | [diff] [blame] | 57 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 58 | |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 59 | /** |
| 60 | * Returns the id of the left hand side of the relation. |
| 61 | * |
| 62 | * @return an id |
| 63 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 64 | public short getLeftId () { |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 65 | return leftId; |
| 66 | } |
| Eliza Margaretha | 23f9876 | 2014-10-30 17:34:47 +0000 | [diff] [blame] | 67 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 68 | |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 69 | /** |
| 70 | * Sets the id of the left hand side of the relation. |
| 71 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 72 | * @param leftId |
| 73 | * the id of the left hand side of the relation. |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 74 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 75 | public void setLeftId (short leftId) { |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 76 | this.leftId = leftId; |
| 77 | } |
| Eliza Margaretha | 23f9876 | 2014-10-30 17:34:47 +0000 | [diff] [blame] | 78 | |
| Eliza Margaretha | 2db5e23 | 2015-03-04 10:20:01 +0000 | [diff] [blame] | 79 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 80 | public int getLeftStart () { |
| 81 | return leftStart; |
| 82 | } |
| Eliza Margaretha | 2db5e23 | 2015-03-04 10:20:01 +0000 | [diff] [blame] | 83 | |
| Eliza Margaretha | 2db5e23 | 2015-03-04 10:20:01 +0000 | [diff] [blame] | 84 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 85 | public void setLeftStart (int leftStart) { |
| 86 | this.leftStart = leftStart; |
| 87 | } |
| Eliza Margaretha | 2db5e23 | 2015-03-04 10:20:01 +0000 | [diff] [blame] | 88 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 89 | |
| 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 Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 106 | return rightId; |
| 107 | } |
| Eliza Margaretha | 23f9876 | 2014-10-30 17:34:47 +0000 | [diff] [blame] | 108 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 109 | |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 110 | /** |
| 111 | * Sets the id of the right hand side of the relation. |
| 112 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 113 | * @param rightId |
| 114 | * the id of the right hand side of the relation. |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 115 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 116 | public void setRightId (short rightId) { |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 117 | this.rightId = rightId; |
| 118 | } |
| Eliza Margaretha | 23f9876 | 2014-10-30 17:34:47 +0000 | [diff] [blame] | 119 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 120 | |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 121 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 122 | * Returns the start position of the right hand side of the |
| 123 | * relation. |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 124 | * |
| 125 | * @return the start position |
| 126 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 127 | public int getRightStart () { |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 128 | return rightStart; |
| 129 | } |
| Eliza Margaretha | 23f9876 | 2014-10-30 17:34:47 +0000 | [diff] [blame] | 130 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 131 | |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 132 | /** |
| 133 | * Sets the start position of the right hand side of the relation. |
| 134 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 135 | * @param rightStart |
| 136 | * the start position of the right hand side of the |
| 137 | * relation. |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 138 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 139 | public void setRightStart (int rightStart) { |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 140 | this.rightStart = rightStart; |
| 141 | } |
| 142 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 143 | |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 144 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 145 | * Returns the end position of the right hand side of the |
| 146 | * relation. |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 147 | * |
| 148 | * @return the end position |
| 149 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 150 | public int getRightEnd () { |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 151 | return rightEnd; |
| 152 | } |
| 153 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 154 | |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 155 | /** |
| 156 | * Sets the start position of the right hand side of the relation. |
| 157 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 158 | * @param rightEnd |
| 159 | * the end position of the right hand side of the |
| 160 | * relation. |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 161 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 162 | public void setRightEnd (int rightEnd) { |
| Eliza Margaretha | 493bfa9 | 2015-01-13 16:16:38 +0000 | [diff] [blame] | 163 | this.rightEnd = rightEnd; |
| 164 | } |
| Eliza Margaretha | 23f9876 | 2014-10-30 17:34:47 +0000 | [diff] [blame] | 165 | } |