KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lucene > search > SimilarityDelegator


1 package org.apache.lucene.search;
2
3 /**
4  * Copyright 2005 The Apache Software Foundation
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 /** Expert: Delegating scoring implementation. Useful in {@link
20  * Query#getSimilarity(Searcher)} implementations, to override only certain
21  * methods of a Searcher's Similiarty implementation.. */

22 public class SimilarityDelegator extends Similarity {
23
24   private Similarity delegee;
25
26   /** Construct a {@link Similarity} that delegates all methods to another.
27    *
28    * @param delegee the Similarity implementation to delegate to
29    */

30   public SimilarityDelegator(Similarity delegee) {
31     this.delegee = delegee;
32   }
33
34   public float lengthNorm(String JavaDoc fieldName, int numTerms) {
35     return delegee.lengthNorm(fieldName, numTerms);
36   }
37   
38   public float queryNorm(float sumOfSquaredWeights) {
39     return delegee.queryNorm(sumOfSquaredWeights);
40   }
41
42   public float tf(float freq) {
43     return delegee.tf(freq);
44   }
45     
46   public float sloppyFreq(int distance) {
47     return delegee.sloppyFreq(distance);
48   }
49     
50   public float idf(int docFreq, int numDocs) {
51     return delegee.idf(docFreq, numDocs);
52   }
53     
54   public float coord(int overlap, int maxOverlap) {
55     return delegee.coord(overlap, maxOverlap);
56   }
57
58 }
59
Popular Tags