public class PropertyValueParser extends Object
MyClass{{propertyOne=foo}{propertyTwo=bar}}
If the class name is supplied to the constructor, the property string need not contain the class declaration.
Modifier and Type | Field and Description |
---|---|
private String |
className
Class found in the config.
|
protected static Pattern |
CONFIG_PATTERN
Property string containing configuration.
|
protected Logger |
logger
Logger for this class.
|
protected static Pattern |
PARAMS_ONLY_CONFIG_PATTERN
Property string for configuring a config where the class is known.
|
private Map<String,String> |
properties
Properties found in the config to set on the class.
|
protected static Pattern |
PROPERTY_PATTERN
Pattern for finding properties.
|
Modifier | Constructor and Description |
---|---|
protected |
PropertyValueParser()
Default constructor.
|
|
PropertyValueParser(String config)
Creates a new config parser.
|
|
PropertyValueParser(String config,
String clazz)
Creates a new config parser.
|
Modifier and Type | Method and Description |
---|---|
String |
getClassName()
Returns the class name of the object to initialize.
|
Map<String,String> |
getProperties()
Returns the properties from the configuration.
|
protected void |
initialize(String clazz,
String props)
Invokes
setClassName(String) and initializeProperties(Matcher) . |
protected void |
initializeProperties(Matcher matcher)
Finds all the matches in the supplied matcher puts them into the properties map.
|
Object |
initializeType()
Initialize an instance of the class type with the properties contained in this config.
|
static boolean |
isConfig(String config)
Returns whether the supplied configuration data contains a config.
|
static boolean |
isParamsOnlyConfig(String config)
Returns whether the supplied configuration data contains a params only config.
|
protected void |
setClassName(String name)
Sets the class name of the object to initialize.
|
protected void |
setProperties(Class<?> c,
Object o)
Sets the properties on the supplied object.
|
protected static final Pattern CONFIG_PATTERN
protected static final Pattern PARAMS_ONLY_CONFIG_PATTERN
protected static final Pattern PROPERTY_PATTERN
protected final Logger logger
private String className
protected PropertyValueParser()
public PropertyValueParser(String config)
config
- containing configuration dataprotected void initialize(String clazz, String props)
setClassName(String)
and initializeProperties(Matcher)
.clazz
- type to create and initializeprops
- to set on the classprotected void initializeProperties(Matcher matcher)
matcher
- to find matchespublic String getClassName()
protected void setClassName(String name)
name
- of the object class typepublic Map<String,String> getProperties()
public static boolean isConfig(String config)
config
- containing configuration datapublic static boolean isParamsOnlyConfig(String config)
config
- containing configuration datapublic Object initializeType()
Copyright © 2003-2019 Virginia Tech. All Rights Reserved.