001// Copyright (c) 2001 Hursh Jain (http://www.mollypages.org) 
002// The Molly framework is freely distributable under the terms of an
003// MIT-style license. For details, see the molly pages web site at:
004// http://www.mollypages.org/. Use, modify, have fun !
005
006package fc.io.fileselectors;
007
008import java.io.*;
009import java.util.*;
010
011/**
012Filters a list of files and chooses only normal files (ignores any
013subdirectories).
014
015@author hursh jain
016@date   3/24/2002
017**/   
018  
019//filters based on whether the specified file is a directory (or not)
020public class NormalFileSelector extends ChainedFileSelector 
021{
022//for convenience
023public NormalFileSelector() { 
024  this(null);
025  }
026
027public NormalFileSelector(ChainedFileSelector filter) { 
028  super(filter);
029  }
030
031protected boolean thisfilter(File name) { 
032  if ( ! name.isFile() ) return false; 
033  return true;
034  }
035
036public static void main(String[] args) throws Exception
037  {
038  new Test();
039  }
040
041/**
042Unit Test History   
043<pre>
044Class Version Tester  Status    Notes
0451.0       hj    passed  
046</pre>
047*/
048static private class Test {
049Test() throws Exception
050  {
051  File startdir = new File("c:\\temp");
052  ChainedFileSelector sel = new NormalFileSelector();
053  File[] files = startdir.listFiles(sel);
054  List list = Arrays.asList(files);     
055  System.out.println("total="+ list.size() + ", files=" + list);
056  }
057} //~class Test
058}