01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: InfoFileFilter.java,v 1.11.2.2 2008/01/07 15:14:34 cwl Exp $
07: */
08:
09: package com.sleepycat.je.util;
10:
11: import java.io.File;
12: import java.io.FilenameFilter;
13: import java.util.StringTokenizer;
14:
15: public class InfoFileFilter implements FilenameFilter {
16:
17: /**
18: * Accept files of this format:
19: * je.info.#
20: */
21: public boolean accept(File dir, String name) {
22: boolean ok = false;
23: StringTokenizer tokenizer = new StringTokenizer(name, ".");
24: // there should be two parts
25: if (tokenizer.countTokens() == 3) {
26: String filePrefix = tokenizer.nextToken();
27: String fileSuffix = tokenizer.nextToken();
28: String repeat = tokenizer.nextToken();
29:
30: // check the length and the suffix
31: if (filePrefix.equals("je") && fileSuffix.equals("info")) {
32: // The last part should be a number
33: try {
34: Integer.parseInt(repeat);
35: ok = true;
36: } catch (NumberFormatException e) {
37: ok = false;
38: }
39: }
40: }
41:
42: return ok;
43: }
44: }
|