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/regexp RegexpFactory.java RegexpMatcherFactory.java
Date Fri, 04 Jan 2002 09:27:38 GMT
donaldp     02/01/04 01:27:38

  Modified:    proposal/myrmidon/src/main/org/apache/tools/ant/util/regexp
                        RegexpFactory.java RegexpMatcherFactory.java
  Log:
  Simplified and cleaned regex factorys
  
  Revision  Changes    Path
  1.4       +11 -40    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/regexp/RegexpFactory.java
  
  Index: RegexpFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/regexp/RegexpFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RegexpFactory.java	23 Dec 2001 06:32:30 -0000	1.3
  +++ RegexpFactory.java	4 Jan 2002 09:27:37 -0000	1.4
  @@ -8,7 +8,6 @@
   package org.apache.tools.ant.util.regexp;
   
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.tools.ant.Project;
   
   /**
    * Regular expression factory, which will create Regexp objects. The actual
  @@ -17,46 +16,18 @@
    *
    * @author Matthew Inger <a href="mailto:mattinger@mindless.com">
    *      mattinger@mindless.com</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
  -public class RegexpFactory extends RegexpMatcherFactory
  +public class RegexpFactory
  +    extends RegexpMatcherFactory
   {
  -    public RegexpFactory()
  -    {
  -    }
  -
       /**
        * Create a new regular expression matcher instance.
  -     *
  -     * @return Description of the Returned Value
  -     * @exception TaskException Description of Exception
        */
       public Regexp newRegexp()
           throws TaskException
       {
  -        return (Regexp)newRegexp( null );
  -    }
  -
  -    /**
  -     * Create a new regular expression matcher instance.
  -     *
  -     * @param p Project whose ant.regexp.regexpimpl property will be used.
  -     * @return Description of the Returned Value
  -     * @exception TaskException Description of Exception
  -     */
  -    public Regexp newRegexp( Project p )
  -        throws TaskException
  -    {
  -        String systemDefault = null;
  -        if( p == null )
  -        {
  -            systemDefault = System.getProperty( "ant.regexp.regexpimpl" );
  -        }
  -        else
  -        {
  -            systemDefault = (String)p.getProperties().get( "ant.regexp.regexpimpl" );
  -        }
  -
  +        final String systemDefault = System.getProperty( "ant.regexp.regexpimpl" );
           if( systemDefault != null )
           {
               return createRegexpInstance( systemDefault );
  @@ -66,7 +37,7 @@
   
           try
           {
  -            return createRegexpInstance( "org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp"
);
  +            return createRegexpInstance( JDK14_REGEXP );
           }
           catch( TaskException be )
           {
  @@ -74,7 +45,7 @@
   
           try
           {
  -            return createRegexpInstance( "org.apache.tools.ant.util.regexp.JakartaOroRegexp"
);
  +            return createRegexpInstance( JAKARTA_ORO );
           }
           catch( TaskException be )
           {
  @@ -82,13 +53,14 @@
   
           try
           {
  -            return createRegexpInstance( "org.apache.tools.ant.util.regexp.JakartaRegexpRegexp"
);
  +            return createRegexpInstance( JAKARTA_REGEXP );
           }
           catch( TaskException be )
           {
           }
   
  -        throw new TaskException( "No supported regular expression matcher found" );
  +        final String message = "No supported regular expression matcher found";
  +        throw new TaskException( message );
       }
   
       /**
  @@ -100,11 +72,10 @@
        * @exception TaskException Description of Exception
        * @since 1.3
        */
  -    protected Regexp createRegexpInstance( String classname )
  +    private Regexp createRegexpInstance( final String classname )
           throws TaskException
       {
  -
  -        RegexpMatcher m = createInstance( classname );
  +        final RegexpMatcher m = createInstance( classname );
           if( m instanceof Regexp )
           {
               return (Regexp)m;
  
  
  
  1.5       +11 -33    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java
  
  Index: RegexpMatcherFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RegexpMatcherFactory.java	23 Dec 2001 06:32:30 -0000	1.4
  +++ RegexpMatcherFactory.java	4 Jan 2002 09:27:37 -0000	1.5
  @@ -8,7 +8,6 @@
   package org.apache.tools.ant.util.regexp;
   
   import org.apache.myrmidon.api.TaskException;
  -import org.apache.tools.ant.Project;
   
   /**
    * Simple Factory Class that produces an implementation of RegexpMatcher based
  @@ -22,22 +21,9 @@
    */
   public class RegexpMatcherFactory
   {
  -
  -    public RegexpMatcherFactory()
  -    {
  -    }
  -
  -    /**
  -     * Create a new regular expression instance.
  -     *
  -     * @return Description of the Returned Value
  -     * @exception TaskException Description of Exception
  -     */
  -    public RegexpMatcher newRegexpMatcher()
  -        throws TaskException
  -    {
  -        return newRegexpMatcher( null );
  -    }
  +    protected static final String JAKARTA_REGEXP = "org.apache.tools.ant.util.regexp.JakartaRegexpRegexp";
  +    protected static final String JAKARTA_ORO = "org.apache.tools.ant.util.regexp.JakartaOroRegexp";
  +    protected static final String JDK14_REGEXP = "org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp";
   
       /**
        * Create a new regular expression instance.
  @@ -46,19 +32,10 @@
        * @return Description of the Returned Value
        * @exception TaskException Description of Exception
        */
  -    public RegexpMatcher newRegexpMatcher( Project p )
  +    public RegexpMatcher newRegexpMatcher()
           throws TaskException
       {
  -        String systemDefault = null;
  -        if( p == null )
  -        {
  -            systemDefault = System.getProperty( "ant.regexp.regexpimpl" );
  -        }
  -        else
  -        {
  -            systemDefault = (String)p.getProperties().get( "ant.regexp.regexpimpl" );
  -        }
  -
  +        final String systemDefault = System.getProperty( "ant.regexp.regexpimpl" );
           if( systemDefault != null )
           {
               return createInstance( systemDefault );
  @@ -68,7 +45,7 @@
   
           try
           {
  -            return createInstance( "org.apache.tools.ant.util.regexp.Jdk14RegexpMatcher"
);
  +            return createInstance( JDK14_REGEXP );
           }
           catch( TaskException be )
           {
  @@ -76,7 +53,7 @@
   
           try
           {
  -            return createInstance( "org.apache.tools.ant.util.regexp.JakartaOroMatcher"
);
  +            return createInstance( JAKARTA_ORO );
           }
           catch( TaskException be )
           {
  @@ -84,16 +61,17 @@
   
           try
           {
  -            return createInstance( "org.apache.tools.ant.util.regexp.JakartaRegexpMatcher"
);
  +            return createInstance( JAKARTA_REGEXP );
           }
           catch( TaskException be )
           {
           }
   
  -        throw new TaskException( "No supported regular expression matcher found" );
  +        final String message = "No supported regular expression matcher found";
  +        throw new TaskException( message );
       }
   
  -    protected RegexpMatcher createInstance( String className )
  +    protected RegexpMatcher createInstance( final String className )
           throws TaskException
       {
           try
  
  
  

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