XDC - v. 0.6.1

net.sf.xdc.util
Class PathDescriptor

java.lang.Object
  extended bynet.sf.xdc.util.PathDescriptor
All Implemented Interfaces:
java.io.FilenameFilter

public class PathDescriptor
extends java.lang.Object
implements java.io.FilenameFilter

This class implements the FilenameFilter interface and is used to filter out files from a list of files contained in a directory.

Since:
0.5
Version:
0.5
Author:
Jens Voß

Constructor Summary
PathDescriptor(java.lang.String path, boolean defaultExcludes)
          Public constructor.
 
Method Summary
 boolean accept(java.io.File dir, java.lang.String name)
          This is an implementation of the method defined in the FilenameFilter interface.
static java.lang.String convert(java.lang.String str)
          This utility method is used to convert an expression containing "basic" wildcards like "?"
 PathDescriptor getChildDescriptor()
          If the path used for construction of this PathDescriptor consists of more than one constituent, this method can be used to retrieve a child descriptor corresponding to the sub-path after the first constituent.
 boolean matches(java.io.File file)
          This method determines whether a String matches the pattern expressed by the first constituent of the path used for construction of this PathDescriptor.
 boolean matchesDirWithWildcard(java.io.File file)
          This method determines whether a file is a directory and the path pattern of this PathDescriptor is the path wildcard pattern ("**").
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathDescriptor

public PathDescriptor(java.lang.String path,
                      boolean defaultExcludes)
Public constructor.

Parameters:
path - A path pattern. Its constituents are delimited by forward slashes ('/') and may contain "basic" wildcards: An asterisk ("*") means "any substring" (even an empty substring); a question mark ("?") means "any character".
defaultExcludes - Specifies whether directories or files probably containing version control information should be excluded from processing
Method Detail

convert

public static java.lang.String convert(java.lang.String str)
This utility method is used to convert an expression containing "basic" wildcards like "?" (any character), "*" (any sequence of characters except a path separator), "**" (any seqence of directory names contained in each other) to a regular expression.

Parameters:
str - The string to be converted to a regular expression
Returns:
A regular expression corresponding to the string with "basic" wildcards

accept

public boolean accept(java.io.File dir,
                      java.lang.String name)
This is an implementation of the method defined in the FilenameFilter interface. It tests whether a file with a certain name is included in the list passing through this filter.

Specified by:
accept in interface java.io.FilenameFilter
Parameters:
dir - The directory in which the file is found
name - The name of the file
Returns:
true if the file should be included in the list (in this case if and only if the file name matches the pattern of the first constituent of the path used for construction); false otherwise

matchesDirWithWildcard

public boolean matchesDirWithWildcard(java.io.File file)
This method determines whether a file is a directory and the path pattern of this PathDescriptor is the path wildcard pattern ("**").

Parameters:
file - The file to be tested
Returns:
true if this PathDescriptor's path pattern is "**" and the file exists and is a directory and is not to be excluded because it might be a version control directory.

matches

public boolean matches(java.io.File file)
This method determines whether a String matches the pattern expressed by the first constituent of the path used for construction of this PathDescriptor.

Parameters:
file - The File whose name is to be compared to the pattern of this PathDescriptor
Returns:
true if the String matches the pattern; false otherwise

getChildDescriptor

public PathDescriptor getChildDescriptor()
If the path used for construction of this PathDescriptor consists of more than one constituent, this method can be used to retrieve a child descriptor corresponding to the sub-path after the first constituent.

Returns:
The sub-path after the first constituent of the path used for constructing this PathDescriptor. If that path only consisted of one such part, the method returns null.

XDC - v. 0.6.1