~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to lucene/src/test/org/apache/lucene/search/JustCompileSearch.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.apache.lucene.search;
2
 
 
3
 
/**
4
 
 * Licensed to the Apache Software Foundation (ASF) under one or more
5
 
 * contributor license agreements.  See the NOTICE file distributed with
6
 
 * this work for additional information regarding copyright ownership.
7
 
 * The ASF licenses this file to You under the Apache License, Version 2.0
8
 
 * (the "License"); you may not use this file except in compliance with
9
 
 * the License.  You may obtain a copy of the License at
10
 
 *
11
 
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 
 *
13
 
 * Unless required by applicable law or agreed to in writing, software
14
 
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 
 * See the License for the specific language governing permissions and
17
 
 * limitations under the License.
18
 
 */
19
 
 
20
 
import java.io.IOException;
21
 
 
22
 
import org.apache.lucene.document.Document;
23
 
import org.apache.lucene.document.FieldSelector;
24
 
import org.apache.lucene.index.CorruptIndexException;
25
 
import org.apache.lucene.index.IndexReader;
26
 
import org.apache.lucene.index.FieldInvertState;
27
 
import org.apache.lucene.index.Term;
28
 
import org.apache.lucene.util.PriorityQueue;
29
 
 
30
 
/**
31
 
 * Holds all implementations of classes in the o.a.l.search package as a
32
 
 * back-compatibility test. It does not run any tests per-se, however if 
33
 
 * someone adds a method to an interface or abstract method to an abstract
34
 
 * class, one of the implementations here will fail to compile and so we know
35
 
 * back-compat policy was violated.
36
 
 */
37
 
final class JustCompileSearch {
38
 
 
39
 
  private static final String UNSUPPORTED_MSG = "unsupported: used for back-compat testing only !";
40
 
 
41
 
  static final class JustCompileSearcher extends Searcher {
42
 
 
43
 
    @Override
44
 
    public Weight createNormalizedWeight(Query query) throws IOException {
45
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
46
 
    }
47
 
    
48
 
    @Override
49
 
    public void close() throws IOException {
50
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
51
 
    }
52
 
 
53
 
    @Override
54
 
    public Document doc(int i) throws CorruptIndexException, IOException {
55
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
56
 
    }
57
 
 
58
 
    @Override
59
 
    public int[] docFreqs(Term[] terms) throws IOException {
60
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
61
 
    }
62
 
 
63
 
    @Override
64
 
    public Explanation explain(Query query, int doc) throws IOException {
65
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
66
 
    }
67
 
 
68
 
    @Override
69
 
    public Similarity getSimilarity() {
70
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
71
 
    }
72
 
 
73
 
    @Override
74
 
    public void search(Query query, Collector results) throws IOException {
75
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
76
 
    }
77
 
 
78
 
    @Override
79
 
    public void search(Query query, Filter filter, Collector results)
80
 
        throws IOException {
81
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
82
 
    }
83
 
 
84
 
    @Override
85
 
    public TopDocs search(Query query, Filter filter, int n) throws IOException {
86
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
87
 
    }
88
 
    
89
 
    @Override
90
 
    public TopFieldDocs search(Query query, Filter filter, int n, Sort sort)
91
 
        throws IOException {
92
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
93
 
    }
94
 
    
95
 
    @Override
96
 
    public TopDocs search(Query query, int n) throws IOException {
97
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
98
 
    }
99
 
    
100
 
    @Override
101
 
    public void setSimilarity(Similarity similarity) {
102
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
103
 
    }
104
 
    
105
 
    @Override
106
 
    public int docFreq(Term term) throws IOException {
107
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
108
 
    }
109
 
 
110
 
    @Override
111
 
    public Explanation explain(Weight weight, int doc) throws IOException {
112
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
113
 
    }
114
 
 
115
 
    @Override
116
 
    public int maxDoc() throws IOException {
117
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
118
 
    }
119
 
 
120
 
    @Override
121
 
    public Query rewrite(Query query) throws IOException {
122
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
123
 
    }
124
 
 
125
 
    @Override
126
 
    public void search(Weight weight, Filter filter, Collector results)
127
 
        throws IOException {
128
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
129
 
    }
130
 
 
131
 
    @Override
132
 
    public TopDocs search(Weight weight, Filter filter, int n)
133
 
        throws IOException {
134
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
135
 
    }
136
 
 
137
 
    @Override
138
 
    public TopFieldDocs search(Weight weight, Filter filter, int n, Sort sort)
139
 
        throws IOException {
140
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
141
 
    }
142
 
 
143
 
    @Override
144
 
    public Document doc(int n, FieldSelector fieldSelector)
145
 
        throws CorruptIndexException, IOException {
146
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
147
 
    }
148
 
    
149
 
  }
150
 
  
151
 
  static final class JustCompileCollector extends Collector {
152
 
 
153
 
