Class ArgHandlerFlag

java.lang.Object
com.google.gwt.util.tools.ArgHandler
com.google.gwt.util.tools.ArgHandlerFlag
Direct Known Subclasses:
ArgHandlerIgnore, ArgHandlerOverwrite

public abstract class ArgHandlerFlag extends ArgHandler
Argument handler for boolean flags that have no parameters. Supports toggling the boolean value on and off using -label and -nolabel tag variants and calculating a meaningful purpose including default value.
  • Constructor Details

    • ArgHandlerFlag

      public ArgHandlerFlag()
  • Method Details

    • addTagValue

      protected void addTagValue(String tag, boolean value)
    • getDefaultValue

      public abstract boolean getDefaultValue()
      Returns the default value that will appear in help messages.
    • getHelpTag

      public String getHelpTag()
      Description copied from class: ArgHandler
      The tag to display in help messages.
      Overrides:
      getHelpTag in class ArgHandler
    • getLabel

      public String getLabel()
      The root String that will be munged into -label and -nolabel variants for flag value toggling. Should follow the verb[Adjective]Noun naming pattern. For example:
    • getPurpose

      public final String getPurpose()
      Specified by:
      getPurpose in class ArgHandler
    • getPurposeSnippet

      public abstract String getPurposeSnippet()
      Returns a description that will be mixed together with default value to come up with the overall flag purpose.
    • getTag

      public final String getTag()
      The primary tag matched by this argument handler.
      Specified by:
      getTag in class ArgHandler
    • getTagArgs

      public String[] getTagArgs()
      Description copied from class: ArgHandler
      A list of words representing the arguments in help text.
      Specified by:
      getTagArgs in class ArgHandler
    • getTags

      public final String[] getTags()
      Description copied from class: ArgHandler
      The set of tags matched by this argument handler. By default includes just the one primary tag mentioned in getTag() but can be overridden to provide broader matching.
      Overrides:
      getTags in class ArgHandler
    • getValueByTag

      boolean getValueByTag(String tag)
    • handle

      public int handle(String[] args, int startIndex)
      Description copied from class: ArgHandler
      Attempts to process one flag or "extra" command-line argument (that appears without a flag).
      Specified by:
      handle in class ArgHandler
      Parameters:
      args - the arguments passed in to main()
      startIndex - an index into args indicating the first argument to use. If this is a handler for a flag argument. Otherwise it's the index of the "extra" argument.
      Returns:
      the number of additional arguments consumed, not including the flag or extra argument. Alternately, returns -1 if the argument cannot be used. This will causes the program to abort and usage to be displayed.
    • isRequired

      public boolean isRequired()
      Overrides:
      isRequired in class ArgHandler
    • setFlag

      public abstract boolean setFlag(boolean value)
      Takes the explicitly provided value and propagates it into whatever option settings this flag controls.
      Parameters:
      value - the new value for the flag.
      Returns:
      whether the assignment was valid.