com.Prominic.jFTPd
Class WildcardFilter

java.lang.Object
  extended by com.Prominic.jFTPd.WildcardFilter
All Implemented Interfaces:
java.io.FilenameFilter

 class WildcardFilter
extends java.lang.Object
implements java.io.FilenameFilter


Field Summary
(package private)  boolean endsWithStar
           
(package private)  boolean mustBeFile
           
(package private)  java.lang.String pattern
           
(package private)  boolean startsWithStar
           
(package private)  java.lang.String[] subpatterns
           
 
Constructor Summary
WildcardFilter(java.lang.String p)
          Creates a filter based on the given pattern.
WildcardFilter(java.lang.String p, boolean mbf)
          Creates a filter based on the given pattern.
 
Method Summary
 boolean accept(java.io.File file, java.lang.String filename)
          Returns true if the file is accepted by the filter.
protected  int getMatchPosition(java.lang.String s, java.lang.String pat, int pos)
          Obtains the match position
protected  boolean matchChar(char patChar, char ch)
          Matches a char if the chars are identical, or the pattern char is '?'
 boolean matchesPattern(java.lang.String filename)
          Checks if the filename matches the pattern given when the filter was created.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pattern

java.lang.String pattern

subpatterns

java.lang.String[] subpatterns

startsWithStar

boolean startsWithStar

endsWithStar

boolean endsWithStar

mustBeFile

boolean mustBeFile
Constructor Detail

WildcardFilter

public WildcardFilter(java.lang.String p)
Creates a filter based on the given pattern. Will match directories too.

Parameters:
p - - pattern

WildcardFilter

public WildcardFilter(java.lang.String p,
                      boolean mbf)
Creates a filter based on the given pattern. You can control whether the generated list will contain directories.

Parameters:
p - - pattern
mbf - - set to true if you want directories to be included in the generated list.
Method Detail

accept

public boolean accept(java.io.File file,
                      java.lang.String filename)
Returns true if the file is accepted by the filter.

Specified by:
accept in interface java.io.FilenameFilter
Returns:
true if the file matches the pattern; if the filter was requested to only accept files, it will return false for directories that match the pattern.

getMatchPosition

protected int getMatchPosition(java.lang.String s,
                               java.lang.String pat,
                               int pos)
Obtains the match position

Parameters:
s - - file name
pat - - pattern
pos - - position where to start matching from.
Returns:
- next matching position.

matchChar

protected boolean matchChar(char patChar,
                            char ch)
Matches a char if the chars are identical, or the pattern char is '?'

Parameters:
patChar - - pattern char to be matched.
ch - - actual character
Returns:
true if the patChar equals ch, or if patChar is '?'

matchesPattern

public boolean matchesPattern(java.lang.String filename)
Checks if the filename matches the pattern given when the filter was created.

Parameters:
filename - - filename to be checked against the pattern.
Returns:
- true if filename matches the pattern.