V - represents the type of the non-option argumentspublic class NonOptionArgumentSpec<V> extends AbstractOptionSpec<V>
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 V |
convert(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.
|
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.
|
boolean |
representsNonOptions()
Tells whether this object represents the non-option arguments of a command line.
|
boolean |
requiresArgument()
Does this option require an argument?
|
<T> NonOptionArgumentSpec<T> |
withValuesConvertedBy(ValueConverter<T> aConverter)
Specifies a converter to use to translate non-option arguments into Java objects.
|
argumentTypeIndicatorFrom, convertWith, description, equals, forHelp, hashCode, isForHelp, options, toString, value, valuespublic <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 optionprotected final V convert(String argument)
convert in class AbstractOptionSpec<V>public List<?> defaultValues()
OptionDescriptorpublic boolean isRequired()
OptionDescriptorpublic boolean acceptsArguments()
OptionDescriptorpublic boolean requiresArgument()
OptionDescriptorpublic String argumentDescription()
OptionDescriptorpublic String argumentTypeIndicator()
OptionDescriptorpublic boolean representsNonOptions()
OptionDescriptorrepresentsNonOptions in interface OptionDescriptorrepresentsNonOptions in class AbstractOptionSpec<V>true if this represents non-option argumentsCopyright © 2017. All Rights Reserved.