21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 *
23 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
24 * or visit www.oracle.com if you need additional information or have any
25 * questions.
26 */
27 package com.sun.javatest.util;
28
29 import java.io.File;
30 import java.util.Map;
31 import java.util.Collections;
32 import java.util.LinkedHashMap;
33
34 public class FileInfoCache
35 {
36
37 private final int SIZE = 500;
38
39 // we can't use generics in util package but this is actually Map<String, Boolean>
40 private Map<String, Boolean> map = Collections.synchronizedMap( new LinkedHashMap<String, Boolean>() {
41 protected boolean removeEldestEntry(Map.Entry eldest) {
42 return size() > SIZE;
43 }
44 });
45
46 public void put(File f, boolean b) {
47 map.put(f.getAbsolutePath(), b ? Boolean.TRUE : Boolean.FALSE);
48 }
49
50 public Boolean get(File f) {
51 return map.get(f.getAbsolutePath());
52 }
53
54 public void clear() {
55 map.clear();
56 }
57 }
|
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 *
23 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
24 * or visit www.oracle.com if you need additional information or have any
25 * questions.
26 */
27 package com.sun.javatest.util;
28
29 import java.io.File;
30 import java.util.Map;
31 import java.util.Collections;
32 import java.util.LinkedHashMap;
33
34 public class FileInfoCache
35 {
36
37 private final int SIZE = 500;
38
39 // we can't use generics in util package but this is actually Map<String, Boolean>
40 private Map<String, Boolean> map = Collections.synchronizedMap( new LinkedHashMap<String, Boolean>() {
41 protected boolean removeEldestEntry(Map.Entry<String, Boolean> eldest) {
42 return size() > SIZE;
43 }
44 });
45
46 public void put(File f, boolean b) {
47 map.put(f.getAbsolutePath(), b ? Boolean.TRUE : Boolean.FALSE);
48 }
49
50 public Boolean get(File f) {
51 return map.get(f.getAbsolutePath());
52 }
53
54 public void clear() {
55 map.clear();
56 }
57 }
|