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