diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/AbstractAvailableCondition.java b/proposal/myrmidon/src/java/org/apache/antlib/core/AbstractAvailableCondition.java
index 7534f668a..a7713a692 100644
--- a/proposal/myrmidon/src/java/org/apache/antlib/core/AbstractAvailableCondition.java
+++ b/proposal/myrmidon/src/java/org/apache/antlib/core/AbstractAvailableCondition.java
@@ -7,12 +7,13 @@
*/
package org.apache.antlib.core;
-import org.apache.myrmidon.framework.conditions.Condition;
+import java.net.URL;
+import java.net.URLClassLoader;
+import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
+import org.apache.myrmidon.framework.conditions.Condition;
import org.apache.tools.todo.types.Path;
import org.apache.tools.todo.types.PathUtil;
-import java.net.URL;
-import java.net.URLClassLoader;
/**
* An abstract condition which checks for the availability of a particular
@@ -38,9 +39,9 @@ public abstract class AbstractAvailableCondition
/**
* Builds the ClassLoader to use to check resources.
*/
- protected ClassLoader buildClassLoader() throws TaskException
+ protected ClassLoader buildClassLoader( final TaskContext context ) throws TaskException
{
- final URL[] urls = PathUtil.toURLs( m_classpath );
+ final URL[] urls = PathUtil.toURLs( m_classpath, context );
final ClassLoader classLoader;
if( urls.length > 0 )
{
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/ClassAvailableCondition.java b/proposal/myrmidon/src/java/org/apache/antlib/core/ClassAvailableCondition.java
index a1875a6c9..fcf4f3d6d 100644
--- a/proposal/myrmidon/src/java/org/apache/antlib/core/ClassAvailableCondition.java
+++ b/proposal/myrmidon/src/java/org/apache/antlib/core/ClassAvailableCondition.java
@@ -47,7 +47,7 @@ public class ClassAvailableCondition
}
// Build the classloader to use to check resources
- final ClassLoader classLoader = buildClassLoader();
+ final ClassLoader classLoader = buildClassLoader( context );
// Do the check
try
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/ResourceAvailableCondition.java b/proposal/myrmidon/src/java/org/apache/antlib/core/ResourceAvailableCondition.java
index a0af0ca20..a704c933b 100644
--- a/proposal/myrmidon/src/java/org/apache/antlib/core/ResourceAvailableCondition.java
+++ b/proposal/myrmidon/src/java/org/apache/antlib/core/ResourceAvailableCondition.java
@@ -49,7 +49,7 @@ public class ResourceAvailableCondition
}
// Check whether the resource is available
- final ClassLoader classLoader = buildClassLoader();
+ final ClassLoader classLoader = buildClassLoader( context );
final InputStream instr = classLoader.getResourceAsStream( m_resource );
if( instr != null )
{
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/xml/XMLValidateTask.java b/proposal/myrmidon/src/java/org/apache/antlib/xml/XMLValidateTask.java
index 3aba08955..d41ae494c 100644
--- a/proposal/myrmidon/src/java/org/apache/antlib/xml/XMLValidateTask.java
+++ b/proposal/myrmidon/src/java/org/apache/antlib/xml/XMLValidateTask.java
@@ -330,7 +330,7 @@ public class XMLValidateTask
Class readerClass = null;
if( m_classpath != null )
{
- final URL[] urls = PathUtil.toURLs( m_classpath );
+ final URL[] urls = PathUtil.toURLs( m_classpath, getContext() );
final ClassLoader classLoader = new URLClassLoader( urls );
readerClass = classLoader.loadClass( m_readerClassName );
}
diff --git a/proposal/myrmidon/src/manifest/ant1-ant-descriptor.xml b/proposal/myrmidon/src/manifest/ant1-ant-descriptor.xml
index e5b5a9194..120d447e6 100644
--- a/proposal/myrmidon/src/manifest/ant1-ant-descriptor.xml
+++ b/proposal/myrmidon/src/manifest/ant1-ant-descriptor.xml
@@ -4,9 +4,12 @@
@@ -642,7 +642,7 @@ public class JUnitTask extends AbstractTask
{
getContext().debug( "Using System properties " + System.getProperties() );
ClassLoader classLoader = null;
- final URL[] urls = PathUtil.toURLs( classPath );
+ final URL[] urls = PathUtil.toURLs( classPath, getContext() );
if( urls.length > 0 )
{
classLoader = new URLClassLoader( urls );
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MAudit.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MAudit.java
index 93b246dae..d0ad8981c 100644
--- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MAudit.java
+++ b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MAudit.java
@@ -129,7 +129,7 @@ public class MAudit
// don't forget to modify the pattern if you change the options reporting
classpath.addPath( getClassPath() );
- final String formattedClasspath = PathUtil.formatPath( classpath );
+ final String formattedClasspath = PathUtil.formatPath( classpath, getContext() );
if( formattedClasspath.length() > 0 )
{
options.add( "-classpath" );
@@ -162,7 +162,7 @@ public class MAudit
if( m_unused )
{
options.add( "-unused" );
- options.add( PathUtil.formatPath( m_searchPath ) );
+ options.add( PathUtil.formatPath( m_searchPath, getContext() ) );
}
addAllArrayList( options, getIncludedFiles().keySet().iterator() );
return options;
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MMetrics.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MMetrics.java
index 6979e0a6e..2e29ac6fd 100644
--- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MMetrics.java
+++ b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MMetrics.java
@@ -132,7 +132,7 @@ public class MMetrics extends AbstractMetamataTask
// don't forget to modify the pattern if you change the options reporting
classpath.addPath( getClassPath() );
- final String formattedClasspath = PathUtil.formatPath( classpath );
+ final String formattedClasspath = PathUtil.formatPath( classpath, getContext() );
if( formattedClasspath.length() > 0 )
{
options.add( "-classpath" );
@@ -157,7 +157,7 @@ public class MMetrics extends AbstractMetamataTask
options.add( "/" );
// directories
- final String[] dirs = path.list();
+ final String[] dirs = path.listFiles( getContext() );
for( int i = 0; i < dirs.length; i++ )
{
options.add( dirs[ i ] );
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MParse.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MParse.java
index 2952d3671..74309ce7b 100644
--- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MParse.java
+++ b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MParse.java
@@ -235,15 +235,17 @@ public class MParse
{
options.add( "-dp" );
}
- if( ! m_classpath.isEmpty() )
+ final String[] classpath = m_classpath.listFiles( getContext() );
+ if( classpath.length > 0 )
{
options.add( "-classpath" );
- options.add( PathUtil.formatPath( m_classpath ) );
+ options.add( PathUtil.formatPath( classpath ) );
}
- if( ! m_sourcepath.isEmpty() )
+ final String[] sourcepath = m_sourcepath.listFiles( getContext() );
+ if( sourcepath.length > 0 )
{
options.add( "-sourcepath" );
- options.add( PathUtil.formatPath( m_sourcepath ) );
+ options.add( PathUtil.formatPath( sourcepath ) );
}
options.add( m_target.getAbsolutePath() );
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/rmic/DefaultRmicAdapter.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/rmic/DefaultRmicAdapter.java
index ab1fbbb61..95d296022 100644
--- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/rmic/DefaultRmicAdapter.java
+++ b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/rmic/DefaultRmicAdapter.java
@@ -120,11 +120,11 @@ public abstract class DefaultRmicAdapter
if( attributes.getExtdirs() != null )
{
cmd.addArgument( "-extdirs" );
- cmd.addArgument( PathUtil.formatPath( attributes.getExtdirs() ) );
+ cmd.addArgument( PathUtil.formatPath( attributes.getExtdirs(), getTaskContext() ) );
}
cmd.addArgument( "-classpath" );
- cmd.addArgument( PathUtil.formatPath( classpath ) );
+ cmd.addArgument( PathUtil.formatPath( classpath, getTaskContext() ) );
String stubVersion = attributes.getStubVersion();
if( null != stubVersion )
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/rmic/Rmic.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/rmic/Rmic.java
index 46f28cbf5..6cf07b962 100644
--- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/rmic/Rmic.java
+++ b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/rmic/Rmic.java
@@ -15,8 +15,6 @@ import java.rmi.Remote;
import java.util.ArrayList;
import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.api.AbstractTask;
-import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.framework.FileNameMapper;
import org.apache.tools.todo.taskdefs.MatchingTask;
import org.apache.tools.todo.types.DirectoryScanner;
@@ -487,7 +485,7 @@ public class Rmic extends MatchingTask
adapter.setRmic( this );
Path classpath = adapter.getClasspath();
- final URL[] urls = PathUtil.toURLs( classpath );
+ final URL[] urls = PathUtil.toURLs( classpath, getContext() );
loader = new URLClassLoader( urls );
// scan base dirs to build up compile lists only if a
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/sitraka/CovReport.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/sitraka/CovReport.java
index cf9b8a896..0e2307282 100644
--- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/sitraka/CovReport.java
+++ b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/sitraka/CovReport.java
@@ -17,10 +17,8 @@ import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
-import org.apache.aut.nativelib.ExecManager;
import org.apache.myrmidon.api.AbstractTask;
import org.apache.myrmidon.api.TaskException;
-import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.framework.Execute;
import org.apache.tools.todo.types.Commandline;
import org.apache.tools.todo.types.EnumeratedAttribute;
@@ -392,7 +390,7 @@ public class CovReport
throw new TaskException( "Need a 'classpath' element." );
}
// and a valid one...
- String[] paths = classPath.list();
+ String[] paths = classPath.listFiles();
if( paths.length == 0 )
{
throw new TaskException( "Coverage path is invalid. It does not contain any existing path." );
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/sitraka/Coverage.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/sitraka/Coverage.java
index 345a7bf75..15963e1eb 100644
--- a/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/sitraka/Coverage.java
+++ b/proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/sitraka/Coverage.java
@@ -304,10 +304,11 @@ public class Coverage
params.addArguments( m_vmArgs );
// classpath
- if( ! m_classpath.isEmpty() )
+ final String[] classpath = m_classpath.listFiles();
+ if( classpath.length > 0 )
{
params.addArgument( "-classpath" );
- params.addArgument( PathUtil.formatPath( m_classpath ) );
+ params.addArgument( PathUtil.formatPath( classpath ) );
}
// classname (runner or standalone)
if( m_className != null )
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/types/Argument.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/Argument.java
index f792437bf..05d15e9e5 100644
--- a/proposal/myrmidon/src/todo/org/apache/tools/todo/types/Argument.java
+++ b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/Argument.java
@@ -62,7 +62,8 @@ public class Argument
*/
public void setPath( final Path value ) throws TaskException
{
- m_parts = new String[]{ PathUtil.formatPath( value ) };
+ throw new TaskException( "Using a path not implemented." );
+ //m_parts = new String[]{ PathUtil.formatPath( value ) };
}
/**
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/types/ArrayFileList.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/ArrayFileList.java
new file mode 100644
index 000000000..3e49118d8
--- /dev/null
+++ b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/ArrayFileList.java
@@ -0,0 +1,39 @@
+/*
+ * 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.tools.todo.types;
+
+import org.apache.myrmidon.api.TaskContext;
+import org.apache.myrmidon.api.TaskException;
+
+/**
+ * A PathElement made up of an array of strings.
+ *
+ * @author Adam Murdoch
+ * @version $Revision$ $Date$
+ */
+class ArrayFileList
+ implements FileList
+{
+ private final String[] m_parts;
+
+ public ArrayFileList( final String part )
+ {
+ m_parts = new String[] { part } ;
+ }
+
+ public ArrayFileList( final String[] parts )
+ {
+ m_parts = parts;
+ }
+
+ public String[] listFiles( final TaskContext context )
+ throws TaskException
+ {
+ return m_parts;
+ }
+}
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/types/EnvironmentVariable.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/EnvironmentVariable.java
index 1c823372a..2c5fbbccb 100644
--- a/proposal/myrmidon/src/todo/org/apache/tools/todo/types/EnvironmentVariable.java
+++ b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/EnvironmentVariable.java
@@ -27,7 +27,8 @@ public class EnvironmentVariable
public void setPath( final Path path ) throws TaskException
{
- m_value = PathUtil.formatPath( path );
+ throw new TaskException( "Using a path not implemented." );
+ //m_value = PathUtil.formatPath( path );
}
public void setValue( final String value )
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/types/FileList.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/FileList.java
index 9b762e5ab..880298d84 100644
--- a/proposal/myrmidon/src/todo/org/apache/tools/todo/types/FileList.java
+++ b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/FileList.java
@@ -7,67 +7,23 @@
*/
package org.apache.tools.todo.types;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.StringTokenizer;
+import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
/**
- * FileList represents an explicitly named list of files. FileLists are useful
- * when you want to capture a list of files regardless of whether they currently
- * exist. By contrast, FileSet operates as a filter, only returning the name of
- * a matched file if it currently exists in the file system.
+ * A list of files.
*
- * @author Craeg Strong
+ * @author Adam Murdoch
* @version $Revision$ $Date$
*/
-public class FileList
+public interface FileList
{
- private final ArrayList m_filenames = new ArrayList();
- private File m_dir;
-
- public FileList()
- {
- }
-
- public void setDir( File dir )
- {
- m_dir = dir;
- }
-
- public void setFiles( String filenames )
- {
- if( filenames != null && filenames.length() > 0 )
- {
- StringTokenizer tok = new StringTokenizer( filenames, ", \t\n\r\f", false );
- while( tok.hasMoreTokens() )
- {
- m_filenames.add( tok.nextToken() );
- }
- }
- }
-
- public File getDir()
- {
- return m_dir;
- }
-
/**
- * Returns the list of files represented by this FileList.
+ * Returns the files in this list.
+ *
+ * @param context the context to use to evaluate the list.
+ * @return The names of the files in this list. All names are absolute paths.
*/
- public String[] getFiles()
- throws TaskException
- {
- if( m_dir == null )
- {
- throw new TaskException( "No directory specified for filelist." );
- }
-
- if( m_filenames.size() == 0 )
- {
- throw new TaskException( "No files specified for filelist." );
- }
-
- return (String[])m_filenames.toArray( new String[ m_filenames.size() ] );
- }
+ public String[] listFiles( TaskContext context )
+ throws TaskException;
}
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/types/ParsedPathElement.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/ParsedPathElement.java
new file mode 100644
index 000000000..bc37979fa
--- /dev/null
+++ b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/ParsedPathElement.java
@@ -0,0 +1,35 @@
+/*
+ * 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.tools.todo.types;
+
+import org.apache.myrmidon.api.TaskContext;
+import org.apache.myrmidon.api.TaskException;
+import org.apache.tools.todo.util.FileUtils;
+
+/**
+ * A PathElement that is parsed from a string.
+ *
+ * @author Adam Murdoch
+ * @version $Revision$ $Date$
+ */
+class ParsedPathElement
+ implements FileList
+{
+ private final String m_path;
+
+ public ParsedPathElement( final String path )
+ {
+ m_path = path;
+ }
+
+ public String[] listFiles( final TaskContext context )
+ throws TaskException
+ {
+ return FileUtils.translatePath( context.getBaseDirectory(), m_path );
+ }
+}
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/types/Path.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/Path.java
index 6c53c641f..eb09c6ba3 100644
--- a/proposal/myrmidon/src/todo/org/apache/tools/todo/types/Path.java
+++ b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/Path.java
@@ -9,11 +9,10 @@ package org.apache.tools.todo.types;
import java.io.File;
import java.util.ArrayList;
+import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.DataType;
import org.apache.tools.todo.util.FileUtils;
-import org.apache.tools.todo.types.DirectoryScanner;
-import org.apache.tools.todo.types.FileSet;
/**
* This object represents a path as used by CLASSPATH or PATH environment
@@ -45,12 +44,13 @@ import org.apache.tools.todo.types.FileSet;
*
* @author Thomas.Haas@softwired-inc.com
* @author Stefan Bodewig
+ *
+ * @ant:data-type name="path"
*/
public class Path
- implements DataType
+ implements DataType, FileList
{
private final ArrayList m_elements = new ArrayList();
- private File m_baseDirectory;
public Path( final String path )
{
@@ -72,14 +72,6 @@ public class Path
}
}
- /**
- * Sets the base directory for this path.
- */
- public void setBaseDirectory( final File baseDir )
- {
- m_baseDirectory = baseDir;
- }
-
/**
* Adds an element to the path.
*/
@@ -96,9 +88,8 @@ public class Path
*/
public void addLocation( final File location )
{
- final PathElement pathElement = new PathElement();
+ final FileList pathElement = new ArrayFileList( location.getAbsolutePath() );
m_elements.add( pathElement );
- pathElement.setLocation( location );
}
/**
@@ -122,9 +113,17 @@ public class Path
*/
public void addPath( final String path )
{
- final PathElement pathElement = new PathElement();
+ final FileList pathElement = new ParsedPathElement( path );
+ m_elements.add( pathElement );
+ }
+
+ /**
+ * Adds a path.
+ */
+ public void addPath( final String[] path )
+ {
+ final FileList pathElement = new ArrayFileList( path );
m_elements.add( pathElement );
- pathElement.setPath( path );
}
/**
@@ -139,35 +138,17 @@ public class Path
* Returns all path elements defined by this and nested path objects.
* The paths returned by this method are absolute.
*/
- public String[] list()
+ public String[] listFiles( final TaskContext context )
throws TaskException
{
ArrayList result = new ArrayList( 2 * m_elements.size() );
for( int i = 0; i < m_elements.size(); i++ )
{
Object o = m_elements.get( i );
- if( o instanceof String )
- {
- // obtained via append
- addUnlessPresent( result, (String)o );
- }
- else if( o instanceof PathElement )
+ if( o instanceof FileList )
{
- final PathElement element = (PathElement)o;
- final String[] parts = element.getParts( m_baseDirectory );
- if( parts == null )
- {
- throw new NullPointerException( "You must either set location or path on <>
values.
- */
-class PathElement
-{
- private String m_location;
- private String m_path;
-
- public void setLocation( final File location )
- {
- m_location = location.getAbsolutePath();
- }
-
- public void setPath( final String path )
- {
- m_path = path;
- }
-
- protected String[] getParts( final File baseDirectory )
- throws TaskException
- {
- if( m_location != null )
- {
- return new String[]{m_location};
- }
- return FileUtils.translatePath( baseDirectory, m_path );
- }
-}
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/types/PathUtil.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/PathUtil.java
index 87a293568..2495d12cf 100644
--- a/proposal/myrmidon/src/todo/org/apache/tools/todo/types/PathUtil.java
+++ b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/PathUtil.java
@@ -11,9 +11,8 @@ import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Locale;
+import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
-import org.apache.tools.todo.types.FileSet;
-import org.apache.tools.todo.types.Path;
/**
* Utilities for operating on Path objects.
@@ -26,37 +25,44 @@ public class PathUtil
/**
* Formats a Path into its native representation.
*/
- public static String formatPath( final Path path )
- throws TaskException
+ public static String formatPath( final String[] path )
{
- final String[] list = path.list();
-
// empty path return empty string
- if( list.length == 0 )
+ if( path.length == 0 )
{
return "";
}
// path containing one or more elements
- final StringBuffer result = new StringBuffer( list[ 0 ].toString() );
- for( int i = 1; i < list.length; i++ )
+ final StringBuffer result = new StringBuffer( path[ 0 ].toString() );
+ for( int i = 1; i < path.length; i++ )
{
result.append( File.pathSeparatorChar );
- result.append( list[ i ] );
+ result.append( path[ i ] );
}
return result.toString();
}
+ /**
+ * Formats a Path into its native representation.
+ */
+ public static String formatPath( final Path path, final TaskContext context )
+ throws TaskException
+ {
+ final String[] list = path.listFiles( context );
+ return formatPath( list );
+ }
+
/**
* Returns an array of URLs - useful for building a ClassLoader.
*/
- public static URL[] toURLs( final Path path )
+ public static URL[] toURLs( final Path path, final TaskContext context )
throws TaskException
{
try
{
- final String[] list = path.list();
+ final String[] list = path.listFiles( context );
final URL[] result = new URL[ list.length ];
@@ -126,10 +132,10 @@ public class PathUtil
/**
* Adds the contents of a set of directories to a path.
*/
- public static void addExtdirs( final Path toPath, final Path extDirs )
+ public static void addExtdirs( final Path toPath, final Path extDirs, TaskContext context )
throws TaskException
{
- final String[] dirs = extDirs.list();
+ final String[] dirs = extDirs.listFiles( context );
for( int i = 0; i < dirs.length; i++ )
{
final File dir = new File( dirs[ i ] );
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/types/SimpleFileList.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/SimpleFileList.java
new file mode 100644
index 000000000..cf996add3
--- /dev/null
+++ b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/SimpleFileList.java
@@ -0,0 +1,73 @@
+/*
+ * 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.tools.todo.types;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+import org.apache.myrmidon.api.TaskException;
+
+/**
+ * FileList represents an explicitly named list of files. FileLists are useful
+ * when you want to capture a list of files regardless of whether they currently
+ * exist. By contrast, FileSet operates as a filter, only returning the name of
+ * a matched file if it currently exists in the file system.
+ *
+ * @author Craeg Strong
+ * @version $Revision$ $Date$
+ */
+public class SimpleFileList
+{
+ private final ArrayList m_filenames = new ArrayList();
+ private File m_dir;
+
+ public SimpleFileList()
+ {
+ }
+
+ public void setDir( File dir )
+ {
+ m_dir = dir;
+ }
+
+ public void setFiles( String filenames )
+ {
+ if( filenames != null && filenames.length() > 0 )
+ {
+ StringTokenizer tok = new StringTokenizer( filenames, ", \t\n\r\f", false );
+ while( tok.hasMoreTokens() )
+ {
+ m_filenames.add( tok.nextToken() );
+ }
+ }
+ }
+
+ public File getDir()
+ {
+ return m_dir;
+ }
+
+ /**
+ * Returns the list of files represented by this FileList.
+ */
+ public String[] getFiles()
+ throws TaskException
+ {
+ if( m_dir == null )
+ {
+ throw new TaskException( "No directory specified for filelist." );
+ }
+
+ if( m_filenames.size() == 0 )
+ {
+ throw new TaskException( "No files specified for filelist." );
+ }
+
+ return (String[])m_filenames.toArray( new String[ m_filenames.size() ] );
+ }
+}
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/todo/types/converters/FileListToStringConverter.java b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/converters/FileListToStringConverter.java
new file mode 100644
index 000000000..90642b9cc
--- /dev/null
+++ b/proposal/myrmidon/src/todo/org/apache/tools/todo/types/converters/FileListToStringConverter.java
@@ -0,0 +1,48 @@
+/*
+ * 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.tools.todo.types.converters;
+
+import org.apache.aut.converter.AbstractConverter;
+import org.apache.aut.converter.ConverterException;
+import org.apache.myrmidon.api.TaskContext;
+import org.apache.myrmidon.api.TaskException;
+import org.apache.tools.todo.types.FileList;
+import org.apache.tools.todo.types.PathUtil;
+
+/**
+ * Converters from FileList to String.
+ *
+ * @author Adam Murdoch
+ * @version $Revision$ $Date$
+ *
+ * @ant:converter source="org.apache.tools.todo.types.FileList" destination="java.lang.String"
+ */
+public class FileListToStringConverter
+ extends AbstractConverter
+{
+ public FileListToStringConverter()
+ {
+ super( FileList.class, String.class );
+ }
+
+ protected Object convert( final Object original, final Object context )
+ throws ConverterException
+ {
+ try
+ {
+ final TaskContext taskContext = (TaskContext)context;
+ final FileList fileList = (FileList)original;
+ final String[] files = fileList.listFiles( taskContext );
+ return PathUtil.formatPath( files );
+ }
+ catch( final TaskException e )
+ {
+ throw new ConverterException( e.getMessage(), e );
+ }
+ }
+}