Clover Coverage Report
Coverage timestamp: Fri May 9 2008 10:54:27 EST
../../../../img/srcFileCovDistChart9.png 37% of files have more coverage
9   57   6   2.25
6   24   0.67   4
4     1.5  
1    
 
  MapFieldSelector       Line # 19 9 6 89.5% 0.8947368
 
  (1)
 
1    /*
2    * MapFieldSelector.java
3    *
4    * Created on May 2, 2006, 6:49 PM
5    *
6    */
7   
8    package org.apache.lucene.document;
9   
10    import java.util.HashMap;
11    import java.util.List;
12    import java.util.Map;
13   
14    /**
15    * A FieldSelector based on a Map of field names to FieldSelectorResults
16    *
17    * @author Chuck Williams
18    */
 
19    public class MapFieldSelector implements FieldSelector {
20   
21    Map fieldSelections;
22   
23    /** Create a a MapFieldSelector
24    * @param fieldSelections maps from field names to FieldSelectorResults
25    */
 
26  0 toggle public MapFieldSelector(Map fieldSelections) {
27  0 this.fieldSelections = fieldSelections;
28    }
29   
30    /** Create a a MapFieldSelector
31    * @param fields fields to LOAD. All other fields are NO_LOAD.
32    */
 
33  1 toggle public MapFieldSelector(List fields) {
34  1 fieldSelections = new HashMap(fields.size()*5/3);
35  2 for (int i=0; i<fields.size(); i++)
36  1 fieldSelections.put(fields.get(i), FieldSelectorResult.LOAD);
37    }
38   
39    /** Create a a MapFieldSelector
40    * @param fields fields to LOAD. All other fields are NO_LOAD.
41    */
 
42  2 toggle public MapFieldSelector(String[] fields) {
43  2 fieldSelections = new HashMap(fields.length*5/3);
44  5 for (int i=0; i<fields.length; i++)
45  3 fieldSelections.put(fields[i], FieldSelectorResult.LOAD);
46    }
47   
48    /** Load field according to its associated value in fieldSelections
49    * @param field a field name
50    * @return the fieldSelections value that field maps to or NO_LOAD if none.
51    */
 
52  18 toggle public FieldSelectorResult accept(String field) {
53  18 FieldSelectorResult selection = (FieldSelectorResult) fieldSelections.get(field);
54  18 return selection!=null ? selection : FieldSelectorResult.NO_LOAD;
55    }
56   
57    }