bb.io.filefilter
Class OmniFilter

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by bb.io.filefilter.OmniFilter
All Implemented Interfaces:
FileFilter

public class OmniFilter
extends FileFilter
implements FileFilter

This file filter accepts all files. One of the constructors allows you to specify whether or not to accept directories also. (The default is to accept directories.)

Note that this class is both a subclass of javax.swing.filechooser.FileFilter (so that it can be passed to JFileChooser), as well as an implementation of java.io.FileFilter (so that it is suitable as an argument to File.listFiles).

This class is multithread safe: it is immutable (both its immediate state, as well as the deep state of its fields).

Author:
Brent Boyer

Field Summary
private  boolean acceptDirectory
           
 
Constructor Summary
OmniFilter()
          Constructs a new OmniFilter instance; directories are accepted.
OmniFilter(boolean acceptDirectory)
          Constructs a new OmniFilter instance with the specification for whether to accept directories or not.
 
Method Summary
 boolean accept(File file)
          Reports whether or not the supplied File is accepted by this filter.
 String getDescription()
          Returns a description of this filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

acceptDirectory

private final boolean acceptDirectory
Constructor Detail

OmniFilter

public OmniFilter()
Constructs a new OmniFilter instance; directories are accepted.


OmniFilter

public OmniFilter(boolean acceptDirectory)
Constructs a new OmniFilter instance with the specification for whether to accept directories or not.

Method Detail

accept

public boolean accept(File file)
               throws IllegalArgumentException,
                      SecurityException
Reports whether or not the supplied File is accepted by this filter.

Specified by:
accept in interface FileFilter
Specified by:
accept in class FileFilter
Throws:
IllegalArgumentException - if file is null
SecurityException - if a security manager exists and its SecurityManager.checkRead(java.lang.String) method denies read access to the file

getDescription

public String getDescription()
Returns a description of this filter.

Specified by:
getDescription in class FileFilter