/** * <p> * First convert the supplied {@link Properties} into a {@link Map} and then * call {@link #substitute(String, Map)}. * </p> * * @param source * the string containing possible variable references * @param variablesAndValues * the {@link Map} to use to resolve the variables' values. * @return The updated source {@link String}. * @throws IllegalArgumentException * <ul> * <li>if the source {@link String} is null</li> * <li>if the {@link Map} of variables is null</li> * <li> * or if the source {@link String} references a variable which * doesn't exist in the variable {@link Map}.</li> * </ul> */ public static String substitute(String source, Properties variablesAndValues) { Validate.notNull(source, "The source cannot be null"); Validate.notNull(variablesAndValues, "The Properties cannot be null"); Map<String, String> map = new HashMap<String, String>(); for (String key : variablesAndValues.stringPropertyNames()) { map.put(key, variablesAndValues.getProperty(key)); } return substitute(source, map); }
/** * <p> * First convert the supplied {@link Properties} into a {@link Map} and then * call {@link #substitute(String, Map)}. * </p> * * @param source * the string containing possible variable references * @param variablesAndValues * the {@link Map} to use to resolve the variables' values. * @return The updated source {@link String}. * @throws IllegalArgumentException * <ul> * <li>if the source {@link String} is null</li> * <li>if the {@link Map} of variables is null</li> * <li> * or if the source {@link String} references a variable which * doesn't exist in the variable {@link Map}.</li> * </ul> */ public static String substitute(String source, Properties variablesAndValues) { Validate.notNull(source, "The source cannot be null"); Validate.notNull(variablesAndValues, "The Properties cannot be null"); Map<String, String> map = new HashMap<String, String>(); for (String key : variablesAndValues.stringPropertyNames()) { map.put(key, variablesAndValues.getProperty(key)); } return substitute(source, map); }
for (Entry<String, String> locationEntry : asu.getLocations().entrySet()) { locations.put(locationEntry.getKey(), StringUtils.substitute(locationEntry.getValue(), context.getConfiguration().getProperties()));
for (Entry<String, String> locationEntry : asu.getLocations().entrySet()) { locations.put(locationEntry.getKey(), StringUtils.substitute(locationEntry.getValue(), context.getConfiguration().getProperties()));