org.jhotdraw.io
Class ExtensionFileFilter

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by org.jhotdraw.io.ExtensionFileFilter

public class ExtensionFileFilter
extends javax.swing.filechooser.FileFilter

Filters files by their extensions.

Version:
$Id: ExtensionFileFilter.java 527 2009-06-07 14:28:19Z rawcoder $
Author:
Werner Randelshofer

Field Summary
private  java.lang.String defaultExtension
           
private  java.lang.String description
           
private  java.util.HashSet<java.lang.String> extensions
           
 
Constructor Summary
ExtensionFileFilter(java.lang.String description, java.lang.String extension)
          Creates a new instance.
ExtensionFileFilter(java.lang.String description, java.lang.String[] extensions)
          Creates a new instance.
 
Method Summary
 boolean accept(java.io.File pathname)
           
 java.lang.String getDescription()
           
 java.util.Set<java.lang.String> getExtensions()
          Returns an unmodifiable set with the filename extensions.
 java.io.File makeAcceptable(java.io.File pathname)
          Appends the extension to the filename, in case it is missing.
 
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

extensions

private java.util.HashSet<java.lang.String> extensions

defaultExtension

private java.lang.String defaultExtension
Constructor Detail

ExtensionFileFilter

public ExtensionFileFilter(java.lang.String description,
                           java.lang.String extension)
Creates a new instance.

Parameters:
description - A human readable description.
extension - The filename extension. This will be converted to lower-case by this method.

ExtensionFileFilter

public ExtensionFileFilter(java.lang.String description,
                           java.lang.String[] extensions)
Creates a new instance.

Parameters:
description - A human readable description.
extensions - The filename extensions. These will be converted to lower-case by this method.
Method Detail

getExtensions

public java.util.Set<java.lang.String> getExtensions()
Returns an unmodifiable set with the filename extensions. All extensions are lower case.


accept

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

makeAcceptable

public java.io.File makeAcceptable(java.io.File pathname)
Appends the extension to the filename, in case it is missing.


getDescription

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