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.
-
prefix
- The prefix of the file to be matched.
-
suffix
- The suffix of the file to be matched.
-
testSuffix
- If true (the default) then both the suffix and prefix are used to match the filename.
-
FileFilter()
-
Create the filter with the default setting of testing both prefix and suffix
-
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
-
accept(File, String)
- This method is used by the createSequence call to filter the files found
in the supplied directory.
-
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.
-
postProcess(String[])
- This method is called after the directory has been filtered.
-
testFrameNumber(String)
- This method tests the frameNumber portion of the filename.
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.
suffix
protected String suffix
- The suffix of the file to be matched. The value is set by the extractPrefixAndSuffix
method.
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.
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
FileFilter
public FileFilter()
- Create the filter with the default setting of testing both prefix and suffix
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.
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.
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
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