| Eliza Margaretha | 7ee76da | 2014-08-12 15:32:33 +0000 | [diff] [blame] | 1 | package de.ids_mannheim.korap.query; |
| 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 | 7ee76da | 2014-08-12 15:32:33 +0000 | [diff] [blame] | 7 | import org.apache.lucene.index.Term; |
| 8 | import org.apache.lucene.index.TermContext; |
| 9 | import org.apache.lucene.search.spans.SpanQuery; |
| 10 | import org.apache.lucene.search.spans.Spans; |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 11 | import org.apache.lucene.search.spans.TermSpans; |
| Eliza Margaretha | 7ee76da | 2014-08-12 15:32:33 +0000 | [diff] [blame] | 12 | import org.apache.lucene.util.Bits; |
| 13 | |
| Eliza Margaretha | 99c72c2 | 2014-09-17 08:38:25 +0000 | [diff] [blame] | 14 | import de.ids_mannheim.korap.query.spans.ExpandedExclusionSpans; |
| Eliza Margaretha | 7ee76da | 2014-08-12 15:32:33 +0000 | [diff] [blame] | 15 | import de.ids_mannheim.korap.query.spans.ExpandedSpans; |
| 16 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 17 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 18 | * SpanExpansionQuery makes a span longer by stretching out the start |
| Eliza Margaretha | dc98dc1 | 2016-11-16 14:33:42 +0100 | [diff] [blame] | 19 | * or the end position of the span. The constraints of the expansion, |
| 20 | * such as how large the expansion should be (min and max position) |
| 21 | * and the direction of the expansion with respect to the original |
| 22 | * span, are specified in ExpansionConstraint. The direction is |
| 23 | * designated with the sign of a number, namely a negative number |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 24 | * signifies the left direction, and a positive number (including 0) |
| Eliza Margaretha | dc98dc1 | 2016-11-16 14:33:42 +0100 | [diff] [blame] | 25 | * signifies the right direction. |
| Eliza Margaretha | 7788a98 | 2014-08-29 16:10:52 +0000 | [diff] [blame] | 26 | * |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 27 | * <pre> |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 28 | * SpanTermQuery stq = new SpanTermQuery(new Term("tokens", |
| 29 | * "s:lightning")); |
| 30 | * SpanExpansionQuery seq = new SpanExpansionQuery(stq, 0, 2, -1, |
| 31 | * true); |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 32 | * </pre> |
| Eliza Margaretha | 7788a98 | 2014-08-29 16:10:52 +0000 | [diff] [blame] | 33 | * |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 34 | * In the example above, the SpanExpansionQuery describes that the |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 35 | * {@link TermSpans} of "lightning" may be expanded up to two token |
| 36 | * positions to |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 37 | * the left. |
| Eliza Margaretha | 7ee76da | 2014-08-12 15:32:33 +0000 | [diff] [blame] | 38 | * |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 39 | * <pre> |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 40 | * "Trees are often struck by lightning because they are natural |
| 41 | * lightning conductors to the ground." |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 42 | * </pre> |
| 43 | * |
| 44 | * The matches for the sample text are: |
| 45 | * |
| 46 | * <pre> |
| 47 | * [struck by lightning] |
| 48 | * [by lightning] |
| 49 | * [lightning] |
| 50 | * [are natural lightning] |
| 51 | * [natural lightning] |
| 52 | * [lightning] |
| 53 | * </pre> |
| 54 | * |
| 55 | * The expansion can also be specified to <em>not</em> contain any |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 56 | * direct/immediate /adjacent occurrence(s) of another span. Examples |
| 57 | * in |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 58 | * Poliqarp: |
| 59 | * |
| 60 | * <pre> |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 61 | * [orth=the][orth!=lightning] "the" must not be followed by |
| 62 | * "lightning" |
| 63 | * [pos!=ADJ]{1,2}[orth=jacket] one or two adjectives cannot precedes |
| 64 | * "jacket" |
| Eliza Margaretha | dffd059 | 2015-01-15 18:24:39 +0000 | [diff] [blame] | 65 | * </pre> |
| 66 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 67 | * The SpanExpansionQuery for the latter Poliqarp query with left |
| 68 | * direction from |
| Eliza Margaretha | dffd059 | 2015-01-15 18:24:39 +0000 | [diff] [blame] | 69 | * "jacket" example is: |
| 70 | * |
| 71 | * <pre> |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 72 | * SpanTermQuery notQuery = new SpanTermQuery(new |
| 73 | * Term("tokens", "tt:p:/ADJ")); |
| 74 | * SpanTermQuery stq = new SpanTermQuery(new Term("tokens", |
| 75 | * "s:jacket")); |
| 76 | * SpanExpansionQuery seq = new SpanExpansionQuery(stq, notQuery, 1, |
| 77 | * 2, -1, true); |
| Eliza Margaretha | dffd059 | 2015-01-15 18:24:39 +0000 | [diff] [blame] | 78 | * </pre> |
| 79 | * |
| 80 | * Matches and non matches example: |
| 81 | * |
| 82 | * <pre> |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 83 | * [a jacket] match |
| 84 | * [such a jacket] non match, where such is an ADJ |
| 85 | * [leather jacket] non match |
| 86 | * [black leather jacket] non match |
| 87 | * [large black leather jacket] non match |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 88 | * </pre> |
| 89 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 90 | * The positions of the expansion parts can be optionally stored in |
| 91 | * payloads |
| Eliza Margaretha | afe9812 | 2015-01-23 17:37:57 +0000 | [diff] [blame] | 92 | * together with a class number. |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 93 | * |
| 94 | * @author margaretha |
| Eliza Margaretha | 6f98920 | 2016-10-14 21:48:29 +0200 | [diff] [blame] | 95 | */ |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 96 | public class SpanExpansionQuery extends SimpleSpanQuery { |
| Eliza Margaretha | 7ee76da | 2014-08-12 15:32:33 +0000 | [diff] [blame] | 97 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 98 | private int min, max; // min, max expansion position |
| Eliza Margaretha | 7ee76da | 2014-08-12 15:32:33 +0000 | [diff] [blame] | 99 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 100 | // if > 0, collect expansion offsets using this label |
| 101 | private byte classNumber; |
| Eliza Margaretha | 7ee76da | 2014-08-12 15:32:33 +0000 | [diff] [blame] | 102 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 103 | // expansion direction with regard to the main span: |
| 104 | // < 0 to the left of main span |
| 105 | // >= 0 to the right of main span |
| 106 | private int direction; |
| Eliza Margaretha | 7ee76da | 2014-08-12 15:32:33 +0000 | [diff] [blame] | 107 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 108 | // if true, no occurrence of another span |
| 109 | final boolean isExclusion; |
| Eliza Margaretha | 7ee76da | 2014-08-12 15:32:33 +0000 | [diff] [blame] | 110 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 111 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 112 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 113 | * Constructs a SpanExpansionQuery for simple expansion of the |
| 114 | * specified {@link SpanQuery}. |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 115 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 116 | * @param firstClause |
| 117 | * a {@link SpanQuery} |
| 118 | * @param min |
| 119 | * the minimum length of the expansion |
| 120 | * @param max |
| 121 | * the maximum length of the expansion |
| 122 | * @param direction |
| 123 | * the direction of the expansion |
| 124 | * @param collectPayloads |
| 125 | * a boolean flag representing the value |
| 126 | * <code>true</code> if payloads are to be collected, |
| 127 | * otherwise |
| 128 | * <code>false</code>. |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 129 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 130 | public SpanExpansionQuery (SpanQuery firstClause, int min, int max, |
| 131 | int direction, boolean collectPayloads) { |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 132 | super(firstClause, collectPayloads); |
| 133 | if (max < min) { |
| 134 | throw new IllegalArgumentException("The max position has to be " |
| 135 | + "bigger than or the same as min position."); |
| 136 | } |
| 137 | this.min = min; |
| 138 | this.max = max; |
| 139 | this.direction = direction; |
| 140 | this.isExclusion = false; |
| 141 | } |
| Eliza Margaretha | 7ee76da | 2014-08-12 15:32:33 +0000 | [diff] [blame] | 142 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 143 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 144 | /** |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 145 | * Constructs a SpanExpansionQuery for simple expansion of the |
| 146 | * specified {@link SpanQuery} and stores expansion offsets in |
| 147 | * payloads associated |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 148 | * with the given class number. |
| 149 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 150 | * @param firstClause |
| 151 | * a {@link SpanQuery} |
| 152 | * @param min |
| 153 | * the minimum length of the expansion |
| 154 | * @param max |
| 155 | * the maximum length of the expansion |
| 156 | * @param direction |
| 157 | * the direction of the expansion |
| 158 | * @param classNumber |
| 159 | * the class number for storing expansion offsets in |
| 160 | * payloads |
| 161 | * @param collectPayloads |
| 162 | * a boolean flag representing the value |
| 163 | * <code>true</code> if payloads are to be collected, |
| 164 | * otherwise |
| 165 | * <code>false</code>. |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 166 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 167 | public SpanExpansionQuery (SpanQuery firstClause, int min, int max, |
| 168 | int direction, byte classNumber, |
| 169 | boolean collectPayloads) { |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 170 | this(firstClause, min, max, direction, collectPayloads); |
| 171 | this.classNumber = classNumber; |
| 172 | } |
| Eliza Margaretha | 7ee76da | 2014-08-12 15:32:33 +0000 | [diff] [blame] | 173 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 174 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 175 | /** |
| 176 | * Constructs a SpanExpansionQuery for expansion of the first |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 177 | * {@link SpanQuery} with exclusions of the second |
| 178 | * {@link SpanQuery}. |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 179 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 180 | * @param firstClause |
| 181 | * the SpanQuery to be expanded |
| 182 | * @param notClause |
| 183 | * the SpanQuery to be excluded |
| 184 | * @param min |
| 185 | * the minimum length of the expansion |
| 186 | * @param max |
| 187 | * the maximum length of the expansion |
| 188 | * @param direction |
| 189 | * the direction of the expansion |
| 190 | * @param collectPayloads |
| 191 | * a boolean flag representing the value |
| 192 | * <code>true</code> if payloads are to be collected, |
| 193 | * otherwise |
| 194 | * <code>false</code>. |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 195 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 196 | public SpanExpansionQuery (SpanQuery firstClause, SpanQuery notClause, |
| 197 | int min, int max, int direction, |
| 198 | boolean collectPayloads) { |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 199 | super(firstClause, notClause, collectPayloads); |
| 200 | if (max < min) { |
| 201 | throw new IllegalArgumentException("The max position has to be " |
| 202 | + "bigger than or the same as min position."); |
| 203 | } |
| 204 | this.min = min; |
| 205 | this.max = max; |
| 206 | this.direction = direction; |
| 207 | this.isExclusion = true; |
| 208 | } |
| Eliza Margaretha | 656cb31 | 2014-08-14 12:42:26 +0000 | [diff] [blame] | 209 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 210 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 211 | /** |
| 212 | * Constructs a SpanExpansionQuery for expansion of the first |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 213 | * {@link SpanQuery} with exclusions of the second |
| 214 | * {@link SpanQuery}, and |
| 215 | * stores expansion offsets in payloads associated with the given |
| 216 | * class |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 217 | * number. |
| 218 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 219 | * @param firstClause |
| 220 | * the SpanQuery to be expanded |
| 221 | * @param notClause |
| 222 | * the SpanQuery to be excluded |
| 223 | * @param min |
| 224 | * the minimum length of the expansion |
| 225 | * @param max |
| 226 | * the maximum length of the expansion |
| 227 | * @param direction |
| 228 | * the direction of the expansion |
| 229 | * @param classNumber |
| 230 | * the class number for storing expansion offsets in |
| 231 | * payloads |
| 232 | * @param collectPayloads |
| 233 | * a boolean flag representing the value |
| 234 | * <code>true</code> if payloads are to be collected, |
| 235 | * otherwise |
| 236 | * <code>false</code>. |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 237 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 238 | public SpanExpansionQuery (SpanQuery firstClause, SpanQuery notClause, |
| 239 | int min, int max, int direction, |
| 240 | byte classNumber, boolean collectPayloads) { |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 241 | this(firstClause, notClause, min, max, direction, collectPayloads); |
| 242 | this.classNumber = classNumber; |
| 243 | } |
| Eliza Margaretha | 7788a98 | 2014-08-29 16:10:52 +0000 | [diff] [blame] | 244 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 245 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 246 | @Override |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 247 | public SimpleSpanQuery clone () { |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 248 | SpanExpansionQuery sq = null; |
| 249 | if (isExclusion) { |
| 250 | sq = new SpanExpansionQuery(firstClause, secondClause, min, max, |
| 251 | direction, classNumber, collectPayloads); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 252 | } |
| 253 | else { |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 254 | sq = new SpanExpansionQuery(firstClause, min, max, direction, |
| 255 | classNumber, collectPayloads); |
| 256 | } |
| 257 | //sq.setBoost(sq.getBoost()); |
| 258 | return sq; |
| 259 | } |
| Eliza Margaretha | 7788a98 | 2014-08-29 16:10:52 +0000 | [diff] [blame] | 260 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 261 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 262 | @Override |
| Akron | 700c1eb | 2015-09-25 16:57:30 +0200 | [diff] [blame] | 263 | public Spans getSpans (LeafReaderContext context, Bits acceptDocs, |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 264 | Map<Term, TermContext> termContexts) throws IOException { |
| 265 | |
| 266 | // Temporary: |
| 267 | if (isExclusion) |
| 268 | return new ExpandedExclusionSpans(this, context, acceptDocs, |
| 269 | termContexts); |
| 270 | else |
| 271 | |
| 272 | return new ExpandedSpans(this, context, acceptDocs, termContexts); |
| 273 | } |
| 274 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 275 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 276 | @Override |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 277 | public String toString (String field) { |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 278 | StringBuilder sb = new StringBuilder(); |
| 279 | sb.append("spanExpansion("); |
| 280 | sb.append(firstClause.toString()); |
| 281 | if (isExclusion && secondClause != null) { |
| 282 | sb.append(", !"); |
| 283 | sb.append(secondClause.toString()); |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 284 | } |
| 285 | else { |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 286 | sb.append(", []"); |
| 287 | } |
| 288 | sb.append("{"); |
| 289 | sb.append(min); |
| 290 | sb.append(", "); |
| 291 | sb.append(max); |
| 292 | sb.append("}, "); |
| 293 | if (direction < 0) |
| 294 | sb.append("left"); |
| 295 | else |
| 296 | sb.append("right"); |
| 297 | if (classNumber > 0) { |
| 298 | sb.append(", class:"); |
| 299 | sb.append(classNumber); |
| 300 | } |
| 301 | sb.append(")"); |
| 302 | return sb.toString(); |
| 303 | } |
| 304 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 305 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 306 | /** |
| 307 | * Returns the minimum length of the expansion. |
| 308 | * |
| 309 | * @return the minimum length of the expansion |
| 310 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 311 | public int getMin () { |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 312 | return min; |
| 313 | } |
| 314 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 315 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 316 | /** |
| 317 | * Sets the minimum length of the expansion. |
| 318 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 319 | * @param min |
| 320 | * the minimum length of the expansion |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 321 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 322 | public void setMin (int min) { |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 323 | this.min = min; |
| 324 | } |
| 325 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 326 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 327 | /** |
| 328 | * Returns the maximum length of the expansion. |
| 329 | * |
| 330 | * @return the maximum length of the expansion |
| 331 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 332 | public int getMax () { |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 333 | return max; |
| 334 | } |
| 335 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 336 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 337 | /** |
| 338 | * Sets the maximum length of the expansion. |
| 339 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 340 | * @param max |
| 341 | * the maximum length of the expansion |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 342 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 343 | public void setMax (int max) { |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 344 | this.max = max; |
| 345 | } |
| 346 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 347 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 348 | /** |
| 349 | * Returns the class number associated with the expansion offsets |
| 350 | * |
| 351 | * @return the class number associated with the expansion offsets |
| 352 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 353 | public byte getClassNumber () { |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 354 | return classNumber; |
| 355 | } |
| 356 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 357 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 358 | /** |
| 359 | * Sets the class number associated with the expansion offsets |
| 360 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 361 | * @param classNumber |
| 362 | * the class number associated with the expansion |
| 363 | * offsets |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 364 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 365 | public void setClassNumber (byte classNumber) { |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 366 | this.classNumber = classNumber; |
| 367 | } |
| 368 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 369 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 370 | /** |
| 371 | * Returns the direction of the expansion |
| 372 | * |
| 373 | * @return the direction of the expansion |
| 374 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 375 | public int getDirection () { |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 376 | return direction; |
| 377 | } |
| 378 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 379 | |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 380 | /** |
| 381 | * Sets the direction of the expansion |
| 382 | * |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 383 | * @param direction |
| 384 | * the direction of the expansion |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 385 | */ |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 386 | public void setDirection (int direction) { |
| Eliza Margaretha | f0171c5 | 2015-01-14 17:38:16 +0000 | [diff] [blame] | 387 | this.direction = direction; |
| 388 | } |
| Eliza Margaretha | 7ee76da | 2014-08-12 15:32:33 +0000 | [diff] [blame] | 389 | } |