Coverage Report - org.dishevelled.commandline.Argument
 
Classes in this File Line Coverage Branch Coverage Complexity
Argument
N/A
N/A
1
 
 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;
 25  
 
 26  
 /**
 27  
  * A typed argument.
 28  
  *
 29  
  * @param <E> argument type
 30  
  * @author  Michael Heuer
 31  
  */
 32  
 public interface Argument<E>
 33  
 {
 34  
 
 35  
     /**
 36  
      * Visit the specified argument string from the specified command line.
 37  
      *
 38  
      * <p>Previous and next argument strings in the command line may be interrogated
 39  
      * by this argument, but the <i>cursor position</i> of the command line must
 40  
      * be reset to what it was at the beginning of this method invocation.</p>
 41  
      *
 42  
      * @param s current argument string
 43  
      * @param commandLine command line to visit
 44  
      * @throws Exception if any error occurs
 45  
      */
 46  
     void visit(String s, CommandLine commandLine)
 47  
         throws Exception;
 48  
 
 49  
     /**
 50  
      * Return the short name of this argument.
 51  
      *
 52  
      * @return the short name of this argument
 53  
      */
 54  
     String getShortName();
 55  
 
 56  
     /**
 57  
      * Return the long name of this argument.
 58  
      *
 59  
      * @return the long name of this argument
 60  
      */
 61  
     String getLongName();
 62  
 
 63  
     /**
 64  
      * Return the description of this argument.
 65  
      *
 66  
      * @return the description of this argument
 67  
      */
 68  
     String getDescription();
 69  
 
 70  
     /**
 71  
      * Return true if this argument is required.
 72  
      *
 73  
      * @return true if this argument is required
 74  
      */
 75  
     boolean isRequired();
 76  
 
 77  
     /**
 78  
      * Return true if this argument was found in the
 79  
      * command line, false if it was not found or if
 80  
      * this argument has not visited a command line
 81  
      * yet.
 82  
      *
 83  
      * @see #visit(String, CommandLine)
 84  
      * @return true if this argument was found in the
 85  
      *    command line
 86  
      */
 87  
     boolean wasFound();
 88  
 
 89  
     /**
 90  
      * Return the value of this argument.
 91  
      *
 92  
      * @return the value of this argument
 93  
      */
 94  
     E getValue();
 95  
 
 96  
     /**
 97  
      * Return the value of this argument or the specified default value
 98  
      * if this argument was not found in the command line.
 99  
      *
 100  
      * @return the value of this argument or the specified default value
 101  
      *    if this argument was not found in the command line
 102  
      */
 103  
     E getValue(E defaultValue);
 104  
 }