org.apache.tools.ant.taskdefs.condition
Class IsLastModified

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.taskdefs.condition.IsLastModified
All Implemented Interfaces:
java.lang.Cloneable, Condition

public class IsLastModified
extends ProjectComponent
implements Condition

Condition that makes assertions about the last modified date of a resource.

Since:
Ant 1.8.0

Nested Class Summary
static class IsLastModified.CompareMode
          describes comparison modes.
 
Field Summary
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
IsLastModified()
           
 
Method Summary
 void add(Resource r)
          The resource to test.
 boolean eval()
          evaluate the condition
protected  long getMillis()
          Calculate timestamp as millis either based on millis or dateTime (and pattern) attribute.
 void setDatetime(java.lang.String dateTime)
          Set the new modification time of file(s) touched in the format "MM/DD/YYYY HH:MM AM or PM" or "MM/DD/YYYY HH:MM:SS AM or PM".
 void setMillis(long millis)
          Set the new modification time of file(s) touched in milliseconds since midnight Jan 1 1970.
 void setMode(IsLastModified.CompareMode mode)
          The type of comparison to test.
 void setPattern(java.lang.String pattern)
          Set the format of the datetime attribute.
protected  void validate()
          Argument validation.
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IsLastModified

public IsLastModified()
Method Detail

setMillis

public void setMillis(long millis)
Set the new modification time of file(s) touched in milliseconds since midnight Jan 1 1970.

Parameters:
millis - the long timestamp to use.

setDatetime

public void setDatetime(java.lang.String dateTime)
Set the new modification time of file(s) touched in the format "MM/DD/YYYY HH:MM AM or PM" or "MM/DD/YYYY HH:MM:SS AM or PM".

Parameters:
dateTime - the String date in the specified format.

setPattern

public void setPattern(java.lang.String pattern)
Set the format of the datetime attribute.

Parameters:
pattern - the SimpleDateFormat-compatible format pattern.

add

public void add(Resource r)
The resource to test.

Parameters:
r - the resource to test

setMode

public void setMode(IsLastModified.CompareMode mode)
The type of comparison to test.

Parameters:
mode - the mode of comparison.

validate

protected void validate()
                 throws BuildException
Argument validation.

Throws:
BuildException - if the required attributes are not supplied or if there is an inconsistency in the attributes.

getMillis

protected long getMillis()
                  throws BuildException
Calculate timestamp as millis either based on millis or dateTime (and pattern) attribute.

Returns:
time in milliseconds
Throws:
BuildException - if the date cannot be parsed.

eval

public boolean eval()
             throws BuildException
evaluate the condition

Specified by:
eval in interface Condition
Returns:
true or false depending on the compoarison mode and the time of the resource
Throws:
BuildException