Package org.apache.commons.cli
Class OptionValidator
java.lang.Object
org.apache.commons.cli.OptionValidator
Validates an Option string.
- Since:
- 1.1
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleanisValidChar(char c) Returns whether the specified character is a valid character.private static booleanisValidOpt(char c) Returns whether the specified character is a valid Option.(package private) static StringValidates whetheroptis a permissible Option shortOpt.
-
Constructor Details
-
OptionValidator
OptionValidator()
-
-
Method Details
-
isValidChar
private static boolean isValidChar(char c) Returns whether the specified character is a valid character.- Parameters:
c- the character to validate- Returns:
- true if
cis a letter.
-
isValidOpt
private static boolean isValidOpt(char c) Returns whether the specified character is a valid Option.- Parameters:
c- the option to validate- Returns:
- true if
cis a letter, '?' or '@', otherwise false.
-
validate
Validates whetheroptis a permissible Option shortOpt. The rules that specify if theoptis valid are:- a single character
optthat is either ' '(special case), '?', '@' or a letter - a multi character
optthat only contains letters.
In case
optisnullno further validation is performed.- Parameters:
option- The option string to validate, may be null- Throws:
IllegalArgumentException- if the Option is not valid.
- a single character
-