Class Arguments

java.lang.Object
edu.uky.ai.util.Arguments

public class Arguments extends Object
A more convenient representation of command line argument based on keys and values. A key is an argument that starts with a dash "-" character. Every other argument is considered a value.
Author:
Stephen G. Ware
  • Field Details

    • groups

      public final String[][] groups
      Arguments, divided into groups. Each group (except the first) begins with a key and contains all the values that follow that key. The first group is all values before the first key.
  • Constructor Details

    • Arguments

      public Arguments(String[] args)
      Constructs a new group of argument from an array of strings.
      Parameters:
      args - the command line arguments
  • Method Details

    • containsKey

      public boolean containsKey(String key)
      Checks whether a given key is present in the arguments.
      Parameters:
      key - the key to look for, including the initial dash
      Returns:
      true if the key is present, false otherwise
    • getValue

      public String getValue(String key)
      Returns the value immediately after a given key.
      Parameters:
      key - the key to look for, including the initial dash
      Returns:
      the value following the key
      Throws:
      IllegalArgumentException - if the key is not present, if there is no value after the key, or if there is more than one value after the key
    • getValues

      public String[] getValues(String key)
      Returns the values (0, 1, or many) immediately after a given key.
      Parameters:
      key - the key to look for, including the initial dash
      Returns:
      the values following the key
      Throws:
      IllegalArgumentException - if the key is not present