// -*- c++ -*-

/*
 * Jakelib2 - General purpose C++ library
 * Copyright (C) 2001 Florian Wolff  (florian@donuz.de)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * $Id: FilenameExtensionFilter.h,v 1.3 2003/03/02 11:20:02 florian Exp $
 */

#ifndef INCLUDE_JAKELIB2_IO_FILENAMEEXTENSIONFILTER_H
# define INCLUDE_JAKELIB2_IO_FILENAMEEXTENSIONFILTER_H
#include "FilenameFilter.h"

namespace jakelib {
  namespace util {
    class ArrayList;
    class StringTokenizer;
  }
  namespace io {
    class File;

    /**
     * \c FilenameExtensionFilter implements a simple extension filename filter.
     *
     * @class FilenameExtensionFilter
     * @version $Id: FilenameExtensionFilter.h,v 1.3 2003/03/02 11:20:02 florian Exp $
     * @author Florian 'Overflo' Wolff (florian@donuz.de)
     */
    class FilenameExtensionFilter : public jakelib::lang::Object, 
                                    public FilenameFilter
      {
      public:

        /**
         * Creates a new \c FilenameExtensionFilter with the given filename
         * extension.
         */
	FilenameExtensionFilter(jakelib::lang::String *extension);

        /**
         * Creates a new \c FilenameExtensionFilter with a number of filename
         * extension given as a \c StringTokenizer.
         */
	FilenameExtensionFilter(jakelib::util::StringTokenizer *extensions);


        /**
         * This method determines whether or not a given file should be included
         * in a directory listing.
         *
         * @param dir  The \c File instance for the directory being read.
         *             Totally ignored in this sub-class.
         * @param name The name of the file to test.
         *
         * @return \c true if the file should be included in the list,
         *         \c false otherwise.
         */
        jboolean accept(File *dir, jakelib::lang::String *name);

        /**
         * Returns a short description of this filename filter.
         */
        jakelib::lang::String *toString();

      protected:

        /** Holds the allowed extensions. */
        jakelib::lang::Strings *extensions;

	JAKELIB_DECLARE_CLASS(FilenameExtensionFilter);
      };
  }
}
#endif

