Java Code Examples for org.apache.commons.configuration2.interpol.ConfigurationInterpolator#interpolate()

The following examples show how to use org.apache.commons.configuration2.interpol.ConfigurationInterpolator#interpolate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractDeployer.java    From studio with GNU General Public License v3.0 5 votes vote down vote up
protected void addChildParams(Map<String, Object> childParams, ImmutableNode parentNode,
                              ConfigurationInterpolator interpolator) {
    for (ImmutableNode childParamNode : parentNode.getChildren()) {
        if (childParamNode.getChildren().isEmpty()) {
            Object value = interpolator.interpolate(childParamNode.getValue());
            MapUtils.add(childParams, childParamNode.getNodeName(), value);
        } else {
            Map<String, Object> params = new LinkedHashMap<>();
            addChildParams(params, childParamNode, interpolator);

            MapUtils.add(childParams, childParamNode.getNodeName(), params);
        }
    }
}
 
Example 2
Source File: XMLBeanDeclaration.java    From commons-configuration with Apache License 2.0 3 votes vote down vote up
/**
 * Performs interpolation for the specified value. This implementation will
 * interpolate against the current subnode configuration's parent. If sub
 * classes need a different interpolation mechanism, they should override
 * this method.
 *
 * @param value the value that is to be interpolated
 * @return the interpolated value
 */
protected Object interpolate(final Object value)
{
    final ConfigurationInterpolator interpolator =
            getConfiguration().getInterpolator();
    return interpolator != null ? interpolator.interpolate(value) : value;
}
 
Example 3
Source File: DefaultConversionHandler.java    From commons-configuration with Apache License 2.0 3 votes vote down vote up
/**
 * Extracts a single value from a complex object. This method is called by
 * {@code convert()} if the source object is complex. This implementation
 * extracts the first value from the complex object and returns it.
 *
 * @param container the complex object
 * @param targetCls the target class of the conversion
 * @param ci the {@code ConfigurationInterpolator} (not <b>null</b>)
 * @return the value to be converted (may be <b>null</b> if no values are
 *         found)
 */
protected Object extractConversionValue(final Object container,
        final Class<?> targetCls, final ConfigurationInterpolator ci)
{
    final Collection<?> values = extractValues(container, 1);
    return values.isEmpty() ? null : ci.interpolate(values.iterator()
            .next());
}
 
Example 4
Source File: AbstractConfiguration.java    From commons-configuration with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the interpolated value. This implementation delegates to the
 * current {@code ConfigurationInterpolator}. If no
 * {@code ConfigurationInterpolator} is set, the passed in value is returned
 * without changes.
 *
 * @param value the value to interpolate
 * @return the value with variables substituted
 */
protected Object interpolate(final Object value)
{
    final ConfigurationInterpolator ci = getInterpolator();
    return ci != null ? ci.interpolate(value) : value;
}