public class PatternOptionBuilder
extends java.lang.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 contructor) |
| e% | -e [number] (creates Double/Long instance depeding 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'.
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 java.lang.Class |
CLASS_VALUE
Class class
|
static java.lang.Class |
DATE_VALUE
Date class
|
static java.lang.Class |
EXISTING_FILE_VALUE
FileInputStream class
|
static java.lang.Class |
FILE_VALUE
File class
|
static java.lang.Class |
FILES_VALUE
File array class
|
static java.lang.Class |
NUMBER_VALUE
Number class
|
static java.lang.Class |
OBJECT_VALUE
Object class
|
static java.lang.Class |
STRING_VALUE
String class
|
static java.lang.Class |
URL_VALUE
URL class
|
| Constructor and Description |
|---|
PatternOptionBuilder() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.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(java.lang.String pattern)
Returns the
Options instance represented by
pattern. |
public static final java.lang.Class STRING_VALUE
public static final java.lang.Class OBJECT_VALUE
public static final java.lang.Class NUMBER_VALUE
public static final java.lang.Class DATE_VALUE
public static final java.lang.Class CLASS_VALUE
public static final java.lang.Class EXISTING_FILE_VALUE
public static final java.lang.Class FILE_VALUE
public static final java.lang.Class FILES_VALUE
public static final java.lang.Class URL_VALUE
public static java.lang.Object getValueClass(char ch)
Retrieve the class that ch represents.
ch - the specified characterch representspublic static boolean isValueCode(char ch)
Returns whether 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.