public class ConfigurationParser extends Object
Modifier and Type | Field and Description |
---|---|
static String |
CLASS_ATTRIBUTE
Name of the bean implementation class configuration attribute.
|
static String |
NAME_ATTRIBUTE
Name of the bean parameter name configuration attribute.
|
static String |
PARAM_ELEMENT
Name of the bean parameter configuration element.
|
static String |
VALUE_ATTRIBUTE
Name of the bean parameter value configuration attribute.
|
Constructor and Description |
---|
ConfigurationParser(Properties variables)
Creates a new configuration parser with the given parser variables.
|
Modifier and Type | Method and Description |
---|---|
protected String |
getAttribute(Element element,
String name)
Returns the value of the named attribute of the given element.
|
protected String |
getAttribute(Element element,
String name,
String def)
Returns the value of the named attribute of the given element.
|
protected Element |
getElement(Element parent,
String name)
Returns the named child of the given parent element.
|
protected Element |
getElement(Element parent,
String name,
boolean required)
Returns the named child of the given parent element.
|
protected Element[] |
getElements(Element parent,
String name,
boolean required)
Returns the named child of the given parent element.
|
protected EntityResolver |
getEntityResolver()
Returns the entity resolver to be used when parsing configuration
documents.
|
protected ErrorHandler |
getErrorHandler()
Returns the error handler to be used when parsing configuration
documents.
|
Properties |
getVariables()
Returns the variables.
|
protected BeanConfig |
parseBeanConfig(Element element)
Parses a named bean configuration from the given element.
|
protected BeanConfig |
parseBeanConfig(Element parent,
String name)
Parses a named bean configuration from the given element.
|
protected Properties |
parseParameters(Element element)
Parses the configuration parameters of the given element.
|
protected Element |
parseXML(InputSource xml)
Parses the given XML document and returns the DOM root element.
|
protected Element |
parseXML(InputSource xml,
boolean validate)
Parses the given XML document and returns the DOM root element.
|
protected Document |
postParseModificationHook(Document document)
A post-processing hook for the parsed repository or workspace
configuration documents.
|
protected String |
replaceVariables(String value)
Performs variable replacement on the given string value.
|
public static final String PARAM_ELEMENT
public static final String CLASS_ATTRIBUTE
public static final String NAME_ATTRIBUTE
public static final String VALUE_ATTRIBUTE
public ConfigurationParser(Properties variables)
variables
- parser variablespublic Properties getVariables()
protected BeanConfig parseBeanConfig(Element parent, String name) throws ConfigurationException
<BeanName class="..."> <param name="..." value="..."/> ... </BeanName>
The returned bean configuration object contains the configured class name and configuration parameters. Variable replacement is performed on the parameter values.
parent
- parent elementname
- name of the bean configuration elementConfigurationException
- if the configuration element does not
exist or is brokenprotected BeanConfig parseBeanConfig(Element element) throws ConfigurationException
<BeanName class="..."> <param name="..." value="..."/> ... </BeanName>
The returned bean configuration object contains the configured class name and configuration parameters. Variable replacement is performed on the parameter values.
element
- ConfigurationException
- if the configuration element does not
exist or is brokenprotected Properties parseParameters(Element element) throws ConfigurationException
<param name="..." value="..."/>
child elements. This method parses all param elements,
performs variable replacement
on parameter values, and returns the resulting name-value pairs.element
- configuration elementConfigurationException
- if a param
element does
not contain the name
and
value
attributesprotected String replaceVariables(String value) throws ConfigurationException
${...}
sequence within the given value is replaced
with the value of the named parser variable. The replacement is not
done if the named variable does not exist.value
- original valueConfigurationException
- if the replacement of a referenced
variable is not foundprotected Element parseXML(InputSource xml) throws ConfigurationException
xml
- xml documentConfigurationException
- if the configuration document could
not be read or parsedConfigurationEntityResolver
protected ErrorHandler getErrorHandler()
protected EntityResolver getEntityResolver()
protected Document postParseModificationHook(Document document)
document
- the parsed configuration documentprotected Element parseXML(InputSource xml, boolean validate) throws ConfigurationException
xml
- xml documentvalidate
- whether the XML should be validatedConfigurationException
- if the configuration document could
not be read or parsedConfigurationEntityResolver
protected Element getElement(Element parent, String name) throws ConfigurationException
parent
- parent elementname
- name of the child elementConfigurationException
ConfigurationException
- if the child element is not foundprotected Element getElement(Element parent, String name, boolean required) throws ConfigurationException
parent
- parent elementname
- name of the child elementrequired
- indicates if the child element is requirednull
if not found and
required
is false
.ConfigurationException
- if the child element is not found and
required
is true
;
or if more than one element with this name exists.protected Element[] getElements(Element parent, String name, boolean required) throws ConfigurationException
parent
- parent elementname
- name of the child elementrequired
- indicates if the child element is requirednull
if not found and
required
is false
.ConfigurationException
- if the child element is not found and
required
is true
;
or if more than one element with this name exists.protected String getAttribute(Element element, String name) throws ConfigurationException
element
- elementname
- attribute nameConfigurationException
- if the attribute is not foundprotected String getAttribute(Element element, String name, String def)
element
- elementname
- attribute namedef
- default valueCopyright © 2004–2024 The Apache Software Foundation. All rights reserved.