All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class quicktime.app.image.FileFilter

java.lang.Object
   |
   +----quicktime.app.image.FileFilter

public class FileFilter
extends Object
implements FilenameFilter
This class is used by the ImageUtil.createSequence call. It is used to filter the contents of a directory and return true to those files that match the pattern that this expects. After the files are selected the array of fileNames accepted are submitted to the postProcess method which returns an array of fileNames which will then be used to create a sequence of images in the order of the files in this array.

The filename format that this filter expects is:

Both prefix and suffix can be empty, but requires that there be at least one numeric character in the name of the file.

No sorting is done on the resulting file list, so generally the files will be opened and added to the sequence in alpha/numeric order. So for files to appear in proper numeric order you will need to specify leading zeroes in the frame numbers.

You can also pass in a boolean flag to indicate that the filter should ignore the suffix of the filename when matching.

Subclasses can overide or extend the methods to provide custom filtering operations.


Variable Index

 o prefix
The prefix of the file to be matched.
 o suffix
The suffix of the file to be matched.
 o testSuffix
If true (the default) then both the suffix and prefix are used to match the filename.

Constructor Index

 o FileFilter()
Create the filter with the default setting of testing both prefix and suffix
 o FileFilter(boolean)
Create the filter with the flag set (if true - the default) which will test the suffix and prefix or if false it will test the prefix only

Method Index

 o accept(File, String)
This method is used by the createSequence call to filter the files found in the supplied directory.
 o extractPrefixAndSuffix(String)
It dissects the incoming fName (the name of a file) into a prefix which are all the characters of the fileName that precede the last occurance of a number in the filename and a suffix the extracts the characters that immediately follow the last occurance of a number in the fName.
 o postProcess(String[])
This method is called after the directory has been filtered.
 o testFrameNumber(String)
This method tests the frameNumber portion of the filename.

Variables

 o prefix
 protected String prefix
The prefix of the file to be matched. The value is set by the extractPrefixAndSuffix method. It should always have a value - even if it is just an empty string.

 o suffix
 protected String suffix
The suffix of the file to be matched. The value is set by the extractPrefixAndSuffix method.

 o testSuffix
 protected boolean testSuffix
If true (the default) then both the suffix and prefix are used to match the filename. If false then only the prefix is matched.

Constructors

 o FileFilter
 public FileFilter(boolean testSuffix)
Create the filter with the flag set (if true - the default) which will test the suffix and prefix or if false it will test the prefix only

 o FileFilter
 public FileFilter()
Create the filter with the default setting of testing both prefix and suffix

Methods

 o extractPrefixAndSuffix
 protected void extractPrefixAndSuffix(String fName)
It dissects the incoming fName (the name of a file) into a prefix which are all the characters of the fileName that precede the last occurance of a number in the filename and a suffix the extracts the characters that immediately follow the last occurance of a number in the fName. It stores the result of these into the instance variables prefix and suffix respectively.

Subclasses can overwrite this to produce their own semantic for extracting a prefix and suffix - they need to ensure that the instance variables are set with the appropriate values.

Parameters:
fName - the name of the file that is to be disected.
 o testFrameNumber
 protected int testFrameNumber(String fName) throws NumberFormatException
This method tests the frameNumber portion of the filename. If this string does NOT have a number it will throw a NumberFormatException. It returns the resulting number.

 o accept
 public boolean accept(File dir,
                       String fName)
This method is used by the createSequence call to filter the files found in the supplied directory. It returns true if the filename matches the conditions (prefix and suffix are found in the file and between these there is a number). Both prefix and suffix can be empty but the frame number is required.

Parameters:
dir - the directory being filtered
fName - the name of a file found within this directory
Returns:
true if the file matches the conditions otherwise false
 o postProcess
 protected String[] postProcess(String matchedFiles[])
This method is called after the directory has been filtered. The incoming array contains both the file list (files found within the directory that have been accepted as a match) and the order of the files in this list is the order that the files will be added to the sequence. The method can alter this array (or return a new one). The returned array should contain no null values, and the order of the filenames in the returned array is the order that the files will be added to the sequence.

The default implementation returns the list as is.

Parameters:
the - matched list of files
Returns:
the ordered list of files that the sequence will be created from.

All Packages  Class Hierarchy  This Package  Previous  Next  Index