ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/filters ReplaceTokens.java
Date Wed, 19 Feb 2003 14:44:54 GMT
conor       2003/02/19 06:44:54

  Modified:    src/main/org/apache/tools/ant Tag: ANT_15_BRANCH
                        IntrospectionHelper.java
               src/main/org/apache/tools/ant/filters Tag: ANT_15_BRANCH
                        ReplaceTokens.java
  Log:
  Merge
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.42.2.2  +10 -2     ant/src/main/org/apache/tools/ant/IntrospectionHelper.java
  
  Index: IntrospectionHelper.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/IntrospectionHelper.java,v
  retrieving revision 1.42.2.1
  retrieving revision 1.42.2.2
  diff -u -w -u -r1.42.2.1 -r1.42.2.2
  --- IntrospectionHelper.java	10 Feb 2003 14:24:37 -0000	1.42.2.1
  +++ IntrospectionHelper.java	19 Feb 2003 14:44:54 -0000	1.42.2.2
  @@ -259,7 +259,7 @@
                           particular order.
                       */
                   }
  -                AttributeSetter as = createAttributeSetter(m, args[0]);
  +                AttributeSetter as = createAttributeSetter(m, args[0], propName);
                   if (as != null) {
                       attributeTypes.put(propName, args[0]);
                       attributeSetters.put(propName, as);
  @@ -689,12 +689,15 @@
        *          Must not be <code>null</code>.
        * @param arg The type of the single argument of the bean's method.
        *            Must not be <code>null</code>.
  +     * @param attrName the name of the attribute for which the setter is being
  +     *                 created.
        * 
        * @return an appropriate AttributeSetter instance, or <code>null</code>
        *         if no appropriate conversion is available.
        */
       private AttributeSetter createAttributeSetter(final Method m,
  -                                                  Class arg) {
  +                                                  Class arg, 
  +                                                  final String attrName) {
           // use wrappers for primitive classes, e.g. int and 
           // Integer are treated identically
           final Class reflectedArg = PRIMITIVE_TYPE_MAP.containsKey (arg) 
  @@ -714,6 +717,11 @@
               return new AttributeSetter() {
                       public void set(Project p, Object parent, String value)
                           throws InvocationTargetException, IllegalAccessException {
  +                        if (value.length() == 0) {
  +                            throw new BuildException("The value \"\" is not a " 
  +                                + "legal value for attribute \"" 
  +                                + attrName + "\"");
  +                        }
                           m.invoke(parent, new Character[] {new Character(value.charAt(0))});
                       }
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.4.2.5   +11 -1     ant/src/main/org/apache/tools/ant/filters/ReplaceTokens.java
  
  Index: ReplaceTokens.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/filters/ReplaceTokens.java,v
  retrieving revision 1.4.2.4
  retrieving revision 1.4.2.5
  diff -u -w -u -r1.4.2.4 -r1.4.2.5
  --- ReplaceTokens.java	19 Feb 2003 14:18:30 -0000	1.4.2.4
  +++ ReplaceTokens.java	19 Feb 2003 14:44:54 -0000	1.4.2.5
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2002-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -58,6 +58,7 @@
   import java.util.Hashtable;
   
   import org.apache.tools.ant.types.Parameter;
  +import org.apache.tools.ant.BuildException;
   
   /**
    * Replaces tokens in the original input with user-supplied values.
  @@ -304,9 +305,18 @@
                       final String type = params[i].getType();
                       if ("tokenchar".equals(type)) {
                           final String name = params[i].getName();
  +                        String value = params[i].getValue();
                           if ("begintoken".equals(name)) {
  +                            if (value.length() == 0) {
  +                                throw new BuildException("Begin token cannot " 
  +                                    + "be empty");
  +                            }
                               beginToken = params[i].getValue().charAt(0);
                           } else if ("endtoken".equals(name)) {
  +                            if (value.length() == 0) {
  +                                throw new BuildException("End token cannot " 
  +                                    + "be empty");
  +                            }
                               endToken = params[i].getValue().charAt(0);
                           }
                       } else if ("token".equals(type)) {
  
  
  

Mime
View raw message