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.
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.
Modifier and Type | Field and Description |
---|---|
static Class<?> |
CLASS_VALUE
Class class
|
static Class<Date> |
DATE_VALUE
Date class
|
static Class<FileInputStream> |
EXISTING_FILE_VALUE
FileInputStream class
|
static Class<File> |
FILE_VALUE
File class
|
static Class<File[]> |
FILES_VALUE
File array class
|
static Class<Number> |
NUMBER_VALUE
Number class
|
static Class<Object> |
OBJECT_VALUE
Object class
|
static Class<String> |
STRING_VALUE
String class
|
static Class<URL> |
URL_VALUE
URL class
|
Constructor and Description |
---|
PatternOptionBuilder() |
Modifier and Type | Method and Description |
---|---|
static Object |
getValueClass(char ch)
Retrieve the class that
ch represents. |
static boolean |
isValueCode(char ch)
Returns whether
ch is a value code, i.e. |
static Options |
parsePattern(String pattern)
Returns the
Options instance represented by pattern . |
public static final Class<?> CLASS_VALUE
public static final Class<FileInputStream> EXISTING_FILE_VALUE
public static Object getValueClass(char ch)
ch
represents.ch
- the specified characterch
representspublic static boolean isValueCode(char ch)
ch
is a value code, i.e.
whether it represents a class in a pattern.ch
- the specified characterch
is a value code, otherwise false.Copyright © 2002–2017 The Apache Software Foundation. All rights reserved.