donaldp 02/01/12 20:45:01
Modified: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs
Javac.java Rmic.java Tar.java UpToDate.java
Zip.java
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec
ExecuteOn.java
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file
Copy.java
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic
DefaultRmicAdapter.java RmicAdapter.java
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/text
ExtMapper.java Native2Ascii.java
proposal/myrmidon/src/main/org/apache/tools/ant/types
Mapper.java SourceFileScanner.java
Added: proposal/myrmidon/src/main/org/apache/tools/ant/util/mappers
FileNameMapper.java FlatFileNameMapper.java
GlobPatternMapper.java IdentityMapper.java
MergingMapper.java RegexpPatternMapper.java
Removed: proposal/myrmidon/src/main/org/apache/tools/ant/util
FileNameMapper.java FlatFileNameMapper.java
GlobPatternMapper.java IdentityMapper.java
MergingMapper.java RegexpPatternMapper.java
Log:
Move mappers into their own package
Revision Changes Path
1.23 +1 -1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java
Index: Javac.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- Javac.java 13 Jan 2002 00:00:15 -0000 1.22
+++ Javac.java 13 Jan 2002 04:45:00 -0000 1.23
@@ -18,7 +18,7 @@
import org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory;
import org.apache.tools.ant.types.Argument;
import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.util.GlobPatternMapper;
+import org.apache.tools.ant.util.mappers.GlobPatternMapper;
import org.apache.tools.ant.types.SourceFileScanner;
/**
1.21 +1 -1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Rmic.java
Index: Rmic.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Rmic.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- Rmic.java 13 Jan 2002 00:00:15 -0000 1.20
+++ Rmic.java 13 Jan 2002 04:45:00 -0000 1.21
@@ -18,7 +18,7 @@
import org.apache.tools.ant.taskdefs.rmic.RmicAdapter;
import org.apache.tools.ant.taskdefs.rmic.RmicAdapterFactory;
import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.util.FileNameMapper;
+import org.apache.tools.ant.util.mappers.FileNameMapper;
import org.apache.tools.ant.types.SourceFileScanner;
/**
1.15 +1 -1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tar.java
Index: Tar.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Tar.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- Tar.java 13 Jan 2002 00:00:15 -0000 1.14
+++ Tar.java 13 Jan 2002 04:45:00 -0000 1.15
@@ -17,7 +17,7 @@
import org.apache.tools.ant.types.DirectoryScanner;
import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.FileSet;
-import org.apache.tools.ant.util.MergingMapper;
+import org.apache.tools.ant.util.mappers.MergingMapper;
import org.apache.tools.ant.types.SourceFileScanner;
import org.apache.tools.tar.TarConstants;
import org.apache.tools.tar.TarEntry;
1.15 +2 -2 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/UpToDate.java
Index: UpToDate.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/UpToDate.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- UpToDate.java 12 Jan 2002 23:58:55 -0000 1.14
+++ UpToDate.java 13 Jan 2002 04:45:00 -0000 1.15
@@ -15,8 +15,8 @@
import org.apache.tools.ant.taskdefs.condition.Condition;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.Mapper;
-import org.apache.tools.ant.util.FileNameMapper;
-import org.apache.tools.ant.util.MergingMapper;
+import org.apache.tools.ant.util.mappers.FileNameMapper;
+import org.apache.tools.ant.util.mappers.MergingMapper;
import org.apache.tools.ant.types.SourceFileScanner;
/**
1.14 +1 -1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Zip.java
Index: Zip.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Zip.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Zip.java 13 Jan 2002 00:00:15 -0000 1.13
+++ Zip.java 13 Jan 2002 04:45:00 -0000 1.14
@@ -27,7 +27,7 @@
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.ZipFileSet;
import org.apache.tools.ant.types.ZipScanner;
-import org.apache.tools.ant.util.MergingMapper;
+import org.apache.tools.ant.util.mappers.MergingMapper;
import org.apache.tools.ant.types.SourceFileScanner;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipOutputStream;
1.2 +1 -1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecuteOn.java
Index: ExecuteOn.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/exec/ExecuteOn.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ExecuteOn.java 12 Jan 2002 23:39:01 -0000 1.1
+++ ExecuteOn.java 13 Jan 2002 04:45:01 -0000 1.2
@@ -18,7 +18,7 @@
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.Mapper;
import org.apache.tools.ant.types.Marker;
-import org.apache.tools.ant.util.FileNameMapper;
+import org.apache.tools.ant.util.mappers.FileNameMapper;
import org.apache.tools.ant.types.SourceFileScanner;
import org.apache.avalon.excalibur.util.StringUtil;
1.13 +3 -3 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Copy.java
Index: Copy.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/file/Copy.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Copy.java 12 Jan 2002 23:50:01 -0000 1.12
+++ Copy.java 13 Jan 2002 04:45:01 -0000 1.13
@@ -21,10 +21,10 @@
import org.apache.tools.ant.types.FilterSet;
import org.apache.tools.ant.types.FilterSetCollection;
import org.apache.tools.ant.types.Mapper;
-import org.apache.tools.ant.util.FileNameMapper;
+import org.apache.tools.ant.util.mappers.FileNameMapper;
import org.apache.tools.ant.util.FileUtils;
-import org.apache.tools.ant.util.FlatFileNameMapper;
-import org.apache.tools.ant.util.IdentityMapper;
+import org.apache.tools.ant.util.mappers.FlatFileNameMapper;
+import org.apache.tools.ant.util.mappers.IdentityMapper;
import org.apache.tools.ant.types.SourceFileScanner;
/**
1.10 +1 -1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
Index: DefaultRmicAdapter.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- DefaultRmicAdapter.java 30 Dec 2001 01:14:59 -0000 1.9
+++ DefaultRmicAdapter.java 13 Jan 2002 04:45:01 -0000 1.10
@@ -15,7 +15,7 @@
import org.apache.tools.ant.taskdefs.Rmic;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.util.FileNameMapper;
+import org.apache.tools.ant.util.mappers.FileNameMapper;
/**
* This is the default implementation for the RmicAdapter interface. Currently,
1.5 +1 -1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapter.java
Index: RmicAdapter.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- RmicAdapter.java 23 Dec 2001 06:34:24 -0000 1.4
+++ RmicAdapter.java 13 Jan 2002 04:45:01 -0000 1.5
@@ -10,7 +10,7 @@
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.taskdefs.Rmic;
import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.util.FileNameMapper;
+import org.apache.tools.ant.util.mappers.FileNameMapper;
/**
* The interface that all rmic adapters must adher to. <p>
1.2 +1 -1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/text/ExtMapper.java
Index: ExtMapper.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/text/ExtMapper.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ExtMapper.java 13 Jan 2002 00:19:43 -0000 1.1
+++ ExtMapper.java 13 Jan 2002 04:45:01 -0000 1.2
@@ -7,7 +7,7 @@
*/
package org.apache.tools.ant.taskdefs.text;
-import org.apache.tools.ant.util.FileNameMapper;
+import org.apache.tools.ant.util.mappers.FileNameMapper;
class ExtMapper
implements FileNameMapper
1.2 +2 -2 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/text/Native2Ascii.java
Index: Native2Ascii.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/text/Native2Ascii.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Native2Ascii.java 13 Jan 2002 00:19:43 -0000 1.1
+++ Native2Ascii.java 13 Jan 2002 04:45:01 -0000 1.2
@@ -14,8 +14,8 @@
import org.apache.tools.ant.types.DirectoryScanner;
import org.apache.tools.ant.types.Mapper;
import org.apache.tools.ant.types.SourceFileScanner;
-import org.apache.tools.ant.util.FileNameMapper;
-import org.apache.tools.ant.util.IdentityMapper;
+import org.apache.tools.ant.util.mappers.FileNameMapper;
+import org.apache.tools.ant.util.mappers.IdentityMapper;
/**
* Convert files from native encodings to ascii.
1.9 +1 -1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Mapper.java
Index: Mapper.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Mapper.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Mapper.java 4 Jan 2002 09:26:42 -0000 1.8
+++ Mapper.java 13 Jan 2002 04:45:01 -0000 1.9
@@ -11,7 +11,7 @@
import java.net.URLClassLoader;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.ProjectComponent;
-import org.apache.tools.ant.util.FileNameMapper;
+import org.apache.tools.ant.util.mappers.FileNameMapper;
/**
* Element to define a FileNameMapper.
1.2 +1 -1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/SourceFileScanner.java
Index: SourceFileScanner.java
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/SourceFileScanner.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SourceFileScanner.java 12 Jan 2002 23:49:29 -0000 1.1
+++ SourceFileScanner.java 13 Jan 2002 04:45:01 -0000 1.2
@@ -14,7 +14,7 @@
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.Task;
-import org.apache.tools.ant.util.FileNameMapper;
+import org.apache.tools.ant.util.mappers.FileNameMapper;
/**
* Utility class that collects the functionality of the various scanDir methods
1.1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/mappers/FileNameMapper.java
Index: FileNameMapper.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.tools.ant.util.mappers;
import org.apache.myrmidon.api.TaskException;
/**
* Interface to be used by SourceFileScanner. <p>
*
* Used to find the name of the target file(s) corresponding to a source file.
* </p> <p>
*
* The rule by which the file names are transformed is specified via the setFrom
* and setTo methods. The exact meaning of these is implementation dependent.
* </p>
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
*/
public interface FileNameMapper
{
/**
* Sets the from part of the transformation rule.
*
* @param from The new From value
*/
void setFrom( String from )
throws TaskException;
/**
* Sets the to part of the transformation rule.
*
* @param to The new To value
*/
void setTo( String to );
/**
* Returns an array containing the target filename(s) for the given source
* file. <p>
*
* if the given rule doesn't apply to the source file, implementation must
* return null. SourceFileScanner will then omit the source file in
* question.</p>
*
* @param sourceFileName the name of the source file relative to some given
* basedirectory.
* @return Description of the Returned Value
*/
String[] mapFileName( String sourceFileName )
throws TaskException;
}
1.1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/mappers/FlatFileNameMapper.java
Index: FlatFileNameMapper.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.tools.ant.util.mappers;
import java.io.File;
/**
* Implementation of FileNameMapper that always returns the source file name
* without any leading directory information. <p>
*
* This is the default FileNameMapper for the copy and move tasks if the flatten
* attribute has been set.</p>
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
*/
public class FlatFileNameMapper
implements FileNameMapper
{
/**
* Ignored.
*/
public void setFrom( final String from )
{
}
/**
* Ignored.
*/
public void setTo( final String to )
{
}
/**
* Returns an one-element array containing the source file name without any
* leading directory information.
*
* @param sourceFileName Description of Parameter
* @return Description of the Returned Value
*/
public String[] mapFileName( final String sourceFileName )
{
return new String[]{new File( sourceFileName ).getName()};
}
}
1.1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/mappers/GlobPatternMapper.java
Index: GlobPatternMapper.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.tools.ant.util.mappers;
/**
* Implementation of FileNameMapper that does simple wildcard pattern
* replacements. <p>
*
* This does simple translations like *.foo -> *.bar where the prefix to .foo
* will be left unchanged. It only handles a single * character, use regular
* expressions for more complicated situations.</p> <p>
*
* This is one of the more useful Mappers, it is used by javac for example.</p>
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
*/
public class GlobPatternMapper
implements FileNameMapper
{
/**
* Part of "from" pattern before the *.
*/
private String m_fromPrefix;
/**
* Part of "from" pattern after the *.
*/
private String m_fromPostfix;
/**
* Part of "to" pattern before the *.
*/
private String m_toPrefix;
/**
* Part of "to" pattern after the *.
*/
private String m_toPostfix;
/**
* Length of the postfix ("from" pattern).
*/
private int m_postfixLength;
/**
* Length of the prefix ("from" pattern).
*/
private int m_prefixLength;
/**
* Sets the "from" pattern. Required.
*
* @param from The new From value
*/
public void setFrom( final String from )
{
final int index = from.lastIndexOf( "*" );
if( index == -1 )
{
m_fromPrefix = from;
m_fromPostfix = "";
}
else
{
m_fromPrefix = from.substring( 0, index );
m_fromPostfix = from.substring( index + 1 );
}
m_prefixLength = m_fromPrefix.length();
m_postfixLength = m_fromPostfix.length();
}
/**
* Sets the "to" pattern. Required.
*
* @param to The new To value
*/
public void setTo( final String to )
{
final int index = to.lastIndexOf( "*" );
if( index == -1 )
{
m_toPrefix = to;
m_toPostfix = "";
}
else
{
m_toPrefix = to.substring( 0, index );
m_toPostfix = to.substring( index + 1 );
}
}
/**
* Returns null if the source file name doesn't match the "from"
* pattern, an one-element array containing the translated file otherwise.
*
* @param sourceFileName Description of Parameter
* @return Description of the Returned Value
*/
public String[] mapFileName( final String sourceFileName )
{
if( m_fromPrefix == null ||
!sourceFileName.startsWith( m_fromPrefix ) ||
!sourceFileName.endsWith( m_fromPostfix ) )
{
return null;
}
else
{
final String result = m_toPrefix +
extractVariablePart( sourceFileName ) + m_toPostfix;
return new String[]{result};
}
}
/**
* Returns the part of the given string that matches the * in the
* "from" pattern.
*
* @param name Description of Parameter
* @return Description of the Returned Value
*/
protected String extractVariablePart( final String name )
{
return name.substring( m_prefixLength,
name.length() - m_postfixLength );
}
}
1.1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/mappers/IdentityMapper.java
Index: IdentityMapper.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.tools.ant.util.mappers;
/**
* Implementation of FileNameMapper that always returns the source file name.
* <p>
*
* This is the default FileNameMapper for the copy and move tasks.</p>
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
*/
public class IdentityMapper
implements FileNameMapper
{
/**
* Ignored.
*
* @param from The new From value
*/
public void setFrom( final String from )
{
}
/**
* Ignored.
*
* @param to The new To value
*/
public void setTo( final String to )
{
}
/**
* Returns an one-element array containing the source file name.
*
* @param sourceFileName Description of Parameter
* @return Description of the Returned Value
*/
public String[] mapFileName( final String sourceFileName )
{
return new String[]{sourceFileName};
}
}
1.1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/mappers/MergingMapper.java
Index: MergingMapper.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.tools.ant.util.mappers;
/**
* Implementation of FileNameMapper that always returns the same target file
* name. <p>
*
* This is the default FileNameMapper for the archiving tasks and uptodate.</p>
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
*/
public class MergingMapper
implements FileNameMapper
{
private String[] m_mergedFile;
/**
* Ignored.
*
* @param from The new From value
*/
public void setFrom( String from )
{
}
/**
* Sets the name of the merged file.
*
* @param to The new To value
*/
public void setTo( String to )
{
m_mergedFile = new String[]{to};
}
/**
* Returns an one-element array containing the file name set via setTo.
*
* @param sourceFileName Description of Parameter
* @return Description of the Returned Value
*/
public String[] mapFileName( final String sourceFileName )
{
return m_mergedFile;
}
}
1.1 jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/mappers/RegexpPatternMapper.java
Index: RegexpPatternMapper.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.tools.ant.util.mappers;
import java.util.ArrayList;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.ant.util.regexp.RegexpMatcher;
import org.apache.tools.ant.util.regexp.RegexpMatcherFactory;
/**
* Implementation of FileNameMapper that does regular expression replacements.
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
*/
public class RegexpPatternMapper
implements FileNameMapper
{
private RegexpMatcher m_matcher;
private char[] m_to;
private StringBuffer m_result = new StringBuffer();
public RegexpPatternMapper()
throws TaskException
{
m_matcher = ( new RegexpMatcherFactory() ).newRegexpMatcher();
}
/**
* Sets the "from" pattern. Required.
*/
public void setFrom( final String from )
throws TaskException
{
try
{
m_matcher.setPattern( from );
}
catch( NoClassDefFoundError e )
{
// depending on the implementation the actual RE won't
// get instantiated in the constructor.
throw new TaskException( "Cannot load regular expression matcher", e );
}
}
/**
* Sets the "to" pattern. Required.
*
* @param to The new To value
*/
public void setTo( final String to )
{
m_to = to.toCharArray();
}
/**
* Returns null if the source file name doesn't match the "from"
* pattern, an one-element array containing the translated file otherwise.
*
* @param sourceFileName Description of Parameter
* @return Description of the Returned Value
*/
public String[] mapFileName( final String sourceFileName )
throws TaskException
{
if( m_matcher == null || m_to == null ||
!m_matcher.matches( sourceFileName ) )
{
return null;
}
else
{
return new String[]{replaceReferences( sourceFileName )};
}
}
/**
* Replace all backreferences in the to pattern with the matched groups of
* the source.
*/
private String replaceReferences( final String source )
throws TaskException
{
final ArrayList groups = m_matcher.getGroups( source );
m_result.setLength( 0 );
for( int i = 0; i < m_to.length; i++ )
{
if( m_to[ i ] == '\\' )
{
if( ++i < m_to.length )
{
final int value = Character.digit( m_to[ i ], 10 );
if( value > -1 )
{
m_result.append( (String)groups.get( value ) );
}
else
{
m_result.append( m_to[ i ] );
}
}
else
{
// XXX - should throw an exception instead?
m_result.append( '\\' );
}
}
else
{
m_result.append( m_to[ i ] );
}
}
return m_result.toString();
}
}
--
To unsubscribe, e-mail: <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>
|