biggests.utils
Class FileFilterExtension

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

public class FileFilterExtension
extends javax.swing.filechooser.FileFilter

Title: File Filter by extension.

Description: Defines a file filter which filters the files which are shown to and can be selected by the user in a file chooser dialog. Valid files are chosen according to a pecific file extension.

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
FileFilterExtension(java.lang.String extension)
          Creates a new extension file filter, to filter files based on their extensions.
 
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 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

FileFilterExtension

public FileFilterExtension(java.lang.String extension)
                    throws java.lang.Exception
Creates a new extension file filter, to filter files based on their extensions.

Parameters:
extension - the String file extension to be filtered
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

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