Package edu.uky.ai.util
Class Arguments
java.lang.Object
edu.uky.ai.util.Arguments
public class Arguments
extends java.lang.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 Summary
Fields Modifier and Type Field Description java.lang.String[][]
groups
Arguments, divided into groups. -
Constructor Summary
Constructors Constructor Description Arguments(java.lang.String[] args)
Constructs a new group of argument from an array of strings. -
Method Summary
Modifier and Type Method Description boolean
containsKey(java.lang.String key)
Checks whether a given key is present in the arguments.java.lang.String
getValue(java.lang.String key)
Returns the value immediately after a given key.java.lang.String[]
getValues(java.lang.String key)
Returns the values (0, 1, or many) immediately after a given key.
-
Field Details
-
groups
public final java.lang.String[][] groupsArguments, 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(java.lang.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(java.lang.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 java.lang.String getValue(java.lang.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:
java.lang.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 java.lang.String[] getValues(java.lang.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:
java.lang.IllegalArgumentException
- if the key is not present
-