V - represents the type of the non-option argumentspublic class NonOptionArgumentSpec<V> extends Object
Specification of a command line's non-option arguments.
Instances are returned from OptionParser methods to allow the formation of parser directives as
sentences in a "fluent interface" language. For example:
OptionParser parser = new OptionParser();
parser.nonOptions( "files to be processed" ).ofType( File.class );
If no methods are invoked on an instance of this class, then that instance's option will treat the non-option
arguments as Strings.
| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptsArguments()
Does this option accept arguments?
|
String |
argumentDescription()
Gives a short description of the option's argument.
|
String |
argumentTypeIndicator()
Gives an indication of the expected type of the option's
argument.
|
protected String |
argumentTypeIndicatorFrom(ValueConverter<V> converter) |
protected V |
convert(String argument) |
protected V |
convertWith(ValueConverter<V> converter,
String argument) |
List<?> |
defaultValues()
What values will the option take if none are specified on the command line?
|
NonOptionArgumentSpec<V> |
describedAs(String description)
Specifies a description for the non-option arguments that this spec represents.
|
String |
description()
Description of this option's purpose.
|
boolean |
equals(Object that) |
joptsimple.AbstractOptionSpec<V> |
forHelp() |
int |
hashCode() |
boolean |
isForHelp()
Tells whether this option is designated as a "help" option.
|
boolean |
isRequired()
Is this option required on a command line?
|
<T> NonOptionArgumentSpec<T> |
ofType(Class<T> argumentType)
Specifies a type to which the non-option arguments are to be converted.
|
Collection<String> |
options()
A set of options that are mutually synonymous.
|
boolean |
representsNonOptions()
Tells whether this object represents the non-option arguments of a command line.
|
boolean |
requiresArgument()
Does this option require an argument?
|
String |
toString() |
V |
value(OptionSet detectedOptions)
Gives the argument associated with the given option in the given set of detected options.
|
List<V> |
values(OptionSet detectedOptions)
Gives any arguments associated with the given option in the given set of detected options.
|
<T> NonOptionArgumentSpec<T> |
withValuesConvertedBy(ValueConverter<T> aConverter)
Specifies a converter to use to translate non-option arguments into Java objects.
|
public <T> NonOptionArgumentSpec<T> ofType(Class<T> argumentType)
Specifies a type to which the non-option arguments are to be converted.
JOpt Simple accepts types that have either:
valueOf which accepts a single argument of type String
and whose return type is the same as the class on which the method is declared. The java.lang
primitive wrapper classes have such methods.String.This class converts arguments using those methods in that order; that is, valueOf would be invoked
before a one-String-arg constructor would.
Invoking this method will trump any previous calls to this method or to
withValuesConvertedBy(ValueConverter).
T - represents the runtime class of the desired option argument typeargumentType - desired type of arguments to this spec's optionNullPointerException - if the type is nullIllegalArgumentException - if the type does not have the standard conversion methodspublic final <T> NonOptionArgumentSpec<T> withValuesConvertedBy(ValueConverter<T> aConverter)
Specifies a converter to use to translate non-option arguments into Java objects. This is useful
when converting to types that do not have the requisite factory method or constructor for
ofType(Class).
Invoking this method will trump any previous calls to this method or to ofType(Class).
T - represents the runtime class of the desired non-option argument typeaConverter - the converter to useNullPointerException - if the converter is nullpublic NonOptionArgumentSpec<V> describedAs(String description)
Specifies a description for the non-option arguments that this spec represents. This description is used when generating help information about the parser.
description - describes the nature of the argument of this spec's optionpublic List<?> defaultValues()
OptionDescriptorpublic boolean isRequired()
OptionDescriptorpublic boolean acceptsArguments()
OptionDescriptorpublic boolean requiresArgument()
OptionDescriptorpublic String argumentDescription()
OptionDescriptorpublic String argumentTypeIndicator()
OptionDescriptorpublic boolean representsNonOptions()
OptionDescriptorrepresentsNonOptions in interface OptionDescriptortrue if this represents non-option argumentspublic final Collection<String> options()
OptionDescriptoroptions in interface OptionDescriptoroptions in interface OptionSpec<V>public final List<V> values(OptionSet detectedOptions)
OptionSpecSpecifying a default argument value for this option will cause this method to return that default value even if this option was not detected on the command line, or if this option can take an optional argument but did not have one on the command line.
values in interface OptionSpec<V>detectedOptions - the detected options to search inOptionSet.valuesOf(OptionSpec)public final V value(OptionSet detectedOptions)
OptionSpecSpecifying a default argument value for this option will cause this method to return that default value even if this option was not detected on the command line, or if this option can take an optional argument but did not have one on the command line.
value in interface OptionSpec<V>detectedOptions - the detected options to search innull if no argument is present, or that option was not detectedOptionSet.valueOf(OptionSpec)public String description()
OptionDescriptordescription in interface OptionDescriptorpublic final joptsimple.AbstractOptionSpec<V> forHelp()
public final boolean isForHelp()
OptionSpecisForHelp in interface OptionSpec<V>protected V convertWith(ValueConverter<V> converter, String argument)
protected String argumentTypeIndicatorFrom(ValueConverter<V> converter)
Copyright © 2016. All rights reserved.