diff --git a/src/main/org/apache/tools/ant/types/DestDir.java b/src/main/org/apache/tools/ant/types/DestDir.java index 7b2df29b8..1cbd5d1c3 100644 --- a/src/main/org/apache/tools/ant/types/DestDir.java +++ b/src/main/org/apache/tools/ant/types/DestDir.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -55,6 +55,7 @@ package org.apache.tools.ant.types; import java.io.File; +import org.apache.tools.ant.BuildException; /** * This wrapper class is used to represent Destination Directories. @@ -63,6 +64,20 @@ import java.io.File; */ public final class DestDir extends ValidatedFileAttribute { + /** + * empty constructor + */ + public DestDir() {} + + + /** + * file constructor; performs validation + * @param file the file to use + */ + public DestDir(File file) throws BuildException { + setFile(file); + } + private String message = null; protected final String getMessage() { @@ -85,4 +100,4 @@ public final class DestDir extends ValidatedFileAttribute { } return true; } -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/types/DestFile.java b/src/main/org/apache/tools/ant/types/DestFile.java index d45d62264..1597c49de 100644 --- a/src/main/org/apache/tools/ant/types/DestFile.java +++ b/src/main/org/apache/tools/ant/types/DestFile.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -55,6 +55,7 @@ package org.apache.tools.ant.types; import java.io.File; +import org.apache.tools.ant.BuildException; /** * This wrapper class is used to represent Destination Files. @@ -63,6 +64,21 @@ import java.io.File; */ public final class DestFile extends ValidatedFileAttribute { + + /** + * empty constructor + */ + public DestFile() {} + + + /** + * file constructor; performs validation + * @param file the file to use + */ + public DestFile(File file) throws BuildException { + setFile(file); + } + private String message; protected final String getMessage() { @@ -85,4 +101,29 @@ public final class DestFile extends ValidatedFileAttribute { } return true; } -} \ No newline at end of file + + /** + * test for the dest file being newer than the file passed in. + * returns true iff the dest exists and is the same age or newer + * @pre getFile()!=null && dependent!=null + * @param dependent file we are dependent on + * @return true iff we are up to date + */ + public boolean isUpToDate(File dependent) { + if(!getFile().exists()) + return false; + return getFile().lastModified() >= dependent.lastModified(); + } + + /** + * test for the dest file being newer than the SrcFile passed in. + * returns true iff the dest exists and is the same age or newer + * @pre getFile()!=null + * @pre dependent!=null && depedent.getFile!=null; + * @param dependent file we are dependent on + * @return true iff we are up to date + */ + public boolean isUpToDate(SrcFile dependent) { + return isUpToDate(dependent.getFile()); + } +} diff --git a/src/main/org/apache/tools/ant/types/SrcDir.java b/src/main/org/apache/tools/ant/types/SrcDir.java index 456bbfabd..f7f58ca5a 100644 --- a/src/main/org/apache/tools/ant/types/SrcDir.java +++ b/src/main/org/apache/tools/ant/types/SrcDir.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -55,6 +55,7 @@ package org.apache.tools.ant.types; import java.io.File; +import org.apache.tools.ant.BuildException; /** * This wrapper class is used to represent Source(Origin) Directories. @@ -62,7 +63,21 @@ import java.io.File; * @author Magesh Umasankar */ public final class SrcDir extends ValidatedFileAttribute { - + + /** + * empty constructor + */ + public SrcDir() {} + + + /** + * file constructor; performs validation + * @param file the file to use + */ + public SrcDir(File file) throws BuildException { + setFile(file); + } + private String message; protected final String getMessage() { @@ -89,4 +104,4 @@ public final class SrcDir extends ValidatedFileAttribute { } return true; } -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/types/SrcFile.java b/src/main/org/apache/tools/ant/types/SrcFile.java index 47d1a203b..30f9d9d9c 100644 --- a/src/main/org/apache/tools/ant/types/SrcFile.java +++ b/src/main/org/apache/tools/ant/types/SrcFile.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -55,6 +55,7 @@ package org.apache.tools.ant.types; import java.io.File; +import org.apache.tools.ant.BuildException; /** * This wrapper class is used to represent Source(Origin) Files. @@ -63,6 +64,20 @@ import java.io.File; */ public final class SrcFile extends ValidatedFileAttribute { + /** + * empty constructor + */ + public SrcFile() {} + + + /** + * file constructor; performs validation + * @param file the file to use + */ + public SrcFile(File file) throws BuildException { + setFile(file); + } + private String message; protected final String getMessage() { @@ -89,4 +104,4 @@ public final class SrcFile extends ValidatedFileAttribute { } return true; } -} \ No newline at end of file +}