01: package org.apache.lucene.search;
02:
03: /**
04: * Licensed to the Apache Software Foundation (ASF) under one or more
05: * contributor license agreements. See the NOTICE file distributed with
06: * this work for additional information regarding copyright ownership.
07: * The ASF licenses this file to You under the Apache License, Version 2.0
08: * (the "License"); you may not use this file except in compliance with
09: * 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: /** Expert: Delegating scoring implementation. Useful in {@link
21: * Query#getSimilarity(Searcher)} implementations, to override only certain
22: * methods of a Searcher's Similiarty implementation.. */
23: public class SimilarityDelegator extends Similarity {
24:
25: private Similarity delegee;
26:
27: /** Construct a {@link Similarity} that delegates all methods to another.
28: *
29: * @param delegee the Similarity implementation to delegate to
30: */
31: public SimilarityDelegator(Similarity delegee) {
32: this .delegee = delegee;
33: }
34:
35: public float lengthNorm(String fieldName, int numTerms) {
36: return delegee.lengthNorm(fieldName, numTerms);
37: }
38:
39: public float queryNorm(float sumOfSquaredWeights) {
40: return delegee.queryNorm(sumOfSquaredWeights);
41: }
42:
43: public float tf(float freq) {
44: return delegee.tf(freq);
45: }
46:
47: public float sloppyFreq(int distance) {
48: return delegee.sloppyFreq(distance);
49: }
50:
51: public float idf(int docFreq, int numDocs) {
52: return delegee.idf(docFreq, numDocs);
53: }
54:
55: public float coord(int overlap, int maxOverlap) {
56: return delegee.coord(overlap, maxOverlap);
57: }
58:
59: }
|