Top Description Methods
jdk.internal.joptsimple

public Interface OptionDeclarer

Known Direct Implementers
jdk.internal.joptsimple.OptionParser
Imports
java.util.List

Trains the option parser. This interface aids integration that disposes declaration of options but not actual command-line parsing. Typical use is for another class to implement OptionDeclarer as a facade, forwarding calls to an OptionParser instance. Note that although this is an interface, the returned values of calls are concrete jopt-simple classes.
Author
Paul Holser
Since
4.6
See Also
OptionParser

Method Summary

Modifier and TypeMethod and Description
public OptionSpecBuilder

Returns:

an object that can be used to flesh out more detail about the option
accepts
(String
the option to recognize
option
)

Tells the parser to recognize the given option.

public OptionSpecBuilder

Returns:

an object that can be used to flesh out more detail about the option
accepts
(String
the option to recognize
option
,
String
a string that describes the purpose of the option. This is used when generating help information about the parser.
description
)

Tells the parser to recognize the given option.

public OptionSpecBuilder

Returns:

an object that can be used to flesh out more detail about the options
acceptsAll
(List<String>
the options to recognize and treat as synonymous
options
)

Tells the parser to recognize the given options, and treat them as synonymous.

public OptionSpecBuilder

Returns:

an object that can be used to flesh out more detail about the options
acceptsAll
(List<String>
the options to recognize and treat as synonymous
options
,
String
a string that describes the purpose of the option. This is used when generating help information about the parser.
description
)

Tells the parser to recognize the given options, and treat them as synonymous.

public void
allowsUnrecognizedOptions()

Tells the parser to treat unrecognized options as non-option arguments.

public NonOptionArgumentSpec<String>

Returns:

an object that can be used to flesh out more detail about the non-option arguments
nonOptions
()

Gives an object that represents an access point for non-option arguments on a command line.

public NonOptionArgumentSpec<String>

Returns:

an object that can be used to flesh out more detail about the non-option arguments
nonOptions
(String
a string that describes the purpose of the non-option arguments. This is used when generating help information about the parser.
description
)

Gives an object that represents an access point for non-option arguments on a command line.

public void
posixlyCorrect(boolean
true if the parser should behave "POSIX-ly correct"-ly
setting
)

Tells the parser whether or not to behave "POSIX-ly correct"-ly.

public void
recognizeAlternativeLongOptions(boolean
true if the parser is to recognize the special style of long options
recognize
)

Tells the parser either to recognize or ignore -W-style long options.

Method Detail

acceptsback to summary
public OptionSpecBuilder accepts(String option)

Tells the parser to recognize the given option.

This method returns an instance of OptionSpecBuilder to allow the formation of parser directives as sentences in a fluent interface language. For example:


  OptionDeclarer parser = new OptionParser();
  parser.accepts( "c" ).withRequiredArg().ofType( Integer.class );

If no methods are invoked on the returned OptionSpecBuilder, then the parser treats the option as accepting no argument.

Parameters
option:String

the option to recognize

Returns:OptionSpecBuilder

an object that can be used to flesh out more detail about the option

Exceptions
OptionException:
if the option contains illegal characters
NullPointerException:
if the option is null
acceptsback to summary
public OptionSpecBuilder accepts(String option, String description)

Tells the parser to recognize the given option.

Parameters
option:String

the option to recognize

description:String

a string that describes the purpose of the option. This is used when generating help information about the parser.

Returns:OptionSpecBuilder

an object that can be used to flesh out more detail about the option

Exceptions
OptionException:
if the option contains illegal characters
NullPointerException:
if the option is null
See Also
accepts(String)
acceptsAllback to summary
public OptionSpecBuilder acceptsAll(List<String> options)

Tells the parser to recognize the given options, and treat them as synonymous.

Parameters
options:List<String>

the options to recognize and treat as synonymous

Returns:OptionSpecBuilder

an object that can be used to flesh out more detail about the options

Exceptions
OptionException:
if any of the options contain illegal characters
NullPointerException:
if the option list or any of its elements are null
See Also
accepts(String)
acceptsAllback to summary
public OptionSpecBuilder acceptsAll(List<String> options, String description)

Tells the parser to recognize the given options, and treat them as synonymous.

Parameters
options:List<String>

the options to recognize and treat as synonymous

description:String

a string that describes the purpose of the option. This is used when generating help information about the parser.

Returns:OptionSpecBuilder

an object that can be used to flesh out more detail about the options

Exceptions
OptionException:
if any of the options contain illegal characters
NullPointerException:
if the option list or any of its elements are null
IllegalArgumentException:
if the option list is empty
See Also
acceptsAll(List)
allowsUnrecognizedOptionsback to summary
public void allowsUnrecognizedOptions()

Tells the parser to treat unrecognized options as non-option arguments.

If not called, then the parser raises an OptionException when it encounters an unrecognized option.

nonOptionsback to summary
public NonOptionArgumentSpec<String> nonOptions()

Gives an object that represents an access point for non-option arguments on a command line.

Returns:NonOptionArgumentSpec<String>

an object that can be used to flesh out more detail about the non-option arguments

nonOptionsback to summary
public NonOptionArgumentSpec<String> nonOptions(String description)

Gives an object that represents an access point for non-option arguments on a command line.

Parameters
description:String

a string that describes the purpose of the non-option arguments. This is used when generating help information about the parser.

Returns:NonOptionArgumentSpec<String>

an object that can be used to flesh out more detail about the non-option arguments

See Also
nonOptions()
posixlyCorrectback to summary
public void posixlyCorrect(boolean setting)

Tells the parser whether or not to behave "POSIX-ly correct"-ly.

Parameters
setting:boolean

true if the parser should behave "POSIX-ly correct"-ly

recognizeAlternativeLongOptionsback to summary
public void recognizeAlternativeLongOptions(boolean recognize)

Tells the parser either to recognize or ignore -W-style long options.

Parameters
recognize:boolean

true if the parser is to recognize the special style of long options