biggests.utils
Class FileFilterDirectory

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by biggests.utils.FileFilterDirectory

public class FileFilterDirectory
extends javax.swing.filechooser.FileFilter

Title: File Filter with directory exclusion.

Description: Defines a file filter able to exclude specific directories from being shown to and selected by the user in a file chooser.

Copyright: Copyright (C) 2007 Joana Gonçalves This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or any later version. This program 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 General Public License for more details.


Constructor Summary
FileFilterDirectory(java.lang.String[] invalidDirectoryPaths, java.lang.String validFileExtension)
          Creates a new directory file filter, with a specific valid file extension and some invalid directory paths.
 
Method Summary
 boolean accept(java.io.File file)
          Checks if a certain file is acceptable under the filter conditions.
 java.lang.String checkAndAddFileExtension(java.lang.String filePath)
          Checks if filePath has the required file extension on it.
 java.lang.String getDescription()
          Returns the description of this file filter.
 java.lang.String[] getInvalidDirectoryPaths()
          Returns this file filter invalid directory paths.
 java.lang.String getValidFileExtension()
          Returns this file filter valid file extension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileFilterDirectory

public FileFilterDirectory(java.lang.String[] invalidDirectoryPaths,
                           java.lang.String validFileExtension)
                    throws java.lang.Exception
Creates a new directory file filter, with a specific valid file extension and some invalid directory paths.

Parameters:
invalidDirectoryPaths - the String[] list of directory paths to prevent from user selection
validFileExtension - the valid file extension String for the user to select
Throws:
java.lang.Exception - when the file extension is not valid
Method Detail

accept

public boolean accept(java.io.File file)
Checks if a certain file is acceptable under the filter conditions. Returns true if file is accepted, or false otherwise.

Specified by:
accept in class javax.swing.filechooser.FileFilter
Parameters:
file - the File to check
Returns:
a boolean which is true if the file is accepted or false otherwise

getDescription

public java.lang.String getDescription()
Returns the description of this file filter.

Specified by:
getDescription in class javax.swing.filechooser.FileFilter
Returns:
the String description of this file filter

getValidFileExtension

public java.lang.String getValidFileExtension()
Returns this file filter valid file extension.

Returns:
the String valid file extension for this file filter

getInvalidDirectoryPaths

public java.lang.String[] getInvalidDirectoryPaths()
Returns this file filter invalid directory paths.

Returns:
the String[] invalid directory paths for this file filter

checkAndAddFileExtension

public java.lang.String checkAndAddFileExtension(java.lang.String filePath)
Checks if filePath has the required file extension on it. If not, adds the file extension to the path and returns the new path.

Parameters:
filePath - String the file path to check
Returns:
String the file path with the valid file extension