adammurdoch 02/02/25 03:09:10
Modified: proposal/myrmidon/src/java/org/apache/antlib/vfile
PatternFileSet.java
StringToFileObjectConverter.java
Added: proposal/myrmidon/src/java/org/apache/antlib/vfile
FileSetAdaptor.java FileSetToFileListConverter.java
ListFilesTask.java
Log:
* Add a converter to convert from <v-fileset> to <v-path>, rather
than doing so in the default <v-fileset> or <v-path> implementations.
* Add test <v-list-files> task.
Revision Changes Path
1.2 +3 -19
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/PatternFileSet.java
Index: PatternFileSet.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/PatternFileSet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PatternFileSet.java 21 Feb 2002 03:26:23 -0000 1.1
+++ PatternFileSet.java 25 Feb 2002 11:09:09 -0000 1.2
@@ -26,7 +26,7 @@
*/
public class PatternFileSet
extends AbstractFileSet
- implements FileList, FileSet
+ implements FileSet
{
private final static Resources REZ =
ResourceManager.getPackageResources( PatternFileSet.class );
@@ -42,26 +42,10 @@
}
/**
- * Returns the root directory
- */
- public FileObject getDir()
- {
- return m_dir;
- }
-
- /**
- * Returns the list of files, in depthwise order.
- */
- public FileObject[] listFiles( TaskContext context ) throws TaskException
- {
- final FileSetResult result = getResult( context );
- return result.getFiles();
- }
-
- /**
* Returns the contents of the set.
*/
- public FileSetResult getResult( TaskContext context ) throws
TaskException
+ public FileSetResult getResult( final TaskContext context )
+ throws TaskException
{
if( m_dir == null )
{
1.4 +2 -3
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/StringToFileObjectConverter.java
Index: StringToFileObjectConverter.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/StringToFileObjectConverter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StringToFileObjectConverter.java 21 Feb 2002 10:16:42 -0000 1.3
+++ StringToFileObjectConverter.java 25 Feb 2002 11:09:09 -0000 1.4
@@ -7,14 +7,13 @@
*/
package org.apache.antlib.vfile;
+import org.apache.aut.converter.AbstractConverter;
+import org.apache.aut.converter.ConverterException;
import org.apache.aut.vfs.FileObject;
import org.apache.aut.vfs.FileSystemManager;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
-import org.apache.avalon.framework.context.Context;
import org.apache.myrmidon.api.TaskContext;
-import org.apache.aut.converter.AbstractConverter;
-import org.apache.aut.converter.ConverterException;
/**
* Converts a String to a [EMAIL PROTECTED] FileObject}
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/FileSetAdaptor.java
Index: FileSetAdaptor.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.antlib.vfile;
import org.apache.aut.vfs.FileObject;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
/**
* An adaptor from a [EMAIL PROTECTED] FileSet} to a [EMAIL PROTECTED]
FileList}.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
* @version $Revision: 1.1 $ $Date: 2002/02/25 11:09:09 $
*/
public class FileSetAdaptor
implements FileList
{
private final FileSet m_fileset;
public FileSetAdaptor( final FileSet fileset )
{
m_fileset = fileset;
}
/**
* Returns the files in the list.
*/
public FileObject[] listFiles( TaskContext context )
throws TaskException
{
final FileSetResult result = m_fileset.getResult( context );
return result.getFiles();
}
}
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/FileSetToFileListConverter.java
Index: FileSetToFileListConverter.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.antlib.vfile;
import org.apache.aut.converter.AbstractConverter;
import org.apache.aut.converter.ConverterException;
import org.apache.myrmidon.api.TaskContext;
/**
* A converter from [EMAIL PROTECTED] FileSet} to [EMAIL PROTECTED] FileList}.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
* @version $Revision: 1.1 $ $Date: 2002/02/25 11:09:09 $
*
* @ant:converter source="org.apache.antlib.vfile.FileSet"
* destination="org.apache.antlib.vfile.FileList"
*/
public class FileSetToFileListConverter
extends AbstractConverter
{
public FileSetToFileListConverter()
{
super( FileSet.class, FileList.class );
}
/**
* Do the conversion.
*/
protected Object convert( final Object original, final Object context )
throws ConverterException
{
final TaskContext taskContext = (TaskContext)context;
final FileSet src = (FileSet)original;
return new FileSetAdaptor( src );
}
}
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/ListFilesTask.java
Index: ListFilesTask.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.antlib.vfile;
import org.apache.aut.vfs.FileObject;
import org.apache.myrmidon.api.AbstractTask;
import org.apache.myrmidon.api.TaskException;
/**
* A debug task, which prints out the files in a file list.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
* @version $Revision: 1.1 $ $Date: 2002/02/25 11:09:09 $
*
* @ant:task name="v-list-files"
*/
public class ListFilesTask
extends AbstractTask
{
private final DefaultFileList m_files = new DefaultFileList();
public void add( final FileList files )
{
m_files.add( files );
}
/**
* Execute task.
*
* @exception TaskException if an error occurs
*/
public void execute()
throws TaskException
{
final FileObject[] files = m_files.listFiles( getContext() );
for( int i = 0; i < files.length; i++ )
{
FileObject file = files[i ];
getLogger().info( file.toString() );
}
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>