You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ad...@apache.org on 2002/10/23 12:58:12 UTC
cvs commit: jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/tasks VfsTask.java ShowFileTask.java
adammurdoch 2002/10/23 03:58:12
Modified: vfs/src/java/org/apache/commons/vfs/tasks ShowFileTask.java
Added: vfs/src/java/org/apache/commons/vfs/tasks VfsTask.java
Log:
Extract a VfsTask superclass out of ShowFileTask.
Revision Changes Path
1.2 +4 -10 jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/tasks/ShowFileTask.java
Index: ShowFileTask.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/tasks/ShowFileTask.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ShowFileTask.java 21 Aug 2002 01:40:45 -0000 1.1
+++ ShowFileTask.java 23 Oct 2002 10:58:12 -0000 1.2
@@ -8,17 +8,13 @@
package org.apache.commons.vfs.tasks;
import java.io.BufferedReader;
-import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Date;
import org.apache.commons.vfs.FileContent;
import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileSystemManager;
-import org.apache.commons.vfs.FileSystemManagerFactory;
import org.apache.commons.vfs.FileType;
import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
/**
* An Ant task, which writes the details of a file to Ant's log.
@@ -27,7 +23,7 @@
* @version $Revision$ $Date$
*/
public class ShowFileTask
- extends Task
+ extends VfsTask
{
private String url;
private boolean showContent;
@@ -35,7 +31,7 @@
/**
* The URL of the file to display.
*/
- public void setUrl( final String url )
+ public void setFile( final String url )
{
this.url = url;
}
@@ -57,9 +53,7 @@
try
{
// Lookup the file
- final FileSystemManager manager = FileSystemManagerFactory.getManager();
- final File baseDir = getProject().getBaseDir();
- final FileObject file = manager.resolveFile( baseDir, url );
+ final FileObject file = resolveFile( url );
// Write details
log( "URI: " + file.getName().getURI() );
1.1 jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/tasks/VfsTask.java
Index: VfsTask.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.commons.vfs.tasks;
import org.apache.tools.ant.Task;
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.FileSystemManagerFactory;
import org.apache.commons.vfs.FileSystemManager;
/**
* Base class for the VFS Ant tasks. Provides some utility methods.
*
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
* @version $Revision: 1.1 $ $Date: 2002/10/23 10:58:12 $
*/
public class VfsTask
extends Task
{
private FileSystemManager manager;
/**
* Resolves a URI to a file. Relative URI are resolved relative to the
* project directory.
*
* @param uri The URI to resolve.
*/
protected FileObject resolveFile( final String uri )
throws FileSystemException
{
if ( manager == null )
{
manager = FileSystemManagerFactory.getManager();
}
return manager.resolveFile( getProject().getBaseDir(), uri );
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>