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.
Field Summary |
protected java.lang.String |
prefix
The prefix of the file to be matched. |
protected java.lang.String |
suffix
The suffix of the file to be matched. |
protected boolean |
testSuffix
If true (the default) then both the suffix and prefix are used to match the filename. |
Constructor Summary |
FileFilter()
Create the filter with the default setting of testing both prefix and suffix |
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 |
Method Summary |
boolean |
accept(java.io.File dir,
java.lang.String fName)
This method is used by the createSequence call to filter the files found
in the supplied directory. |
protected void |
extractPrefixAndSuffix(java.lang.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. |
protected java.lang.String[] |
postProcess(java.lang.String[] matchedFiles)
This method is called after the directory has been filtered. |
protected int |
testFrameNumber(java.lang.String fName)
This method tests the frameNumber portion of the filename. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
prefix
protected java.lang.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 java.lang.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(java.lang.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(java.lang.String fName)
throws java.lang.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(java.io.File dir,
java.lang.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.
- Specified by:
accept
in interface java.io.FilenameFilter
- Parameters:
dir
- the directory being filteredfName
- the name of a file found within this directory- Returns:
- true if the file matches the conditions otherwise false
postProcess
protected java.lang.String[] postProcess(java.lang.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.