public class Converter extends Object
convert(String)| Modifier and Type | Field and Description |
|---|---|
static ValueConverter |
BOOLEAN
Converter for booleans
|
static Map<String,ValueConverter> |
CONVERTERS
The default type to value converter map
|
static ValueConverter |
DATE
Converter for ISO 8601 formatted dates/times.
|
static ValueConverter |
EPOCH
Converter for epoch millisecond timestamps
|
static ValueConverter |
GLOB |
static ValueConverter |
ISODATE
Converter for ISO 8601 formatted dates/times.
|
static ValueConverter |
NUMBER
Converter for numbers
|
static ValueConverter |
REGEX
Converts a string to a case sensitive regex Pattern
|
static ValueConverter |
REGEX_I
Converts a string to a case insensitive regex Pattern
|
static ValueConverter |
STRING
String converter
|
| Constructor and Description |
|---|
Converter()
Creates a new converter using the auto value converter as default
|
Converter(Map<String,ValueConverter> converterMap)
Creates a new converter using the auto value converter as default and the given type conversion map
|
Converter(ValueConverter defaultConverter)
Creates a new converter using the given value converter as default
|
Converter(ValueConverter defaultConverter,
Map<String,ValueConverter> converterMap)
Creates a new converter with the given default value converter and type conversion map
|
| Modifier and Type | Method and Description |
|---|---|
Object |
convert(String input)
Converts the string input into a Java object.
|
public static final ValueConverter NUMBER
public static final ValueConverter EPOCH
public static final ValueConverter ISODATE
public static final ValueConverter DATE
public static final ValueConverter BOOLEAN
public static final ValueConverter STRING
public static final ValueConverter REGEX_I
public static final ValueConverter REGEX
public static final ValueConverter GLOB
public static final Map<String,ValueConverter> CONVERTERS
public Converter()
public Converter(ValueConverter defaultConverter)
defaultConverter - the default value converterpublic Converter(Map<String,ValueConverter> converterMap)
converterMap - auto conversion map, maps types e.g. 'date' to a value converterpublic Converter(ValueConverter defaultConverter, Map<String,ValueConverter> converterMap)
defaultConverter - the default value converterconverterMap - auto conversion map, maps types e.g. 'date' to a value converterpublic Object convert(String input) throws ConverterException
Converts the string input into a Java object. The part before the colon denotes the type and is used to find a suitable value converter. If no type is specified the default automatic converter will try to automatically convert the string to a suitable Java object.
As the colon delimits the type from the value, colons in a value should be percent encoded
input - eg 'john', 'date:2015-01-01' or 'number:30'ConverterExceptionCopyright © 2016 Jared Wiltshire. All rights reserved.