com.gridsystems.maven.furabuild
Class ResourceValidator

java.lang.Object
  extended by com.gridsystems.maven.furabuild.ResourceValidator

public class ResourceValidator
extends java.lang.Object

Checks the given resource tree (File), checks that it is valid, and removes it if it is not.

The resource tree is considered valid if it is older than a given source file set.

Author:
Rodrigo Ruiz

Constructor Summary
ResourceValidator()
           
 
Method Summary
protected  long getLastModified(java.io.File f)
          Gets the last modified timestamp of a file.
 boolean isValid(java.util.Collection<java.io.File> resources, java.util.Collection<java.io.File> sources, boolean purge)
          Checks that a resource is older than a set of sources.
 boolean isValid(java.io.File resource, java.util.Collection<java.io.File> sources, boolean purge)
          Checks that a resource is older than a set of sources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceValidator

public ResourceValidator()
Method Detail

isValid

public boolean isValid(java.util.Collection<java.io.File> resources,
                       java.util.Collection<java.io.File> sources,
                       boolean purge)
Checks that a resource is older than a set of sources.

Parameters:
resources - File to check
sources - Collection of files to compare with
purge - Whether to remove invalid resources or not
Returns:
true if the resource is still valid; false otherwise

isValid

public boolean isValid(java.io.File resource,
                       java.util.Collection<java.io.File> sources,
                       boolean purge)
Checks that a resource is older than a set of sources.

Parameters:
resource - File to check
sources - Collection of files to compare with
purge - Whether to remove invalid resources or not
Returns:
true if the resource is still valid; false otherwise

getLastModified

protected long getLastModified(java.io.File f)
Gets the last modified timestamp of a file. If a directory is specified, it recursively iterates over the directory contents and returns the earliest timestamp found.

Parameters:
f - The file or directory to process
Returns:
The earliest "last-modified" timestamp in f


Copyright © 2008 Grid Systems, S.A.. All Rights Reserved.