Browse Source

added empty and file constructors, the latter validates as you go. Also a little IsUpToDate() test for destdir which will should simplify dependency checking.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270384 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 23 years ago
parent
commit
4ae3c9e3c4
4 changed files with 95 additions and 9 deletions
  1. +17
    -2
      src/main/org/apache/tools/ant/types/DestDir.java
  2. +43
    -2
      src/main/org/apache/tools/ant/types/DestFile.java
  3. +18
    -3
      src/main/org/apache/tools/ant/types/SrcDir.java
  4. +17
    -2
      src/main/org/apache/tools/ant/types/SrcFile.java

+ 17
- 2
src/main/org/apache/tools/ant/types/DestDir.java View File

@@ -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;
}
}
}

+ 43
- 2
src/main/org/apache/tools/ant/types/DestFile.java View File

@@ -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;
}
}
/**
* 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());
}
}

+ 18
- 3
src/main/org/apache/tools/ant/types/SrcDir.java View File

@@ -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 <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
*/
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;
}
}
}

+ 17
- 2
src/main/org/apache/tools/ant/types/SrcFile.java View File

@@ -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;
}
}
}

Loading…
Cancel
Save