Clover Coverage Report
Coverage timestamp: Fri May 9 2008 10:54:27 EST
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
184   401   63   10.22
80   291   0.34   9
18     3.5  
2    
 
  FieldCacheImpl       Line # 40 165 52 94.2% 0.9419087
  FieldCacheImpl.Entry       Line # 44 19 11 85.4% 0.85365856
 
  (19)
 
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.index.IndexReader;
20    import org.apache.lucene.index.Term;
21    import org.apache.lucene.index.TermDocs;
22    import org.apache.lucene.index.TermEnum;
23   
24    import java.io.IOException;
25    import java.util.Locale;
26    import java.util.Map;
27    import java.util.WeakHashMap;
28    import java.util.HashMap;
29   
30    /**
31    * Expert: The default cache implementation, storing all values in memory.
32    * A WeakHashMap is used for storage.
33    *
34    * <p>Created: May 19, 2004 4:40:36 PM
35    *
36    * @author Tim Jones (Nacimiento Software)
37    * @since lucene 1.4
38    * @version $Id: FieldCacheImpl.java 413201 2006-06-10 01:23:22Z gsingers $
39    */
 
40    class FieldCacheImpl
41    implements FieldCache {
42   
43    /** Expert: Every key in the internal cache is of this type. */
 
44    static class Entry {
45    final String field; // which Fieldable
46    final int type; // which SortField type
47    final Object custom; // which custom comparator
48    final Locale locale; // the locale we're sorting (if string)
49   
50    /** Creates one of these objects. */
 
51  502 toggle Entry (String field, int type, Locale locale) {
52  502 this.field = field.intern();
53  502 this.type = type;
54  502 this.custom = null;
55  502 this.locale = locale;
56    }
57   
58    /** Creates one of these objects for a custom comparator. */
 
59  123 toggle Entry (String field, Object custom) {
60  123 this.field = field.intern();
61  123 this.type = SortField.CUSTOM;
62  123 this.custom = custom;
63  123 this.locale = null;
64    }
65   
66    /** Two of these are equal iff they reference the same field and type. */
 
67  263 toggle public boolean equals (Object o) {
68  263 if (o instanceof Entry) {
69  263 Entry other = (Entry) o;
70  263 if (other.field == field && other.type == type) {
71  263 if (other.locale == null ? locale == null : other.locale.equals(locale)) {
72  263 if (other.custom == null) {
73  224 if (custom == null) return true;
74  39 } else if (other.custom.equals (custom)) {
75  39 return true;
76    }
77    }
78    }
79    }
80  0 return false;
81    }
82   
83    /** Composes a hashcode based on the field and type. */
 
84  567 toggle public int hashCode() {
85  567 return field.hashCode() ^ type ^ (custom==null ? 0 : custom.hashCode()) ^ (locale==null ? 0 : locale.hashCode());
86    }
87    }
88   
89    private static final IntParser INT_PARSER = new IntParser() {
 
90  300 toggle public int parseInt(String value) {
91  300 return Integer.parseInt(value);
92    }
93    };
94   
95    private static final FloatParser FLOAT_PARSER = new FloatParser() {
 
96  120 toggle public float parseFloat(String value) {
97  120 return Float.parseFloat(value);
98