Coverage Report - org.dishevelled.commandline.argument.FloatListArgument
 
Classes in this File Line Coverage Branch Coverage Complexity
FloatListArgument
100%
11/11
100%
2/2
1.5
 
 1  
 /*
 2  
 
 3  
     dsh-commandline  Command line parser based on typed arguments.
 4  
     Copyright (c) 2004-2014 held jointly by the individual authors.
 5  
 
 6  
     This library is free software; you can redistribute it and/or modify it
 7  
     under the terms of the GNU Lesser General Public License as published
 8  
     by the Free Software Foundation; either version 3 of the License, or (at
 9  
     your option) any later version.
 10  
 
 11  
     This library is distributed in the hope that it will be useful, but WITHOUT
 12  
     ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
 13  
     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 14  
     License for more details.
 15  
 
 16  
     You should have received a copy of the GNU Lesser General Public License
 17  
     along with this library;  if not, write to the Free Software Foundation,
 18  
     Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA.
 19  
 
 20  
     > http://www.fsf.org/licensing/licenses/lgpl.html
 21  
     > http://www.opensource.org/licenses/lgpl-license.php
 22  
 
 23  
 */
 24  
 package org.dishevelled.commandline.argument;
 25  
 
 26  
 import java.util.List;
 27  
 import java.util.ArrayList;
 28  
 import java.util.StringTokenizer;
 29  
 
 30  
 import org.apache.commons.lang.StringUtils;
 31  
 
 32  
 /**
 33  
  * A float list argument.
 34  
  *
 35  
  * @author  Michael Heuer
 36  
  */
 37  18
 public final class FloatListArgument
 38  
     extends AbstractArgument<List<Float>>
 39  
 {
 40  
 
 41  
     /**
 42  
      * Create a new float list argument.
 43  
      *
 44  
      * @param shortName short argument name
 45  
      * @param longName long argument name
 46  
      * @param description argument description
 47  
      * @param required <code>true</code> if this argument is required
 48  
      */
 49  
     public FloatListArgument(final String shortName,
 50  
                              final String longName,
 51  
                              final String description,
 52  
                              final boolean required)
 53  
     {
 54  7
         super(shortName, longName, description, required);
 55  7
     }
 56  
 
 57  
 
 58  
     /** {@inheritDoc} */
 59  
     protected List<Float> convert(final String s)
 60  
         throws Exception
 61  
     {
 62  18
         List<Float> list = new ArrayList<Float>();
 63  18
         StringTokenizer st = new StringTokenizer(s, ",");
 64  40
         while (st.hasMoreTokens())
 65  
         {
 66  24
             String token = StringUtils.stripToEmpty(st.nextToken());
 67  24
             Float f = Float.valueOf(token);
 68  22
             list.add(f);
 69  22
         }
 70  16
         return list;
 71  
     }
 72  
 }