Class JOptCommandLinePropertySource

  • public class JOptCommandLinePropertySource
    extends CommandLinePropertySource<joptsimple.OptionSet>
    CommandLinePropertySource implementation backed by a JOpt OptionSet.

    Typical usage

    Configure and execute an OptionParser against the String[] of arguments supplied to the main method, and create a JOptCommandLinePropertySource using the resulting OptionSet object:
     public static void main(String[] args) {
         OptionParser parser = new OptionParser();
         OptionSet options = parser.parse(args);
           ps = new JOptCommandLinePropertySource(options);
         // ...
    See CommandLinePropertySource for complete general usage examples.

    Requires JOpt version 3.0 or higher. Tested against JOpt up until 4.6.

    Chris Beams, Juergen Hoeller
    See Also:
    CommandLinePropertySource, OptionParser, OptionSet
    • Method Detail

      • getOptionValues

        public List<String> getOptionValues(String name)
        Description copied from class: CommandLinePropertySource
        Return the collection of values associated with the command line option having the given name.
        • if the option is present and has no argument (e.g.: "--foo"), return an empty collection ([])
        • if the option is present and has a single value (e.g. "--foo=bar"), return a collection having one element (["bar"])
        • if the option is present and the underlying command line parsing library supports multiple arguments (e.g. "--foo=bar --foo=baz"), return a collection having elements for each value (["bar", "baz"])
        • if the option is not present, return null
        Specified by:
        getOptionValues in class  CommandLinePropertySource<joptsimple.OptionSet>