    @Override
154
 
    public void collect(int doc) throws IOException {
155
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
156
 
    }
157
 
 
158
 
    @Override
159
 
    public void setNextReader(IndexReader reader, int docBase)
160
 
        throws IOException {
161
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
162
 
    }
163
 
 
164
 
    @Override
165
 
    public void setScorer(Scorer scorer) throws IOException {
166
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
167
 
    }
168
 
    
169
 
    @Override
170
 
    public boolean acceptsDocsOutOfOrder() {
171
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
172
 
    }
173
 
 
174
 
  }
175
 
  
176
 
  static final class JustCompileDocIdSet extends DocIdSet {
177
 
 
178
 
    @Override
179
 
    public DocIdSetIterator iterator() throws IOException {
180
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
181
 
    }
182
 
    
183
 
  }
184
 
 
185
 
  static final class JustCompileDocIdSetIterator extends DocIdSetIterator {
186
 
 
187
 
    @Override
188
 
    public int docID() {
189
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
190
 
    }
191
 
 
192
 
    @Override
193
 
    public int nextDoc() throws IOException {
194
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
195
 
    }
196
 
    
197
 
    @Override
198
 
    public int advance(int target) throws IOException {
199
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
200
 
    }
201
 
  }
202
 
  
203
 
  static final class JustCompileExtendedFieldCacheLongParser implements FieldCache.LongParser {
204
 
 
205
 
    public long parseLong(String string) {
206
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
207
 
    }
208
 
    
209
 
  }
210
 
  
211
 
  static final class JustCompileExtendedFieldCacheDoubleParser implements FieldCache.DoubleParser {
212
 
    
213
 
    public double parseDouble(String string) {
214
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
215
 
    }
216
 
    
217
 
  }
218
 
 
219
 
  static final class JustCompileFieldComparator extends FieldComparator<Object> {
220
 
 
221
 
    @Override
222
 
    public int compare(int slot1, int slot2) {
223
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
224
 
    }
225
 
 
226
 
    @Override
227
 
    public int compareBottom(int doc) throws IOException {
228
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
229
 
    }
230
 
 
231
 
    @Override
232
 
    public void copy(int slot, int doc) throws IOException {
233
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
234
 
    }
235
 
 
236
 
    @Override
237
 
    public void setBottom(int slot) {
238
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
239
 
    }
240
 
 
241
 
    @Override
242
 
    public void setNextReader(IndexReader reader, int docBase)
243
 
        throws IOException {
244
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
245
 
    }
246
 
 
247
 
    @Override
248
 
    public Object value(int slot) {
249
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
250
 
    }
251
 
 
252
 
  }
253
 
 
254
 
  static final class JustCompileFieldComparatorSource extends FieldComparatorSource {
255
 
 
256
 
    @Override
257
 
    public FieldComparator newComparator(String fieldname, int numHits,
258
 
        int sortPos, boolean reversed) throws IOException {
259
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
260
 
    }
261
 
    
262
 
  }
263
 
 
264
 
  static final class JustCompileFilter extends Filter {
265
 
    // Filter is just an abstract class with no abstract methods. However it is
266
 
    // still added here in case someone will add abstract methods in the future.
267
 
    
268
 
    @Override
269
 
    public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
270
 
      return null;
271
 
    }
272
 
  }
273
 
 
274
 
  static final class JustCompileFilteredDocIdSet extends FilteredDocIdSet {
275
 
 
276
 
    public JustCompileFilteredDocIdSet(DocIdSet innerSet) {
277
 
      super(innerSet);
278
 
    }
279
 
 
280
 
    @Override
281
 
    protected boolean match(int docid) {
282
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
283
 
    }
284
 
    
285
 
  }
286
 
 
287
 
  static final class JustCompileFilteredDocIdSetIterator extends FilteredDocIdSetIterator {
288
 
 
289
 
    public JustCompileFilteredDocIdSetIterator(DocIdSetIterator innerIter) {
290
 
      super(innerIter);
291
 
    }
292
 
 
293
 
    @Override
294
 
    protected boolean match(int doc) {
295
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
296
 
    }
297
 
    
298
 
  }
299
 
 
300
 
  static final class JustCompileFilteredTermEnum extends FilteredTermEnum {
301
 
 
302
 
    @Override
303
 
    public float difference() {
304
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
305
 
    }
306
 
 
307
 
    @Override
308
 
    protected boolean endEnum() {
309
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
310
 
    }
311
 
 
312
 
    @Override
313
 
    protected boolean termCompare(Term term) {
314
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
315
 
    }
316
 
    
317
 
  }
318
 
 
319
 
  static final class JustCompilePhraseScorer extends PhraseScorer {
320
 
 
321
 
    JustCompilePhraseScorer(Weight weight, PhraseQuery.PostingsAndFreq[] postings,
322
 
        Similarity similarity, byte[] norms) {
323
 
      super(weight, postings, similarity, norms);
324
 
    }
325
 
 
326
 
    @Override
327
 
    protected float phraseFreq() throws IOException {
328
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
329
 
    }
330
 
    
331
 
  }
