Package org.apache.commons.cli
Class PatternOptionBuilder
java.lang.Object
org.apache.commons.cli.PatternOptionBuilder
Allows Options to be created from a single String. The pattern contains various single character flags and via an
optional punctuation character, their expected type.
| a | -a flag |
| b@ | -b [class name] |
| c> | -c [file name] |
| d+ | -d [class name] (creates object via empty constructor) |
| e% | -e [number] (creates Double/Long instance depending on existing of a '.') |
| f/ | -f [URL] |
| g: | -g [string] |
For example, the following allows command line flags of '-v -p string-value -f /dir/file'. The exclamation mark precede a mandatory option.
Options options = PatternOptionBuilder.parsePattern("vp:!f/");
TODO These need to break out to OptionType and also to be pluggable.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Class<?>Class classDate classstatic final Class<FileInputStream>FileInputStream classFile classFile array classNumber classObject classString classURL class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectgetValueClass(char ch) Deprecated.static Class<?>getValueType(char ch) Retrieve the class thatchrepresents.static booleanisValueCode(char ch) Returns whetherchis a value code, i.e. whether it represents a class in a pattern.static OptionsparsePattern(String pattern) Returns theOptionsinstance represented bypattern.
-
Field Details
-
STRING_VALUE
String class -
OBJECT_VALUE
Object class -
NUMBER_VALUE
Number class -
DATE_VALUE
Date class -
CLASS_VALUE
Class class -
EXISTING_FILE_VALUE
FileInputStream class -
FILE_VALUE
File class -
FILES_VALUE
File array class -
URL_VALUE
URL class
-
-
Constructor Details
-
PatternOptionBuilder
public PatternOptionBuilder()
-
-
Method Details
-
getValueClass
Deprecated.Retrieve the class thatchrepresents.- Parameters:
ch- the specified character- Returns:
- The class that
chrepresents
-
getValueType
Retrieve the class thatchrepresents.- Parameters:
ch- the specified character- Returns:
- The class that
chrepresents - Since:
- 1.7.0
-
isValueCode
Returns whetherchis a value code, i.e. whether it represents a class in a pattern.- Parameters:
ch- the specified character- Returns:
- true if
chis a value code, otherwise false.
-
parsePattern
Returns theOptionsinstance represented bypattern.- Parameters:
pattern- the pattern string- Returns:
- The
Optionsinstance
-
getValueType(char)