public class PropertyValueParser
extends java.lang.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 java.lang.String |
className
Class found in the config.
|
protected static java.util.regex.Pattern |
CONFIG_PATTERN
Property string containing configuration.
|
protected org.slf4j.Logger |
logger
Logger for this class.
|
protected static java.util.regex.Pattern |
PARAMS_ONLY_CONFIG_PATTERN
Property string for configuring a config where the class is known.
|
private java.util.Map<java.lang.String,java.lang.String> |
properties
Properties found in the config to set on the class.
|
protected static java.util.regex.Pattern |
PROPERTY_PATTERN
Pattern for finding properties.
|
| Modifier | Constructor and Description |
|---|---|
protected |
PropertyValueParser()
Default constructor.
|
|
PropertyValueParser(java.lang.String config)
Creates a new config parser.
|
|
PropertyValueParser(java.lang.String config,
java.lang.String clazz)
Creates a new config parser.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getClassName()
Returns the class name of the object to initialize.
|
java.util.Map<java.lang.String,java.lang.String> |
getProperties()
Returns the properties from the configuration.
|
protected void |
initialize(java.lang.String clazz,
java.lang.String props)
Invokes
setClassName(String) and initializeProperties(Matcher). |
protected void |
initializeProperties(java.util.regex.Matcher matcher)
Finds all the matches in the supplied matcher puts them into the properties map.
|
java.lang.Object |
initializeType()
Initialize an instance of the class type with the properties contained in this config.
|
static boolean |
isConfig(java.lang.String config)
Returns whether the supplied configuration data contains a config.
|
static boolean |
isParamsOnlyConfig(java.lang.String config)
Returns whether the supplied configuration data contains a params only config.
|
protected void |
setClassName(java.lang.String name)
Sets the class name of the object to initialize.
|
protected void |
setProperties(java.lang.Class<?> c,
java.lang.Object o)
Sets the properties on the supplied object.
|
protected static final java.util.regex.Pattern CONFIG_PATTERN
protected static final java.util.regex.Pattern PARAMS_ONLY_CONFIG_PATTERN
protected static final java.util.regex.Pattern PROPERTY_PATTERN
protected final org.slf4j.Logger logger
private java.lang.String className
private final java.util.Map<java.lang.String,java.lang.String> properties
protected PropertyValueParser()
public PropertyValueParser(java.lang.String config)
config - containing configuration datapublic PropertyValueParser(java.lang.String config,
java.lang.String clazz)
config - containing configuration dataclazz - fully qualified class nameprotected void initialize(java.lang.String clazz,
java.lang.String props)
setClassName(String) and initializeProperties(Matcher).clazz - type to create and initializeprops - to set on the classprotected void initializeProperties(java.util.regex.Matcher matcher)
matcher - to find matchespublic java.lang.String getClassName()
protected void setClassName(java.lang.String name)
name - of the object class typepublic java.util.Map<java.lang.String,java.lang.String> getProperties()
public static boolean isConfig(java.lang.String config)
config - containing configuration datapublic static boolean isParamsOnlyConfig(java.lang.String config)
config - containing configuration datapublic java.lang.Object initializeType()
protected void setProperties(java.lang.Class<?> c,
java.lang.Object o)
c - type of the supplied objecto - to invoke properties on