Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/flexstor/common/io/file/filters/ExtensionFilter.java


1   /*
2    * ExtensionFilter.java
3    *
4    * Copyright $Date: 2003/08/11 02:22:47 $ FLEXSTOR.net Inc.
5    *
6    * This work is licensed for use and distribution under license terms found at
7    * http://www.flexstor.org/license.html
8    *
9    */
10  
11  package com.flexstor.common.io.file.filters;
12  
13  import java.io.File;
14  import java.io.FilenameFilter;
15  
16  public class ExtensionFilter
17     implements FilenameFilter
18  {
19     String  sExtension = null;
20     boolean bInclude   = true;
21  
22     public ExtensionFilter( String sExtension, boolean bInclude )
23     {
24        if ( sExtension != null )
25           this.sExtension = "." + sExtension.toUpperCase();
26  
27        this.bInclude = bInclude;
28     }
29  
30     public boolean accept( File file, String sFileName )
31     {
32        if ( sExtension != null )
33        {
34           if ( bInclude )
35              return sFileName.toUpperCase().endsWith( sExtension );
36           else
37              return !sFileName.toUpperCase().endsWith( sExtension );
38        }
39        else
40           return true;
41     }
42  
43  } // end of class