mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-18 15:24:13 +01:00
resulved conflict
This commit is contained in:
@@ -21,6 +21,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.text.StrLookup;
|
||||||
|
import org.apache.commons.lang3.text.StrSubstitutor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple pojo to hold data related to a Maven POM file.
|
* A simple pojo to hold data related to a Maven POM file.
|
||||||
*
|
*
|
||||||
@@ -307,29 +310,27 @@ public class Model {
|
|||||||
* @return the interpolated text.
|
* @return the interpolated text.
|
||||||
*/
|
*/
|
||||||
public static String interpolateString(String text, Properties properties) {
|
public static String interpolateString(String text, Properties properties) {
|
||||||
final Properties props = properties;
|
if (null == text || null == properties) {
|
||||||
if (text == null || props == null) {
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
final StrSubstitutor substitutor = new StrSubstitutor(new PropertyLookup(properties));
|
||||||
|
return substitutor.replace(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility class that can provide values from a Properties object to a StrSubstitutor.
|
||||||
|
*/
|
||||||
|
private static class PropertyLookup extends StrLookup {
|
||||||
|
|
||||||
|
private final Properties props;
|
||||||
|
|
||||||
|
public PropertyLookup(Properties props) {
|
||||||
|
this.props = props;
|
||||||
|
}
|
||||||
|
|
||||||
final int pos = text.indexOf("${");
|
@Override
|
||||||
if (pos < 0) {
|
public String lookup(String key) {
|
||||||
return text;
|
return props.getProperty(key);
|
||||||
}
|
}
|
||||||
final int end = text.indexOf('}', pos + 2);
|
|
||||||
if (end < pos) {
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String propName = text.substring(pos + 2, end);
|
|
||||||
String propValue = interpolateString(props.getProperty(propName), props);
|
|
||||||
if (propValue == null) {
|
|
||||||
propValue = "";
|
|
||||||
}
|
|
||||||
final StringBuilder sb = new StringBuilder(propValue.length() + text.length());
|
|
||||||
sb.append(text.subSequence(0, pos))
|
|
||||||
.append(propValue)
|
|
||||||
.append(text.substring(end + 1));
|
|
||||||
return interpolateString(sb.toString(), props); //yes yes, this should be a loop...
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user