332
 
 
333
 
  static final class JustCompileQuery extends Query {
334
 
 
335
 
    @Override
336
 
    public String toString(String field) {
337
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
338
 
    }
339
 
    
340
 
  }
341
 
  
342
 
  static final class JustCompileScorer extends Scorer {
343
 
 
344
 
    protected JustCompileScorer(Weight weight) {
345
 
      super(weight);
346
 
    }
347
 
 
348
 
    @Override
349
 
    protected boolean score(Collector collector, int max, int firstDocID)
350
 
        throws IOException {
351
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
352
 
    }
353
 
    
354
 
    @Override
355
 
    public float score() throws IOException {
356
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
357
 
    }
358
 
 
359
 
    @Override
360
 
    public int docID() {
361
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
362
 
    }
363
 
 
364
 
    @Override
365
 
    public int nextDoc() throws IOException {
366
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
367
 
    }
368
 
    
369
 
    @Override
370
 
    public int advance(int target) throws IOException {
371
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
372
 
    }
373
 
  }
374
 
  
375
 
  static final class JustCompileSimilarity extends Similarity {
376
 
 
377
 
    @Override
378
 
    public float coord(int overlap, int maxOverlap) {
379
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
380
 
    }
381
 
 
382
 
    @Override
383
 
    public float idf(int docFreq, int numDocs) {
384
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
385
 
    }
386
 
 
387
 
    @Override
388
 
    public float computeNorm(String fieldName, FieldInvertState state) {
389
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
390
 
    }
391
 
 
392
 
    @Override
393
 
    public float queryNorm(float sumOfSquaredWeights) {
394
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
395
 
    }
396
 
 
397
 
    @Override
398
 
    public float sloppyFreq(int distance) {
399
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
400
 
    }
401
 
 
402
 
    @Override
403
 
    public float tf(float freq) {
404
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
405
 
    }
406
 
    
407
 
  }
408
 
 
409
 
  static final class JustCompileSpanFilter extends SpanFilter {
410
 
 
411
 
    @Override
412
 
    public SpanFilterResult bitSpans(IndexReader reader) throws IOException {
413
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
414
 
    }
415
 
    
416
 
    @Override
417
 
    public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
418
 
      return null;
419
 
    }    
420
 
  }
421
 
 
422
 
  static final class JustCompileTopDocsCollector extends TopDocsCollector<ScoreDoc> {
423
 
 
424
 
    protected JustCompileTopDocsCollector(PriorityQueue<ScoreDoc> pq) {
425
 
      super(pq);
426
 
    }
427
 
 
428
 
    @Override
429
 
    public void collect(int doc) throws IOException {
430
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
431
 
    }
432
 
 
433
 
    @Override
434
 
    public void setNextReader(IndexReader reader, int docBase)
435
 
        throws IOException {
436
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
437
 
    }
438
 
 
439
 
    @Override
440
 
    public void setScorer(Scorer scorer) throws IOException {
441
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
442
 
    }
443
 
    
444
 
    @Override
445
 
    public boolean acceptsDocsOutOfOrder() {
446
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
447
 
    }
448
 
 
449
 
    @Override
450
 
    public TopDocs topDocs() {
451
 
        throw new UnsupportedOperationException( UNSUPPORTED_MSG );
452
 
    }
453
 
 
454
 
    @Override
455
 
    public TopDocs topDocs( int start ) {
456
 
        throw new UnsupportedOperationException( UNSUPPORTED_MSG );
457
 
    }
458
 
 
459
 
    @Override
460
 
    public TopDocs topDocs( int start, int end ) {
461
 
        throw new UnsupportedOperationException( UNSUPPORTED_MSG );
462
 
    }
463
 
    
464
 
  }
465
 
 
466
 
  static final class JustCompileWeight extends Weight {
467
 
 
468
 
    @Override
469
 
    public Explanation explain(IndexReader reader, int doc) throws IOException {
470
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
471
 
    }
472
 
 
473
 
    @Override
474
 
    public Query getQuery() {
475
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
476
 
    }
477
 
 
478
 
    @Override
479
 
    public float getValue() {
480
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
481
 
    }
482
 
 
483
 
    @Override
484
 
    public void normalize(float norm) {
485
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
486
 
    }
487
 
 
488
 
    @Override
489
 
    public float sumOfSquaredWeights() throws IOException {
490
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
491
 
    }
492
 
 
493
 
    @Override
494
 
    public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer)
495
 
        throws IOException {
496
 
      throw new UnsupportedOperationException(UNSUPPORTED_MSG);
497
 
    }
498
 
    
499
 
  }
500
 
  
501
 
}