org.jutil.io.fileset
Class PatternPredicate

java.lang.Object
  |
  +--org.jutil.predicate.AbstractPredicate
        |
        +--org.jutil.io.fileset.FilePredicate
              |
              +--org.jutil.io.fileset.BaseDirPredicate
                    |
                    +--org.jutil.io.fileset.PatternPredicate
All Implemented Interfaces:
CollectionOperator, FileSetPredicate, Predicate

public class PatternPredicate
extends BaseDirPredicate
implements FileSetPredicate

A class of predicates that check whether a filename matches a certain pattern relative to a base directory.

A PatternPredicate can optionally "contain" another predicate, so it can be used in filesets.


Fields inherited from class org.jutil.io.fileset.BaseDirPredicate
CVS_REVISION
 
Fields inherited from interface org.jutil.predicate.Predicate
CVS_REVISION
 
Constructor Summary
PatternPredicate(java.io.File baseDir, FileNamePattern pattern)
          Initialize a new PatternPredicate with the given base directory and pattern.
PatternPredicate(java.io.File baseDir, FileNamePattern pattern, Predicate predicate)
          Initialize a new PatternPredicate with the given base directory, pattern and predicate .
 
Method Summary
 boolean enterDirectory(java.io.File directory)
          FIXME
 boolean evalFile(java.io.File file)
           
 java.lang.String getFullRegexPattern()
          Return the regex pattern of this PatternPredicate.
 FileNamePattern getPattern()
          Return the pattern of this PatternPredicate.
 Predicate getPredicate()
           
(package private)  java.lang.String getRegexSeparator()
           
 java.util.List getSubPredicates()
          Return the subpredicates of this Predicate.
 int nbSubPredicates()
          Return the size of this Predicate.
 java.util.List suggestDirectories()
          Suggest a list of directories which can contain files that will evaluate to true for this FilePredicate. All files that can make this FilePredicate true will be in one of the returned directories.
 
Methods inherited from class org.jutil.io.fileset.BaseDirPredicate
getBaseDir
 
Methods inherited from class org.jutil.io.fileset.FilePredicate
eval
 
Methods inherited from class org.jutil.predicate.AbstractPredicate
count, equals, exists, filter, forall
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jutil.predicate.Predicate
count, equals, eval, exists, filter, forall
 
Methods inherited from interface org.jutil.java.collections.CollectionOperator
isValidElement
 

Constructor Detail

PatternPredicate

public PatternPredicate(java.io.File baseDir,
                        FileNamePattern pattern)
Initialize a new PatternPredicate with the given base directory and pattern.

Parameters:
baseDir - The base directory for the new PatternPredicate.
pattern - The pattern for the new PatternPredicate.

Specifications:
public behavior
requires baseDir != null;
requires baseDir.isDirectory();
requires pattern != null;
ensures getBaseDir() == baseDir;
ensures getPattern() == pattern;
ensures getPredicate().equals(new True());

PatternPredicate

public PatternPredicate(java.io.File baseDir,
                        FileNamePattern pattern,
                        Predicate predicate)
Initialize a new PatternPredicate with the given base directory, pattern and predicate .

Parameters:
baseDir - The base directory for the new PatternPredicate.
pattern - The pattern for the new PatternPredicate.
predicate - The predicate for the new PatternPredicate.

Specifications:
public behavior
requires baseDir != null;
requires baseDir.isDirectory();
requires pattern != null;
requires predicate != null;
ensures getBaseDir() == baseDir;
ensures getPattern() == pattern;
ensures getPredicate().equals(new True());
Method Detail

getPattern

public FileNamePattern getPattern()
Return the pattern of this PatternPredicate.

Specifications:
public behavior
ensures \result != null;

getFullRegexPattern

public java.lang.String getFullRegexPattern()
Return the regex pattern of this PatternPredicate.

Specifications:
public behavior
ensures \result != null;

evalFile

public boolean evalFile(java.io.File file)
                 throws java.lang.Exception
Specifications:
     also
public behavior
ensures new Pattern(getFullRegexPattern()).matches(file.getAbsolutePath())&&getPredicate().eval(file);

Specifications inherited from overridden method in class FilePredicate:
public behavior
requires file != null;
ensures \result == true|\result == false;

nbSubPredicates

public int nbSubPredicates()
Description copied from interface: Predicate
Return the size of this Predicate.

Specifications:
     also
public behavior
ensures \result == 1;

Specifications inherited from overridden method in class AbstractPredicate:
      --- None ---
Specifications inherited from overridden method in interface Predicate:
public behavior
ensures \result == getSubPredicates().size();

getSubPredicates

public java.util.List getSubPredicates()
Description copied from interface: Predicate
Return the subpredicates of this Predicate.

Specifications:
     also
public behavior
ensures \result .contains(getPredicate());
ensures \result .size() == 1;

Specifications inherited from overridden method in interface Predicate:
public behavior
ensures \result != null;
ensures !\result .contains(null);
ensures !\result .contains(this);

getPredicate

public Predicate getPredicate()
Specifications:
public behavior
ensures \result != null;

suggestDirectories

public java.util.List suggestDirectories()
Description copied from interface: FileSetPredicate

Suggest a list of directories which can contain files that will evaluate to true for this FilePredicate.

All files that can make this FilePredicate true will be in one of the returned directories.

Specifications:
     also
public behavior
ensures \fresh(\result );
ensures \result .size() == 1;

Specifications inherited from overridden method in interface FileSetPredicate:
public behavior
ensures \result != null;
ensures ( \forall Object o; Collections.containsExplicitly(\result ,o); (o instanceof File)&&((File)o).isDirectory());

enterDirectory

public boolean enterDirectory(java.io.File directory)
FIXME
Specifications inherited from overridden method in interface FileSetPredicate:
public behavior
requires directory != null;
ensures \result == true|\result == false;

getRegexSeparator

java.lang.String getRegexSeparator()