org.pietschy.command.file

Class ExtensionFileFilter


public class ExtensionFileFilter
extends FileFilter

An implementation of FileFilter that is based on the extension of a file.
Version:
$Revision: 1.3 $
Author:
andrewp

Constructor Summary

ExtensionFileFilter(String extension, String description)
Creates a new filter for the specified file extension with that has the specified description.

Method Summary

boolean
accept(File f)
Accepts files that end with the specified extension.
File
checkAndAddExtension(File file)
Checks that the specified file has an extension defined.
String
getDescription()
boolean
isIgnoreCase()
void
setIgnoreCase(boolean ignoreCase)

Constructor Details

ExtensionFileFilter

public ExtensionFileFilter(String extension,
                           String description)
Creates a new filter for the specified file extension with that has the specified description.
Parameters:
extension - the file extension to excluding the preceeding '.', ie "java", not ".java".
description - the user friendly description of the file filter.

Method Details

accept

public boolean accept(File f)
Accepts files that end with the specified extension.
Parameters:
f - the file to check.
Returns:
true if the file name ends with this filters extension.

checkAndAddExtension

public File checkAndAddExtension(File file)
Checks that the specified file has an extension defined. If it does, it is returned as is, even if the extension doesn't match that of the filter. If no extension is specified, a new file is returned based on the original but with the extension defined by this filter.
Parameters:
file - the file to check.
Returns:
a file guarenteed to have the extension specified by this filter.

getDescription

public String getDescription()

isIgnoreCase

public boolean isIgnoreCase()

setIgnoreCase

public void setIgnoreCase(boolean ignoreCase)