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