Package org.ldaptive.props
Class PropertyValueParser
- java.lang.Object
-
- org.ldaptive.props.PropertyValueParser
-
- Direct Known Subclasses:
CredentialConfigParser
public class PropertyValueParser extends java.lang.Object
Parses the configuration data associated with classes that contain setter properties. The format of the property string should be like:MyClass{{propertyOne=foo}{propertyTwo=bar}}
If the class name is supplied to the constructor, the property string need not contain the class declaration.
- Author:
- Middleware Services
-
-
Field Summary
Fields Modifier and Type Field Description 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.protected static java.util.regex.Pattern
PROPERTY_PATTERN
Pattern for finding properties.
-
Constructor Summary
Constructors Modifier Constructor 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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)
InvokessetClassName(String)
andinitializeProperties(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.
-
-
-
Field Detail
-
CONFIG_PATTERN
protected static final java.util.regex.Pattern CONFIG_PATTERN
Property string containing configuration.
-
PARAMS_ONLY_CONFIG_PATTERN
protected static final java.util.regex.Pattern PARAMS_ONLY_CONFIG_PATTERN
Property string for configuring a config where the class is known.
-
PROPERTY_PATTERN
protected static final java.util.regex.Pattern PROPERTY_PATTERN
Pattern for finding properties.
-
logger
protected final org.slf4j.Logger logger
Logger for this class.
-
-
Constructor Detail
-
PropertyValueParser
protected PropertyValueParser()
Default constructor.
-
PropertyValueParser
public PropertyValueParser(java.lang.String config)
Creates a new config parser.- Parameters:
config
- containing configuration data
-
PropertyValueParser
public PropertyValueParser(java.lang.String config, java.lang.String clazz)
Creates a new config parser.- Parameters:
config
- containing configuration dataclazz
- fully qualified class name
-
-
Method Detail
-
initialize
protected void initialize(java.lang.String clazz, java.lang.String props)
InvokessetClassName(String)
andinitializeProperties(Matcher)
.- Parameters:
clazz
- type to create and initializeprops
- to set on the class
-
initializeProperties
protected void initializeProperties(java.util.regex.Matcher matcher)
Finds all the matches in the supplied matcher puts them into the properties map. Properties are split on '='.- Parameters:
matcher
- to find matches
-
getClassName
public java.lang.String getClassName()
Returns the class name of the object to initialize.- Returns:
- class name
-
setClassName
protected void setClassName(java.lang.String name)
Sets the class name of the object to initialize.- Parameters:
name
- of the object class type
-
getProperties
public java.util.Map<java.lang.String,java.lang.String> getProperties()
Returns the properties from the configuration.- Returns:
- map of property name to value
-
isConfig
public static boolean isConfig(java.lang.String config)
Returns whether the supplied configuration data contains a config.- Parameters:
config
- containing configuration data- Returns:
- whether the supplied configuration data contains a config
-
isParamsOnlyConfig
public static boolean isParamsOnlyConfig(java.lang.String config)
Returns whether the supplied configuration data contains a params only config.- Parameters:
config
- containing configuration data- Returns:
- whether the supplied configuration data contains a params only config
-
initializeType
public java.lang.Object initializeType()
Initialize an instance of the class type with the properties contained in this config.- Returns:
- object of the type the config parsed
-
setProperties
protected void setProperties(java.lang.Class<?> c, java.lang.Object o)
Sets the properties on the supplied object.- Parameters:
c
- type of the supplied objecto
- to invoke properties on
-
-