com.charliedog.argv
Class StringArgument

java.lang.Object
  |
  +--com.charliedog.argv.StringArgument
All Implemented Interfaces:
Argument

public class StringArgument
extends java.lang.Object
implements Argument

A String argument for use with ArgumentParser. A String argument may have a default value. If specified on the command line, a string argument takes the value of the argument immediately following its flag.


Constructor Summary
StringArgument(java.lang.String flag, java.lang.String description)
          Initialize a new String argument with the given flag and description but without a default value.
StringArgument(java.lang.String flag, java.lang.String defaultValue, java.lang.String description)
          Initialize a new String argument with the given flag, description, and default value.
 
Method Summary
 java.lang.String getValue()
          Return the string value of this argument, which may be null.
 int parse(java.util.List values)
          Parsing method invoked by ArgumentParser.
 void printUsage(java.io.PrintWriter out)
          Usage method invoked by ArgumentParser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringArgument

public StringArgument(java.lang.String flag,
                      java.lang.String description)
Initialize a new String argument with the given flag and description but without a default value.


StringArgument

public StringArgument(java.lang.String flag,
                      java.lang.String defaultValue,
                      java.lang.String description)
Initialize a new String argument with the given flag, description, and default value.

Method Detail

getValue

public java.lang.String getValue()
Return the string value of this argument, which may be null. Returns the default value if the value was not set when the command line was parsed.


parse

public int parse(java.util.List values)
Parsing method invoked by ArgumentParser.

Specified by:
parse in interface Argument

printUsage

public void printUsage(java.io.PrintWriter out)
Usage method invoked by ArgumentParser.

Specified by:
printUsage in interface Argument