public class NumberRangesFileFilter
extends java.lang.Object
implements java.io.FileFilter
This filter can select multiple discontinuous ranges based on a format similar to page selection ranges in various formatting software, such as "34,52-65,67,93-95". The constructor takes a String of this sort and deconstructs it into a list of ranges. The accepted syntax is:
ranges = range
ranges = range "," ranges
range = integer
range = integer "-" integer
Whitespace will be ignored. If the filter constructor is passed anything
that is not a list of numeric ranges of this sort, including being passed
an empty String, then an IllegalArgumentException
will be
thrown.
Constructor and Description |
---|
NumberRangesFileFilter(java.lang.String ranges,
boolean recurse)
Sets up a NumberRangesFileFilter by specifying the ranges of numbers
to accept, and whether to also traverse
folders for recursive search.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(java.io.File file)
Checks whether a file satisfies the number range selection filter.
|
boolean |
accept(java.lang.String str)
Checks whether a String satisfies the number range selection filter.
|
java.lang.String |
toString() |
public NumberRangesFileFilter(java.lang.String ranges, boolean recurse)
ranges
- The ranges of numbers to accept (see class documentation)recurse
- Whether to go into subfoldersjava.lang.IllegalArgumentException
- If the String ranges does not
contain a suitable ranges formatpublic boolean accept(java.io.File file)
accept
in interface java.io.FileFilter
file
- The filepublic boolean accept(java.lang.String str)
str
- The String to check for a number inpublic java.lang.String toString()
toString
in class java.lang.Object