ddiff
Version 1.0.0

com.ehsbe.ddiff
Class PathFilter

java.lang.Object
  extended by com.ehsbe.ddiff.PathFilter
All Implemented Interfaces:
FileFilter, java.nio.file.DirectoryStream.Filter<java.nio.file.Path>

public class PathFilter
extends Object
implements java.nio.file.DirectoryStream.Filter<java.nio.file.Path>, FileFilter

A flexible exclude dir entry filter, which allows globbing as well as regular expressions. Globbing entries are always consulted first.

Version:
$Revision: 396 $
Author:
Jens Elkner

Constructor Summary
Constructor and Description
PathFilter(String[] exclude_globs, Pattern[] exclude_regex, boolean follow, boolean hidden)
          Create a new filter based on the given arguments.
PathFilter(String[] globs, String[] regex, boolean follow, boolean hidden)
          Create a new filter based on the given arguments.
 
Method Summary
Modifier and Type Method and Description
 boolean accept(File file)
          
 boolean accept(java.nio.file.Path entry)
          
 boolean followSymlinks()
          Check, whether symlinks should be followed to the final destination.
 boolean useFiles()
          Check, whether one should use File to obtain a directory listing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathFilter

public PathFilter(String[] globs,
                  String[] regex,
                  boolean follow,
                  boolean hidden)
Create a new filter based on the given arguments.

Parameters:
globs - globbing patterns for pathnames to ignore. Might be null, but must NOT contain null or invalid entries.
regex - regex patterns for pathnames to ignore. Might be null, but must NOT contain null or invalid entries.
follow - if true follow symlinks
hidden - if true ignore hidden entries as well

PathFilter

public PathFilter(String[] exclude_globs,
                  Pattern[] exclude_regex,
                  boolean follow,
                  boolean hidden)
Create a new filter based on the given arguments.

Parameters:
exclude_globs - globbing patterns for pathnames to ignore. Might be null, but must NOT contain null or invalid entries.
exclude_regex - regex patterns for pathnames to ignore. Might be null, but must NOT contain null entries.
follow - if true follow symlinks
hidden - if true ignore hidden entries as well
Method Detail

useFiles

public boolean useFiles()
Check, whether one should use File to obtain a directory listing. Default is false, i.e. use the nio Path#newDirectoryStream(Filter) directory scanner instead. It has no influence the filter itself, it is just a convinient central place to store this property. It gets determined by the System property dir.stream.bug, which should be "true" if the traditional File interface should be used.

Returns:
true if traditional File interface should be used.

followSymlinks

public boolean followSymlinks()
Check, whether symlinks should be followed to the final destination. It has actually no effect on this filter but is considered to be a hint for the instance using this filter.

Returns:
true if symlinks should be resolved.

accept

public boolean accept(java.nio.file.Path entry)

Specified by:
accept in interface java.nio.file.DirectoryStream.Filter<java.nio.file.Path>

accept

public boolean accept(File file)

Specified by:
accept in interface FileFilter

ddiff
Version 1.0.0

Created by Jens Elkner