ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r612467 - /ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResource.java
Date Wed, 16 Jan 2008 14:15:01 GMT
Author: stevel
Date: Wed Jan 16 06:14:59 2008
New Revision: 612467

URL: http://svn.apache.org/viewvc?rev=612467&view=rev
Log:
BugID 44239: Add ability of resource classes to act as factories for relative resources

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResource.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResource.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResource.java?rev=612467&r1=612466&r2=612467&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResource.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResource.java Wed Jan
16 06:14:59 2008
@@ -29,12 +29,14 @@
 import org.apache.tools.ant.util.FileUtils;
 import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.Reference;
+import org.apache.tools.ant.types.ResourceFactory;
 
 /**
  * A Resource representation of a File.
  * @since Ant 1.7
  */
-public class FileResource extends Resource implements Touchable, FileProvider {
+public class FileResource extends Resource implements Touchable, FileProvider,
+        ResourceFactory {
 
     private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
     private static final int NULL_FILE
@@ -321,4 +323,18 @@
         return getFile();
     }
 
+    /**
+     * Create a new resource that matches a relative or absolute path.
+     * If the current instance has a baseDir attribute, it is copied.
+     * @param path relative/absolute path to a resource
+     * @return a new resource of type FileResource
+     * @throws BuildException if desired
+     * @since Ant1.8
+     */
+    public Resource getResource(String path) {
+        File newfile = FILE_UTILS.resolveFile(getFile(), path);
+        FileResource fileResource = new FileResource(newfile);
+        fileResource.setBaseDir(getBaseDir());
+        return fileResource;
+    }
 }



Mime
View raw message