KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > backup > SnapShotFileNameFilter


1 /*
2  * BackupFileNameFilter.java
3  *
4  * Created on December 21, 2003, 10:09 PM
5  */

6
7 package com.sun.enterprise.config.backup;
8
9 import com.sun.enterprise.config.backup.pluggable.BackupEnvironment;
10 import com.sun.enterprise.config.backup.pluggable.EnvironmentFactory;
11 import com.sun.enterprise.config.backup.status.StatusConstants;
12 import java.io.File JavaDoc;
13
14 /**
15  *
16  * @author sridatta
17  */

18 public class SnapShotFileNameFilter implements java.io.FilenameFilter JavaDoc {
19     
20     private final String JavaDoc _backupFileNamePrefix;
21     /** Creates a new instance of BackupFileNameFilter */
22     public SnapShotFileNameFilter(String JavaDoc backupFileNamePrefix) {
23         _backupFileNamePrefix = backupFileNamePrefix;
24     }
25     
26     public boolean accept(java.io.File JavaDoc dir, String JavaDoc name) {
27         try {
28             return test(name);
29         } catch(Exception JavaDoc e) {
30         }
31         return false;
32     }
33     
34     private boolean test(String JavaDoc name) throws Exception JavaDoc {
35         String JavaDoc[] parts =
36             name.split(DefaultConstants.INTRA_FILENAME_SEPARATOR);
37             
38         BackupEnvironment be =
39             EnvironmentFactory.getEnvironmentFactory().
40                                 getBackupEnvironment();
41         if (!be.getSnapshotFileNamePrefix().equals(parts[0]))
42               return false;
43         
44         try {
45             new Long JavaDoc(parts[1]).longValue();
46             return true;
47         } catch(Exception JavaDoc e) {
48             return false;
49         }
50     }
51 }
52
Popular Tags