FileFilters.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */


  20. package org.openspcoop2.utils.io;

  21. import java.io.File;
  22. import java.io.FileFilter;

  23. /**
  24.  * FileFilters
  25.  *
  26.  *
  27.  * @author Poli Andrea (apoli@link.it)
  28.  * @author $Author$
  29.  * @version $Rev$, $Date$
  30.  */
  31. public class FileFilters {

  32.     public static final FileFilter DIRECTORIES_ONLY = new FileFilter ()
  33.     {
  34.         @Override
  35.         public boolean accept (File f)
  36.         {
  37.             if (f.exists () && f.isDirectory ()) return true;
  38.             else return false;
  39.         }
  40.     };
  41.    
  42.     public static final FileFilter FILES_ONLY = new FileFilter ()
  43.     {
  44.         @Override
  45.         public boolean accept (File f)
  46.         {
  47.             if (f.exists () && f.isFile ()) return true;
  48.             else return false;
  49.         }
  50.     };
  51.    
  52.     public static final FileFilter HIDDEN_ONLY = new FileFilter ()
  53.     {
  54.         @Override
  55.         public boolean accept (File f)
  56.         {
  57.             if (f.exists () && f.isHidden()) return true;
  58.             else return false;
  59.         }
  60.     };
  61.    
  62.     public static final FileFilter JAR_ONLY = new FileFilter ()
  63.     {
  64.         @Override
  65.         public boolean accept (File f)
  66.         {
  67.             if (f.exists () && f.getName().endsWith(".jar")) return true;
  68.             else return false;
  69.         }
  70.     };
  71.    
  72.     public static final FileFilter WAR_ONLY = new FileFilter ()
  73.     {
  74.         @Override
  75.         public boolean accept (File f)
  76.         {
  77.             if (f.exists () && f.getName().endsWith(".war")) return true;
  78.             else return false;
  79.         }
  80.     };
  81.    
  82.     public static final FileFilter EAR_ONLY = new FileFilter ()
  83.     {
  84.         @Override
  85.         public boolean accept (File f)
  86.         {
  87.             if (f.exists () && f.getName().endsWith(".ear")) return true;
  88.             else return false;
  89.         }
  90.     };
  91.    
  92. }