Package org.apache.commons.cli
Class PatternOptionBuilder
- java.lang.Object
-
- org.apache.commons.cli.PatternOptionBuilder
-
public class PatternOptionBuilder extends Object
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.
Overview of PatternOptionBuilder patterns a -a flag b@ -b [classname] c> -c [filename] d+ -d [classname] (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.
- Version:
- $Id: PatternOptionBuilder.java 1677406 2015-05-03 14:27:31Z britter $
-
-
Field Summary
Fields Modifier and Type Field Description static Class<?>CLASS_VALUEClass classstatic Class<Date>DATE_VALUEDate classstatic Class<FileInputStream>EXISTING_FILE_VALUEFileInputStream classstatic Class<File>FILE_VALUEFile classstatic Class<File[]>FILES_VALUEFile array classstatic Class<Number>NUMBER_VALUENumber classstatic Class<Object>OBJECT_VALUEObject classstatic Class<String>STRING_VALUEString classstatic Class<URL>URL_VALUEURL class
-
Constructor Summary
Constructors Constructor Description PatternOptionBuilder()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ObjectgetValueClass(char ch)Retrieve the class thatchrepresents.static booleanisValueCode(char ch)Returns whetherchis a value code, i.e.static OptionsparsePattern(String pattern)Returns theOptionsinstance represented bypattern.
-
-
-
Field Detail
-
CLASS_VALUE
public static final Class<?> CLASS_VALUE
Class class
-
EXISTING_FILE_VALUE
public static final Class<FileInputStream> EXISTING_FILE_VALUE
FileInputStream class
-
-
Method Detail
-
getValueClass
public static Object getValueClass(char ch)
Retrieve the class thatchrepresents.- Parameters:
ch- the specified character- Returns:
- The class that
chrepresents
-
isValueCode
public static boolean isValueCode(char ch)
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.
-
-