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/java/org/apache/myrmidon/framework PatternUtil.java PatternSet.java
Date Sat, 26 Jan 2002 02:07:01 GMT
donaldp     02/01/25 18:07:01

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/framework
                        PatternSet.java
  Added:       proposal/myrmidon/src/java/org/apache/myrmidon/framework
                        PatternUtil.java
  Log:
  Mover pattern logic into a PatternUtil class
  
  Revision  Changes    Path
  1.3       +12 -45    jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/PatternSet.java
  
  Index: PatternSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/PatternSet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PatternSet.java	25 Jan 2002 23:30:30 -0000	1.2
  +++ PatternSet.java	26 Jan 2002 02:07:01 -0000	1.3
  @@ -8,10 +8,7 @@
   package org.apache.myrmidon.framework;
   
   import java.util.ArrayList;
  -import java.util.Iterator;
   import java.util.StringTokenizer;
  -import org.apache.myrmidon.api.TaskContext;
  -import org.apache.myrmidon.api.TaskException;
   
   /**
    * Named collection of include/exclude tags. <p>
  @@ -25,8 +22,8 @@
    */
   public class PatternSet
   {
  -    private ArrayList m_includeList = new ArrayList();
  -    private ArrayList m_excludeList = new ArrayList();
  +    private ArrayList m_includes = new ArrayList();
  +    private ArrayList m_excludes = new ArrayList();
   
       /**
        * Sets the set of exclude patterns. Patterns may be separated by a comma or
  @@ -63,7 +60,7 @@
        */
       public void addExclude( final Pattern pattern )
       {
  -        m_excludeList.add( pattern );
  +        m_excludes.add( pattern );
       }
   
       /**
  @@ -71,22 +68,17 @@
        */
       public void addInclude( final Pattern pattern )
       {
  -        m_includeList.add( pattern );
  +        m_includes.add( pattern );
       }
   
  -    public String[] getExcludePatterns( final TaskContext context )
  -        throws TaskException
  +    public final ArrayList getIncludes()
       {
  -        return toArray( m_excludeList, context );
  +        return m_includes;
       }
   
  -    /**
  -     * Returns the filtered include patterns.
  -     */
  -    public String[] getIncludePatterns( final TaskContext context )
  -        throws TaskException
  +    public final ArrayList getExcludes()
       {
  -        return toArray( m_includeList, context );
  +        return m_excludes;
       }
   
       /**
  @@ -94,14 +86,14 @@
        */
       public void append( final PatternSet other )
       {
  -        m_includeList.addAll( other.m_includeList );
  -        m_excludeList.addAll( other.m_excludeList );
  +        m_includes.addAll( other.m_includes );
  +        m_excludes.addAll( other.m_excludes );
       }
   
       public String toString()
       {
  -        return "PatternSet [ includes: " + m_includeList +
  -            " excludes: " + m_excludeList + " ]";
  +        return "PatternSet [ includes: " + m_includes +
  +            " excludes: " + m_excludes + " ]";
       }
   
       private Pattern[] parsePatterns( final String patternString )
  @@ -118,30 +110,5 @@
           }
   
           return (Pattern[])patterns.toArray( new Pattern[ patterns.size() ] );
  -    }
  -
  -    /**
  -     * Convert a vector of Pattern elements into an array of Strings.
  -     */
  -    private String[] toArray( final ArrayList list, final TaskContext context )
  -    {
  -        if( list.size() == 0 )
  -        {
  -            return null;
  -        }
  -
  -        final ArrayList names = new ArrayList();
  -        final Iterator e = list.iterator();
  -        while( e.hasNext() )
  -        {
  -            final Pattern pattern = (Pattern)e.next();
  -            final String result = pattern.evaluateName( context );
  -            if( null != result && result.length() > 0 )
  -            {
  -                names.add( result );
  -            }
  -        }
  -
  -        return (String[])names.toArray( new String[ names.size() ] );
       }
   }
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/PatternUtil.java
  
  Index: PatternUtil.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.myrmidon.framework;
  
  import java.util.ArrayList;
  import java.util.Iterator;
  import org.apache.myrmidon.api.TaskContext;
  import org.apache.myrmidon.api.TaskException;
  
  /**
   *
   *
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/01/26 02:07:01 $
   */
  public class PatternUtil
  {
      /**
       * Returns the filtered include patterns.
       */
      public static String[] getIncludePatterns( final PatternSet set,
                                                 final TaskContext context )
          throws TaskException
      {
          return toArray( set.getIncludes(), context );
      }
  
      public static String[] getExcludePatterns( final PatternSet set,
                                                 final TaskContext context )
          throws TaskException
      {
          return toArray( set.getExcludes(), context );
      }
  
      /**
       * Convert a vector of Pattern elements into an array of Strings.
       */
      private static String[] toArray( final ArrayList list, final TaskContext context )
      {
          if( list.size() == 0 )
          {
              return null;
          }
  
          final ArrayList names = new ArrayList();
          final Iterator patterns = list.iterator();
          while( patterns.hasNext() )
          {
              final Pattern pattern = (Pattern)patterns.next();
              final String result = pattern.evaluateName( context );
              if( null != result && result.length() > 0 )
              {
                  names.add( result );
              }
          }
  
          return (String[])names.toArray( new String[ names.size() ] );
      }
  }
  
  
  

--
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