org.ow2.weblab.crawler.filter
Class ExtensionFilter

java.lang.Object
  extended by org.ow2.weblab.crawler.filter.ExtensionFilter
All Implemented Interfaces:
java.io.FileFilter

public class ExtensionFilter
extends java.lang.Object
implements java.io.FileFilter

Use this class when you need a FileFilter on file extension (.jpg, .txt, .mpeg, ...) If reject mode, given extensions are not rejected. Else, the extensions are the only accepted.

Author:
Jérémie Doucy, ymombrun

Field Summary
protected  java.util.List<java.lang.String> extensions
          The extensions to test.
protected  boolean rejectMode
          Whether extensions are the accepted ones or the rejected ones.
 
Constructor Summary
ExtensionFilter(java.util.List<java.lang.String> extentions, boolean rejectMode)
          Create a file filter using extension
 
Method Summary
 boolean accept(java.io.File file)
           
static java.lang.String getFileExtension(java.io.File file)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

extensions

protected java.util.List<java.lang.String> extensions
The extensions to test.


rejectMode

protected boolean rejectMode
Whether extensions are the accepted ones or the rejected ones.

Constructor Detail

ExtensionFilter

public ExtensionFilter(java.util.List<java.lang.String> extentions,
                       boolean rejectMode)
Create a file filter using extension

Parameters:
extentions - The extensions to test.
rejectMode - Whether extensions are the accepted ones or the rejected ones.
Method Detail

accept

public boolean accept(java.io.File file)
Specified by:
accept in interface java.io.FileFilter

getFileExtension

public static java.lang.String getFileExtension(java.io.File file)
Parameters:
file - The file to extract extension.
Returns:
The extension of the file or the empty String if nothing is found.


Copyright © 2004-2011. All Rights Reserved.