Package org.apache.commons.cli
Class OptionValidator
- java.lang.Object
-
- org.apache.commons.cli.OptionValidator
-
final class OptionValidator extends java.lang.ObjectValidates an Option string.- Since:
- 1.1
- Version:
- $Id: OptionValidator.java 1544819 2013-11-23 15:34:31Z tn $
-
-
Constructor Summary
Constructors Constructor Description OptionValidator()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private 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 voidvalidateOption(java.lang.String opt)Validates whetheroptis a permissible Option shortOpt.
-
-
-
Method Detail
-
validateOption
static void validateOption(java.lang.String opt) throws java.lang.IllegalArgumentExceptionValidates 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:
opt- The option string to validate, may be null- Throws:
java.lang.IllegalArgumentException- if the Option is not valid.
- a single character
-
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.
-
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.
-
-