Top Description Fields Constructors Methods
jdk.internal.joptsimple

public Class NonOptionArgumentSpec<V>

extends AbstractOptionSpec<V>
Class Inheritance
Type Parameters
<V>
represents the type of the non-option arguments
Imports
java.util.List

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.

Author
Paul Holser

Field Summary

Modifier and TypeField and Description
private String
private ValueConverter<V>
pack-priv static final String

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
public String
public String
argumentTypeIndicator()

Implements jdk.internal.joptsimple.OptionDescriptor.argumentTypeIndicator.

Gives an indication of the expected type of the option's argument.

protected final V
public List<?>
defaultValues()

Implements jdk.internal.joptsimple.OptionDescriptor.defaultValues.

What values will the option take if none are specified on the command line?

public NonOptionArgumentSpec<V>

Returns:

self, so that the caller can add clauses to the fluent interface sentence
describedAs
(String
describes the nature of the argument of this spec's option
description
)

Specifies a description for the non-option arguments that this spec represents.

pack-priv void
handleOption(OptionParser parser, ArgumentList arguments, OptionSet detectedOptions, String detectedArgument)

Implements abstract jdk.internal.joptsimple.AbstractOptionSpec.handleOption.

public boolean
isRequired()

Implements jdk.internal.joptsimple.OptionDescriptor.isRequired.

Is this option required on a command line?

public <
represents the runtime class of the desired option argument type
T
>
NonOptionArgumentSpec<T>

Returns:

self, so that the caller can add clauses to the fluent interface sentence
ofType
(Class<T>
desired type of arguments to this spec's option
argumentType
)

Specifies a type to which the non-option arguments are to be converted.

public boolean
representsNonOptions()

Overrides jdk.internal.joptsimple.AbstractOptionSpec.representsNonOptions.

Implements jdk.internal.joptsimple.OptionDescriptor.representsNonOptions.

Tells whether this object represents the non-option arguments of a command line.

public boolean
public final <
represents the runtime class of the desired non-option argument type
T
>
NonOptionArgumentSpec<T>

Returns:

self, so that the caller can add clauses to the fluent interface sentence
withValuesConvertedBy
(ValueConverter<T>
the converter to use
aConverter
)

Specifies a converter to use to translate non-option arguments into Java objects.

Inherited from jdk.internal.joptsimple.AbstractOptionSpec:
argumentTypeIndicatorFromconvertWithdescriptionequalsforHelphashCodeisForHelpoptionstoStringvaluevalues

Field Detail

argumentDescriptionback to summary
private String argumentDescription
converterback to summary
private ValueConverter<V> converter
NAMEback to summary
pack-priv static final String NAME

Constructor Detail

NonOptionArgumentSpecback to summary
pack-priv NonOptionArgumentSpec()
NonOptionArgumentSpecback to summary
pack-priv NonOptionArgumentSpec(String description)

Method Detail

acceptsArgumentsback to summary
public boolean acceptsArguments()

Implements jdk.internal.joptsimple.OptionDescriptor.acceptsArguments.

Doc from jdk.internal.joptsimple.OptionDescriptor.acceptsArguments.

Does this option accept arguments?

Returns:boolean

whether the option accepts arguments

argumentDescriptionback to summary
public String argumentDescription()

Implements jdk.internal.joptsimple.OptionDescriptor.argumentDescription.

Doc from jdk.internal.joptsimple.OptionDescriptor.argumentDescription.

Gives a short description of the option's argument.

Returns:String

a description for the option's argument

argumentTypeIndicatorback to summary
public String argumentTypeIndicator()

Implements jdk.internal.joptsimple.OptionDescriptor.argumentTypeIndicator.

Doc from jdk.internal.joptsimple.OptionDescriptor.argumentTypeIndicator.

Gives an indication of the expected type of the option's argument.

Returns:String

a description for the option's argument type

convertback to summary
protected final V convert(String argument)

Implements abstract jdk.internal.joptsimple.AbstractOptionSpec.convert.

Annotations
@Override
defaultValuesback to summary
public List<?> defaultValues()

Implements jdk.internal.joptsimple.OptionDescriptor.defaultValues.

Doc from jdk.internal.joptsimple.OptionDescriptor.defaultValues.

What values will the option take if none are specified on the command line?

Returns:List<?>

any default values for the option

describedAsback to summary
public 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.

Parameters
description:String

describes the nature of the argument of this spec's option

Returns:NonOptionArgumentSpec<V>

self, so that the caller can add clauses to the fluent interface sentence

handleOptionback to summary
pack-priv void handleOption(OptionParser parser, ArgumentList arguments, OptionSet detectedOptions, String detectedArgument)

Implements abstract jdk.internal.joptsimple.AbstractOptionSpec.handleOption.

Annotations
@Override
isRequiredback to summary
public boolean isRequired()

Implements jdk.internal.joptsimple.OptionDescriptor.isRequired.

Doc from jdk.internal.joptsimple.OptionDescriptor.isRequired.

Is this option required on a command line?

Returns:boolean

whether the option is required

ofTypeback to summary
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:

  1. a public static method called 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.
  2. a public constructor which accepts a single argument of type 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).

Parameters
<T>
represents the runtime class of the desired option argument type
argumentType:Class<T>

desired type of arguments to this spec's option

Returns:NonOptionArgumentSpec<T>

self, so that the caller can add clauses to the fluent interface sentence

Annotations
@SuppressWarnings:unchecked
Exceptions
NullPointerException:
if the type is null
IllegalArgumentException:
if the type does not have the standard conversion methods
representsNonOptionsback to summary
public boolean representsNonOptions()

Overrides jdk.internal.joptsimple.AbstractOptionSpec.representsNonOptions.

Implements jdk.internal.joptsimple.OptionDescriptor.representsNonOptions.

Doc from jdk.internal.joptsimple.OptionDescriptor.representsNonOptions.

Tells whether this object represents the non-option arguments of a command line.

Returns:boolean

true if this represents non-option arguments

requiresArgumentback to summary
public boolean requiresArgument()

Implements jdk.internal.joptsimple.OptionDescriptor.requiresArgument.

Doc from jdk.internal.joptsimple.OptionDescriptor.requiresArgument.

Does this option require an argument?

Returns:boolean

whether the option requires an argument

withValuesConvertedByback to summary
public 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).

Parameters
<T>
represents the runtime class of the desired non-option argument type
aConverter:ValueConverter<T>

the converter to use

Returns:NonOptionArgumentSpec<T>

self, so that the caller can add clauses to the fluent interface sentence

Annotations
@SuppressWarnings:unchecked
Exceptions
NullPointerException:
if the converter is null