ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util FileNameMapper.java FlatFileNameMapper.java GlobPatternMapper.java IdentityMapper.java MergingMapper.java RegexpPatternMapper.java
Date Sat, 12 Jan 2002 23:43:49 GMT
donaldp     02/01/12 15:43:49

  Modified:    proposal/myrmidon/src/main/org/apache/tools/ant/util
                        FileNameMapper.java FlatFileNameMapper.java
                        GlobPatternMapper.java IdentityMapper.java
                        MergingMapper.java RegexpPatternMapper.java
  Log:
  Made all the mappers consistent
  
  Revision  Changes    Path
  1.5       +0 -1      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/FileNameMapper.java
  
  Index: FileNameMapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/FileNameMapper.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FileNameMapper.java	23 Dec 2001 06:32:30 -0000	1.4
  +++ FileNameMapper.java	12 Jan 2002 23:43:49 -0000	1.5
  @@ -23,7 +23,6 @@
    */
   public interface FileNameMapper
   {
  -
       /**
        * Sets the from part of the transformation rule.
        *
  
  
  
  1.4       +8 -10     jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/FlatFileNameMapper.java
  
  Index: FlatFileNameMapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/FlatFileNameMapper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FlatFileNameMapper.java	23 Dec 2001 06:32:30 -0000	1.3
  +++ FlatFileNameMapper.java	12 Jan 2002 23:43:49 -0000	1.4
  @@ -7,6 +7,8 @@
    */
   package org.apache.tools.ant.util;
   
  +import java.io.File;
  +
   /**
    * Implementation of FileNameMapper that always returns the source file name
    * without any leading directory information. <p>
  @@ -16,24 +18,20 @@
    *
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
    */
  -public class FlatFileNameMapper implements FileNameMapper
  +public class FlatFileNameMapper
  +    implements FileNameMapper
   {
  -
       /**
        * Ignored.
  -     *
  -     * @param from The new From value
        */
  -    public void setFrom( String from )
  +    public void setFrom( final String from )
       {
       }
   
       /**
        * Ignored.
  -     *
  -     * @param to The new To value
        */
  -    public void setTo( String to )
  +    public void setTo( final String to )
       {
       }
   
  @@ -44,8 +42,8 @@
        * @param sourceFileName Description of Parameter
        * @return Description of the Returned Value
        */
  -    public String[] mapFileName( String sourceFileName )
  +    public String[] mapFileName( final String sourceFileName )
       {
  -        return new String[]{new java.io.File( sourceFileName ).getName()};
  +        return new String[]{new File( sourceFileName ).getName()};
       }
   }
  
  
  
  1.4       +35 -31    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/GlobPatternMapper.java
  
  Index: GlobPatternMapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/GlobPatternMapper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- GlobPatternMapper.java	23 Dec 2001 06:32:30 -0000	1.3
  +++ GlobPatternMapper.java	12 Jan 2002 23:43:49 -0000	1.4
  @@ -19,58 +19,59 @@
    *
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
    */
  -public class GlobPatternMapper implements FileNameMapper
  +public class GlobPatternMapper
  +    implements FileNameMapper
   {
       /**
        * Part of &quot;from&quot; pattern before the *.
        */
  -    protected String fromPrefix = null;
  +    private String m_fromPrefix;
   
       /**
        * Part of &quot;from&quot; pattern after the *.
        */
  -    protected String fromPostfix = null;
  +    private String m_fromPostfix;
   
       /**
        * Part of &quot;to&quot; pattern before the *.
        */
  -    protected String toPrefix = null;
  +    private String m_toPrefix;
   
       /**
        * Part of &quot;to&quot; pattern after the *.
        */
  -    protected String toPostfix = null;
  +    private String m_toPostfix;
   
       /**
        * Length of the postfix (&quot;from&quot; pattern).
        */
  -    protected int postfixLength;
  +    private int m_postfixLength;
   
       /**
        * Length of the prefix (&quot;from&quot; pattern).
        */
  -    protected int prefixLength;
  +    private int m_prefixLength;
   
       /**
        * Sets the &quot;from&quot; pattern. Required.
        *
        * @param from The new From value
        */
  -    public void setFrom( String from )
  +    public void setFrom( final String from )
       {
  -        int index = from.lastIndexOf( "*" );
  +        final int index = from.lastIndexOf( "*" );
           if( index == -1 )
           {
  -            fromPrefix = from;
  -            fromPostfix = "";
  +            m_fromPrefix = from;
  +            m_fromPostfix = "";
           }
           else
           {
  -            fromPrefix = from.substring( 0, index );
  -            fromPostfix = from.substring( index + 1 );
  +            m_fromPrefix = from.substring( 0, index );
  +            m_fromPostfix = from.substring( index + 1 );
           }
  -        prefixLength = fromPrefix.length();
  -        postfixLength = fromPostfix.length();
  +        m_prefixLength = m_fromPrefix.length();
  +        m_postfixLength = m_fromPostfix.length();
       }
   
       /**
  @@ -78,18 +79,18 @@
        *
        * @param to The new To value
        */
  -    public void setTo( String to )
  +    public void setTo( final String to )
       {
  -        int index = to.lastIndexOf( "*" );
  +        final int index = to.lastIndexOf( "*" );
           if( index == -1 )
           {
  -            toPrefix = to;
  -            toPostfix = "";
  +            m_toPrefix = to;
  +            m_toPostfix = "";
           }
           else
           {
  -            toPrefix = to.substring( 0, index );
  -            toPostfix = to.substring( index + 1 );
  +            m_toPrefix = to.substring( 0, index );
  +            m_toPostfix = to.substring( index + 1 );
           }
       }
   
  @@ -100,17 +101,20 @@
        * @param sourceFileName Description of Parameter
        * @return Description of the Returned Value
        */
  -    public String[] mapFileName( String sourceFileName )
  +    public String[] mapFileName( final String sourceFileName )
       {
  -        if( fromPrefix == null
  -            || !sourceFileName.startsWith( fromPrefix )
  -            || !sourceFileName.endsWith( fromPostfix ) )
  +        if( m_fromPrefix == null ||
  +            !sourceFileName.startsWith( m_fromPrefix ) ||
  +            !sourceFileName.endsWith( m_fromPostfix ) )
           {
               return null;
           }
  -        return new String[]{toPrefix
  -            + extractVariablePart( sourceFileName )
  -            + toPostfix};
  +        else
  +        {
  +            final String result = m_toPrefix +
  +                extractVariablePart( sourceFileName ) + m_toPostfix;
  +            return new String[]{result};
  +        }
       }
   
       /**
  @@ -120,9 +124,9 @@
        * @param name Description of Parameter
        * @return Description of the Returned Value
        */
  -    protected String extractVariablePart( String name )
  +    protected String extractVariablePart( final String name )
       {
  -        return name.substring( prefixLength,
  -                               name.length() - postfixLength );
  +        return name.substring( m_prefixLength,
  +                               name.length() - m_postfixLength );
       }
   }
  
  
  
  1.4       +5 -5      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/IdentityMapper.java
  
  Index: IdentityMapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/IdentityMapper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- IdentityMapper.java	23 Dec 2001 06:32:30 -0000	1.3
  +++ IdentityMapper.java	12 Jan 2002 23:43:49 -0000	1.4
  @@ -15,15 +15,15 @@
    *
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
    */
  -public class IdentityMapper implements FileNameMapper
  +public class IdentityMapper
  +    implements FileNameMapper
   {
  -
       /**
        * Ignored.
        *
        * @param from The new From value
        */
  -    public void setFrom( String from )
  +    public void setFrom( final String from )
       {
       }
   
  @@ -32,7 +32,7 @@
        *
        * @param to The new To value
        */
  -    public void setTo( String to )
  +    public void setTo( final String to )
       {
       }
   
  @@ -42,7 +42,7 @@
        * @param sourceFileName Description of Parameter
        * @return Description of the Returned Value
        */
  -    public String[] mapFileName( String sourceFileName )
  +    public String[] mapFileName( final String sourceFileName )
       {
           return new String[]{sourceFileName};
       }
  
  
  
  1.4       +6 -6      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/MergingMapper.java
  
  Index: MergingMapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/MergingMapper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MergingMapper.java	23 Dec 2001 06:32:30 -0000	1.3
  +++ MergingMapper.java	12 Jan 2002 23:43:49 -0000	1.4
  @@ -15,9 +15,10 @@
    *
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
    */
  -public class MergingMapper implements FileNameMapper
  +public class MergingMapper
  +    implements FileNameMapper
   {
  -    protected String[] mergedFile = null;
  +    private String[] m_mergedFile;
   
       /**
        * Ignored.
  @@ -35,7 +36,7 @@
        */
       public void setTo( String to )
       {
  -        mergedFile = new String[]{to};
  +        m_mergedFile = new String[]{to};
       }
   
       /**
  @@ -44,9 +45,8 @@
        * @param sourceFileName Description of Parameter
        * @return Description of the Returned Value
        */
  -    public String[] mapFileName( String sourceFileName )
  +    public String[] mapFileName( final String sourceFileName )
       {
  -        return mergedFile;
  +        return m_mergedFile;
       }
  -
   }
  
  
  
  1.6       +30 -33    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/RegexpPatternMapper.java
  
  Index: RegexpPatternMapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/RegexpPatternMapper.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- RegexpPatternMapper.java	23 Dec 2001 06:32:30 -0000	1.5
  +++ RegexpPatternMapper.java	12 Jan 2002 23:43:49 -0000	1.6
  @@ -17,37 +17,34 @@
    *
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
    */
  -public class RegexpPatternMapper implements FileNameMapper
  +public class RegexpPatternMapper
  +    implements FileNameMapper
   {
  -    protected RegexpMatcher reg = null;
  -    protected char[] to = null;
  -    protected StringBuffer result = new StringBuffer();
  +    private RegexpMatcher m_matcher;
  +    private char[] m_to;
  +    private StringBuffer m_result = new StringBuffer();
   
       public RegexpPatternMapper()
           throws TaskException
       {
  -        reg = ( new RegexpMatcherFactory() ).newRegexpMatcher();
  +        m_matcher = ( new RegexpMatcherFactory() ).newRegexpMatcher();
       }
   
       /**
        * Sets the &quot;from&quot; pattern. Required.
  -     *
  -     * @param from The new From value
  -     * @exception TaskException Description of Exception
        */
  -    public void setFrom( String from )
  +    public void setFrom( final String from )
           throws TaskException
       {
           try
           {
  -            reg.setPattern( from );
  +            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 );
  +            throw new TaskException( "Cannot load regular expression matcher", e );
           }
       }
   
  @@ -56,9 +53,9 @@
        *
        * @param to The new To value
        */
  -    public void setTo( String to )
  +    public void setTo( final String to )
       {
  -        this.to = to.toCharArray();
  +        m_to = to.toCharArray();
       }
   
       /**
  @@ -68,57 +65,57 @@
        * @param sourceFileName Description of Parameter
        * @return Description of the Returned Value
        */
  -    public String[] mapFileName( String sourceFileName )
  +    public String[] mapFileName( final String sourceFileName )
           throws TaskException
       {
  -        if( reg == null || to == null || !reg.matches( sourceFileName ) )
  +        if( m_matcher == null || m_to == null ||
  +            !m_matcher.matches( sourceFileName ) )
           {
               return null;
           }
  -        return new String[]{replaceReferences( sourceFileName )};
  +        else
  +        {
  +            return new String[]{replaceReferences( sourceFileName )};
  +        }
       }
   
       /**
        * Replace all backreferences in the to pattern with the matched groups of
        * the source.
  -     *
  -     * @param source Description of Parameter
  -     * @return Description of the Returned Value
        */
  -    protected String replaceReferences( String source )
  +    private String replaceReferences( final String source )
           throws TaskException
       {
  -        ArrayList v = reg.getGroups( source );
  +        final ArrayList groups = m_matcher.getGroups( source );
   
  -        result.setLength( 0 );
  -        for( int i = 0; i < to.length; i++ )
  +        m_result.setLength( 0 );
  +        for( int i = 0; i < m_to.length; i++ )
           {
  -            if( to[ i ] == '\\' )
  +            if( m_to[ i ] == '\\' )
               {
  -                if( ++i < to.length )
  +                if( ++i < m_to.length )
                   {
  -                    int value = Character.digit( to[ i ], 10 );
  +                    final int value = Character.digit( m_to[ i ], 10 );
                       if( value > -1 )
                       {
  -                        result.append( (String)v.get( value ) );
  +                        m_result.append( (String)groups.get( value ) );
                       }
                       else
                       {
  -                        result.append( to[ i ] );
  +                        m_result.append( m_to[ i ] );
                       }
                   }
                   else
                   {
                       // XXX - should throw an exception instead?
  -                    result.append( '\\' );
  +                    m_result.append( '\\' );
                   }
               }
               else
               {
  -                result.append( to[ i ] );
  +                m_result.append( m_to[ i ] );
               }
           }
  -        return result.toString();
  +        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>


Mime
View raw message