de.fu_berlin.ties.io
Class ExtensionFilter

java.lang.Object
  extended by de.fu_berlin.ties.io.ExtensionFilter
All Implemented Interfaces:
FileFilter

public class ExtensionFilter
extends Object
implements FileFilter

A file filter that checks the extension to decide whether to accept a file. Don't prepend a dot when specifying extensions -- this happens automatically.

Version:
$Revision: 1.2 $, $Date: 2004/09/06 17:23:31 $, $Author: siefkes $
Author:
Christian Siefkes

Constructor Summary
ExtensionFilter(Set<String> extensionSet, boolean ignoreCase)
          Creates a new instance.
ExtensionFilter(String extension, boolean ignoreCase)
          Creates a new instance that accepts only a single extension.
 
Method Summary
 boolean accept(File pathname)
          Tests whether or not the specified abstract pathname should be included in a pathname list.
 Set getExtensions()
          The immutable set of extensions (Strings) accepted by this filter.
 boolean isCaseIgnored()
          Whether case is ignored when matching the extension.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExtensionFilter

public ExtensionFilter(String extension,
                       boolean ignoreCase)
Creates a new instance that accepts only a single extension.

Parameters:
extension - the extension to accept
ignoreCase - whether case is ignored when matching the extension; if true, extension must be lower-case or matching will fail (file extensions are converted to lower-case prior to comparing)

ExtensionFilter

public ExtensionFilter(Set<String> extensionSet,
                       boolean ignoreCase)
Creates a new instance.

Parameters:
extensionSet - the set of extensions (Strings) to accept
ignoreCase - whether case is ignored when matching the extension; if true, extensionSet must contain only lower-case entries or matching will fail (file extensions are converted to lower-case, but the contents of the set are used as is)
Method Detail

accept

public boolean accept(File pathname)
Tests whether or not the specified abstract pathname should be included in a pathname list.

Specified by:
accept in interface FileFilter
Parameters:
pathname - the abstract pathname to be tested
Returns:
true iff the extension of the pathname is contained in the

getExtensions

public Set getExtensions()
The immutable set of extensions (Strings) accepted by this filter.

Returns:
the value of the attribute

isCaseIgnored

public boolean isCaseIgnored()
Whether case is ignored when matching the extension. If true, file extensions are converted to lower case prior to comparing them.

Returns:
the value of the attribute

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object
Returns:
a textual representation


Copyright © 2003-2004 Christian Siefkes. All Rights Reserved.