Clover Coverage Report
Coverage timestamp: Fri May 9 2008 10:54:27 EST
../../../../img/srcFileCovDistChart4.png 81% of files have more coverage
23   115   16   1.92
6   64   0.7   12
12     1.33  
1    
 
  RemoteSearchable       Line # 33 23 16 36.6% 0.36585367
 
  (8)
 
1    package org.apache.lucene.search;
2   
3    /**
4    * Copyright 2004 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    import org.apache.lucene.document.Document;
20    import org.apache.lucene.index.Term;
21   
22    import java.io.IOException;
23    import java.rmi.Naming;
24    import java.rmi.RMISecurityManager;
25    import java.rmi.RemoteException;
26    import java.rmi.server.UnicastRemoteObject;
27   
28    /**
29    * A remote searchable implementation.
30    *
31    * @version $Id: RemoteSearchable.java 387550 2006-03-21 15:36:32Z yonik $
32    */
 
33    public class RemoteSearchable
34    extends UnicastRemoteObject
35    implements Searchable {
36   
37    private Searchable local;
38   
39    /** Constructs and exports a remote searcher. */
 
40  2 toggle public RemoteSearchable(Searchable local) throws RemoteException {
41  2 super();
42  2 this.local = local;
43    }
44   
45   
 
46  0 toggle public void search(Weight weight, Filter filter, HitCollector results)
47    throws IOException {
48  0 local.search(weight, filter, results);
49    }
50   
 
51  0 toggle public void close() throws IOException {
52  0 local.close();
53    }
54   
 
55  53 toggle public int docFreq(Term term) throws IOException {
56  53 return local.docFreq(term);
57    }
58   
59   
 
60  0 toggle public int[] docFreqs(Term[] terms) throws IOException {
61  0 return local.docFreqs(terms);
62    }
63   
 
64  8 toggle public int maxDoc() throws IOException {
65  8 return local.maxDoc();
66    }
67   
 
68  6 toggle public TopDocs search(Weight weight, Filter filter, int n) throws IOException {
69  6 return local.search(weight, filter, n);
70    }
71   
72   
 
73  47 toggle public TopFieldDocs search (Weight weight, Filter filter, int n, Sort sort)
74    throws IOException {
75  47 return local.search (weight, filter, n, sort);
76    }
77   
 
78  338 toggle public Document doc(int i) throws IOException {
79  338 return local.doc(i);
80    }
81   
 
82  53 toggle public Query rewrite(Query original) throws IOException {
83  53 return local.rewrite(original);
84    }
85   
 
86  0 toggle public Explanation explain(Weight weight, int doc) throws IOException {
87  0 return local.explain(weight, doc);
88    }
89   
90    /** Exports a searcher for the index in args[0] named
91    * "//localhost/Searchable". */
 
92  0 toggle public static void main(String args[]) throws Exception {
93  0 String indexName = null;
94   
95  0 if (args != null && args.length == 1)
96  0 indexName = args[0];
97   
98  0 if (indexName == null) {
99  0 System.out.println("Usage: org.apache.lucene.search.RemoteSearchable <index>");
100  0 return;
101    }
102   
103    // create and install a security manager
104  0 if (System.getSecurityManager() == null) {
105  0 System.setSecurityManager(new RMISecurityManager());
106    }
107   
108  0 Searchable local = new IndexSearcher(indexName);
109  0 RemoteSearchable impl = new RemoteSearchable(local);
110   
111    // bind the implementation to "Searchable"
112  0 Naming.rebind("//localhost/Searchable", impl);
113    }
114   
115    }