texturesynthesis.util
Class FileExtensionFilter

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by texturesynthesis.util.FileExtensionFilter

public class FileExtensionFilter
extends javax.swing.filechooser.FileFilter

Filters files by the file name extension. To be used with the javax.swing.JFileChooser.

Author:
Aki Koskinen

Field Summary
private  boolean acceptDirectories
          Whether to accept directories or not.
private  java.util.Vector<javax.swing.filechooser.FileFilter> combinedFilter
          A place holder for other filters this filter might use.
private  java.lang.String description
          The description of this filter.
private  java.util.Vector<java.lang.String> extensions
          The file name extensions this filter accepts.
 
Constructor Summary
FileExtensionFilter()
          The constuctor.
 
Method Summary
 boolean accept(java.io.File file)
           
 void addAnotherFilter(javax.swing.filechooser.FileFilter ff)
          Adds another filter this filter can use.
 void addExtension(java.lang.String extension)
          Adds a file name extension this filter should accept.
 java.lang.String getDescription()
           
 void setDescription(java.lang.String description)
          Sets the description of this filter.
private  boolean stringIsInExtensions(java.lang.String str)
          Checks if the given string is already in the set of extensions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

description

private java.lang.String description
The description of this filter.


extensions

private java.util.Vector<java.lang.String> extensions
The file name extensions this filter accepts.


acceptDirectories

private boolean acceptDirectories
Whether to accept directories or not.


combinedFilter

private java.util.Vector<javax.swing.filechooser.FileFilter> combinedFilter
A place holder for other filters this filter might use.

Constructor Detail

FileExtensionFilter

public FileExtensionFilter()
The constuctor.

Method Detail

accept

public boolean accept(java.io.File file)
Specified by:
accept in class javax.swing.filechooser.FileFilter
See Also:
FileFilter.accept(java.io.File)

setDescription

public void setDescription(java.lang.String description)
Sets the description of this filter. For example: "JPG and GIF Images"

Parameters:
description - the description

getDescription

public java.lang.String getDescription()
Specified by:
getDescription in class javax.swing.filechooser.FileFilter
See Also:
FileFilter.getDescription()

addExtension

public void addExtension(java.lang.String extension)
Adds a file name extension this filter should accept. The extension can be for example "txt" or "pdf". Case of the characters doesn't matter so you don't have to include for example "jpg" and "JPG". The extensions should not include a dot in the beginning.

Parameters:
extension - the extension to be added.

addAnotherFilter

public void addAnotherFilter(javax.swing.filechooser.FileFilter ff)
Adds another filter this filter can use.

Parameters:
ff - the another filter.

stringIsInExtensions

private boolean stringIsInExtensions(java.lang.String str)
Checks if the given string is already in the set of extensions.

Parameters:
str - the string
Returns:
true is the string is already in the set of extensions.