ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From umag...@apache.org
Subject cvs commit: jakarta-ant/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types Parameter.java AntFilterReader.java Parameterizable.java
Date Sat, 16 Feb 2002 02:29:34 GMT
umagesh     02/02/15 18:29:34

  Modified:    proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters
                        StripLineBreaks.java
               proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs
                        LoadFile.java
               proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types
                        AntFilterReader.java Parameterizable.java
  Added:       proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types
                        Parameter.java
  Log:
  1.  Change Parameterizable interface's setParameters method signature such that it takes
in an array of type Parameter instead of Hashtable.
  2.  Introduce "type" as an attribute to nested param.
  
  Revision  Changes    Path
  1.2       +14 -7     jakarta-ant/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/StripLineBreaks.java
  
  Index: StripLineBreaks.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/filters/StripLineBreaks.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StripLineBreaks.java	15 Feb 2002 21:50:54 -0000	1.1
  +++ StripLineBreaks.java	16 Feb 2002 02:29:34 -0000	1.2
  @@ -3,8 +3,8 @@
   import java.io.FilterReader;
   import java.io.IOException;
   import java.io.Reader;
  -import java.util.Hashtable;
   
  +import org.apache.tools.ant.types.Parameter;
   import org.apache.tools.ant.types.Parameterizable;
   
   /**
  @@ -28,7 +28,7 @@
        */
       private static final String LINE_BREAKS_KEY = "linebreaks";
   
  -    private Hashtable parameters;
  +    private Parameter[] parameters;
   
       /**
        * Create a new filtered reader.
  @@ -73,15 +73,22 @@
        * the option is requested, then line breaks are probably in the source string.
        */
       private final String stripLineBreaks(final String source) {
  -        final int len=source.length();
  -        final String userDefinedLineBreaks =
  -            (String) parameters.get(LINE_BREAKS_KEY);
  +        final int len = source.length();
  +        String userDefinedLineBreaks = null;
  +        if (parameters != null) {
  +            for (int i = 0; i < parameters.length; i++) {
  +                if (LINE_BREAKS_KEY.equals(parameters[i].getName())) {
  +                    userDefinedLineBreaks = parameters[i].getValue();
  +                    break;
  +                }
  +            }
  +        }
   
           String lineBreaks = DEFAULT_LINE_BREAKS;
           if (userDefinedLineBreaks != null) {
               lineBreaks = userDefinedLineBreaks;
           }
  -        final StringBuffer dest=new StringBuffer(len);
  +        final StringBuffer dest = new StringBuffer(len);
           for(int i=0;i<len;++i) {
               final char ch=source.charAt(i);
               if(lineBreaks.indexOf(ch)==-1) {
  @@ -95,7 +102,7 @@
       /**
        * Set Parameters
        */
  -    public final void setParameters(final Hashtable parameters) {
  +    public final void setParameters(final Parameter[] parameters) {
           this.parameters = parameters;
       }
   }
  
  
  
  1.4       +2 -2      jakarta-ant/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadFile.java
  
  Index: LoadFile.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadFile.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LoadFile.java	16 Feb 2002 00:35:38 -0000	1.3
  +++ LoadFile.java	16 Feb 2002 02:29:34 -0000	1.4
  @@ -58,12 +58,12 @@
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.types.AntFilterReader;
   import org.apache.tools.ant.types.FilterReaderSet;
  +import org.apache.tools.ant.types.Parameter;
   import org.apache.tools.ant.types.Parameterizable;
   
   import java.io.*;
   import java.lang.reflect.Constructor;
   import java.lang.reflect.InvocationTargetException;
  -import java.util.Hashtable;
   import java.util.Vector;
   
   /**
  @@ -272,7 +272,7 @@
                               instream =
                                   (Reader) constructors[0].newInstance(rdr);
                               if (Parameterizable.class.isAssignableFrom(clazz)) {
  -                                final Hashtable params = filter.getParams();
  +                                final Parameter[] params = filter.getParams();
                                   ((Parameterizable)
                                       instream).setParameters(params);
                               }
  
  
  
  1.2       +3 -33     jakarta-ant/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/AntFilterReader.java
  
  Index: AntFilterReader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/AntFilterReader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AntFilterReader.java	15 Feb 2002 21:50:55 -0000	1.1
  +++ AntFilterReader.java	16 Feb 2002 02:29:34 -0000	1.2
  @@ -57,7 +57,6 @@
   import java.util.Hashtable;
   import java.util.Vector;
   
  -import org.apache.tools.ant.types.Parameterizable;
   import org.apache.tools.ant.BuildException;
   
   /**
  @@ -94,38 +93,9 @@
           parameters.addElement(param);
       }
   
  -    public final Hashtable getParams() {
  -        final int size = parameters.size();
  -        final Hashtable params = new Hashtable();
  -        for (int i = 0; i < size; i++) {
  -            final Parameter param = (Parameter) parameters.elementAt(i);
  -            final String name = param.getName();
  -            final String value = param.getValue();
  -            if (name != null && value != null) {
  -                params.put(name, value);
  -            }
  -        }
  +    public final Parameter[] getParams() {
  +        Parameter[] params = new Parameter[parameters.size()];
  +        parameters.copyInto(params);
           return params;
  -    }
  -
  -    public static final class Parameter {
  -        private String name = null;
  -        private String value = null;
  -
  -        public final void setName(final String name) {
  -            this.name = name;
  -        }
  -
  -        public final void setValue(final String value) {
  -            this.value = value;
  -        }
  -
  -        public final String getName() {
  -            return name;
  -        }
  -
  -        public final String getValue() {
  -            return value;
  -        }
       }
   }
  
  
  
  1.2       +2 -2      jakarta-ant/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/Parameterizable.java
  
  Index: Parameterizable.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/Parameterizable.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Parameterizable.java	15 Feb 2002 21:50:55 -0000	1.1
  +++ Parameterizable.java	16 Feb 2002 02:29:34 -0000	1.2
  @@ -53,7 +53,7 @@
    */
   package org.apache.tools.ant.types;
   
  -import java.util.Hashtable;
  +import java.util.Vector;
   
   /**
    * Parameterizable objects take genric key value pairs.
  @@ -61,5 +61,5 @@
    * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
    */
   public interface Parameterizable {
  -    void setParameters(Hashtable parameters);
  +    void setParameters(Parameter[] parameters);
   }
  
  
  
  1.1                  jakarta-ant/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/types/Parameter.java
  
  Index: Parameter.java
  ===================================================================
  /*
   *  The Apache Software License, Version 1.1
   *
   *  Copyright (c) 2002 The Apache Software Foundation.  All rights
   *  reserved.
   *
   *  Redistribution and use in source and binary forms, with or without
   *  modification, are permitted provided that the following conditions
   *  are met:
   *
   *  1. Redistributions of source code must retain the above copyright
   *  notice, this list of conditions and the following disclaimer.
   *
   *  2. Redistributions in binary form must reproduce the above copyright
   *  notice, this list of conditions and the following disclaimer in
   *  the documentation and/or other materials provided with the
   *  distribution.
   *
   *  3. The end-user documentation included with the redistribution, if
   *  any, must include the following acknowlegement:
   *  "This product includes software developed by the
   *  Apache Software Foundation (http://www.apache.org/)."
   *  Alternately, this acknowlegement may appear in the software itself,
   *  if and wherever such third-party acknowlegements normally appear.
   *
   *  4. The names "The Jakarta Project", "Ant", and "Apache Software
   *  Foundation" must not be used to endorse or promote products derived
   *  from this software without prior written permission. For written
   *  permission, please contact apache@apache.org.
   *
   *  5. Products derived from this software may not be called "Apache"
   *  nor may "Apache" appear in their names without prior written
   *  permission of the Apache Group.
   *
   *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   *  DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   *  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   *  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   *  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   *  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   *  SUCH DAMAGE.
   *  ====================================================================
   *
   *  This software consists of voluntary contributions made by many
   *  individuals on behalf of the Apache Software Foundation.  For more
   *  information on the Apache Software Foundation, please see
   *  <http://www.apache.org/>.
   */
  package org.apache.tools.ant.types;
  
  /**
   * A parameter is composed of a name, type and value.
   *
   * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
   */
  public final class Parameter {
      private String name = null;
      private String type = null;
      private String value = null;
  
      public final void setName(final String name) {
          this.name = name;
      }
  
      public final void setType(final String type) {
          this.type = type;
      }
  
      public final void setValue(final String value) {
          this.value = value;
      }
  
      public final String getName() {
          return name;
      }
  
      public final String getType() {
          return type;
      }
  
      public final String getValue() {
          return value;
      }
  }
  
  
  

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