Class StringOption

java.lang.Object
snaq.util.jclap.Option<String>
snaq.util.jclap.StringOption
Direct Known Subclasses:
FileOption

public class StringOption
extends Option<String>
Implementation of an Option with value of type String.
Author:
Giles Winstanley
  • Constructor Details

    • StringOption

      public StringOption​(String shortName, String longName, String description, int minCount, int maxCount)
      Creates a new StringOption instance.
      Parameters:
      shortName - short name of the option (e.g. -n)
      longName - long name of the option (e.g. --name)
      description - helpful description of the option (printed for usage message)
      minCount - minimum number of occurrences required for this option
      maxCount - maximum number of occurrences required for this option
    • StringOption

      public StringOption​(String shortName, String longName, String description, boolean mandatory, boolean allowMany)
      Creates a new StringOption instance.
      Parameters:
      shortName - short name of the option (e.g. -n)
      longName - long name of the option (e.g. --name)
      description - helpful description of the option (printed for usage message)
      mandatory - whether this option must be specified
      allowMany - whether this option can take more than one value (i.e. be specified more than once)
  • Method Details

    • parseValue

      protected String parseValue​(String arg, Locale locale) throws OptionException
      Parses the argument string for an option value, optionally using the specified locale for reference (e.g. for date parsing).
      Specified by:
      parseValue in class Option<String>
      Parameters:
      arg - string argument from which a value is to be parsed
      locale - locale as specified when initializing the CLAParser instance
      Returns:
      Value of the parsed argument string
      Throws:
      OptionException - if a problem occurs while parsing the argument string
    • setFilter

      public void setFilter​(StringOption.Filter filter)
      Sets the StringOption.Filter for this instance.
      Parameters:
      filter - Filter instance to use for accepting/rejecting values
    • getFilter

      public Optional<StringOption.Filter> getFilter()
      Returns the StringOption.Filter for this instance.
      Returns:
      optional Filter instance
    • getType

      public Class<String> getType()
      Returns the class type of value this option can take.
      Specified by:
      getType in class Option<String>
      Returns:
      Class instance