Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.stanford.nlp.io
Class NumberRangesFileFilter

    java.lang.Object
      edu.stanford.nlp.io.NumberRangesFileFilter

All Implemented Interfaces:
  FileFilter

    public class NumberRangesFileFilter

extends Object
implements FileFilter

Implements a file filter that examines a number in a filename to determine acceptance. This is useful for wanting to process ranges of numbered files in collections where each file has some name, part of which is alphabetic and constant, and part of which is numeric. The test is evaluated based on the rightmost natural number found in the filename string. (It only looks in the final filename, not in other components of the path.) Number ranges are inclusive.

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.

Author:
  Christopher Manning

Constructor Summary
`NumberRangesFileFilter(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.

Method Summary
`boolean` | `accept(File file)` Checks whether a file satisfies the number range selection filter.
`boolean` | `accept(String str)` Checks whether a String satisfies the number range selection filter.
`String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### NumberRangesFileFilter

    public NumberRangesFileFilter(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.

  Parameters:
    `ranges` - The ranges of numbers to accept (see class documentation)
    `recurse` - Whether to go into subfolders
  Throws:
    `IllegalArgumentException` - If the String ranges does not contain a suitable ranges format

Method Detail

### accept

    public boolean accept(File file)

  Checks whether a file satisfies the number range selection filter. The test is evaluated based on the rightmost natural number found in the filename string (proper, not including directories in a path).

  Specified by:
    `accept` in interface `FileFilter`
  Parameters:
    `file` - The file
  Returns:
    true If the file is within the ranges filtered for

### accept

    public boolean accept(String str)

  Checks whether a String satisfies the number range selection filter. The test is evaluated based on the rightmost natural number found in the String. Note that this is just evaluated on the String as given. It is not trying to interpret it as a filename and to decide whether the file exists, is a directory or anything like that.

  Parameters:
    `str` - The String to check for a number in
  Returns:
    true If the String is within the ranges filtered for

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Stanford NLP Group