ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Input.java
Date Fri, 28 Jun 2002 12:47:18 GMT
bodewig     2002/06/28 05:47:18

  Modified:    .        WHATSNEW
               src/main/org/apache/tools/ant/taskdefs Input.java
  Log:
  Add default value to <input>.
  
  Submitted by:	Scott Sanders <ssanders@nextance.com>
  
  Revision  Changes    Path
  1.270     +2 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.269
  retrieving revision 1.270
  diff -u -r1.269 -r1.270
  --- WHATSNEW	22 Jun 2002 23:46:50 -0000	1.269
  +++ WHATSNEW	28 Jun 2002 12:47:18 -0000	1.270
  @@ -11,6 +11,8 @@
   
   * <filterset> will now resolve filters recursively.
   
  +* <input> has a new attribute that allows you to specify a default value.
  +
   Changes from Ant 1.4.1 to Ant 1.5
   =================================
   
  
  
  
  1.13      +18 -1     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Input.java
  
  Index: Input.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Input.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Input.java	22 Jun 2002 23:38:31 -0000	1.12
  +++ Input.java	28 Jun 2002 12:47:18 -0000	1.13
  @@ -77,6 +77,7 @@
       private String validargs = null;
       private String message = "";
       private String addproperty = null;
  +    private String defaultvalue = null;
   
       /**
        * Defines valid input parameters as comma separated strings. If set, input
  @@ -110,6 +111,17 @@
       }
   
       /**
  +     * Defines the default value of the property to be created from input.
  +     * Property value will be set to default if not input is received.
  +     *
  +     * @param defaultvalue Default value for the property if no input
  +     * is received
  +     */
  +    public void setDefaultvalue (String defaultvalue) {
  +        this.defaultvalue = defaultvalue;
  +    }
  +
  +    /**
        * Set a multiline message.
        */
       public void addText(String msg) {
  @@ -137,8 +149,13 @@
   
           getProject().getInputHandler().handleInput(request);
   
  +        String value = request.getInput();
  +        if ((value == null || value.trim().length() == 0) 
  +            && defaultvalue != null) {
  +            value = defaultvalue;
  +        }
           if (addproperty != null) {
  -            project.setNewProperty(addproperty, request.getInput());
  +            project.setNewProperty(addproperty, 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