mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
use undeprecated substitutor
This commit is contained in:
parent
f26c8f436e
commit
5a3f4e6e8c
@ -15,7 +15,7 @@
|
|||||||
* /
|
* /
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.nosqlbench.engine.api.util;
|
package io.nosqlbench.engine.api.templating;
|
||||||
|
|
||||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||||
import org.apache.commons.text.StrLookup;
|
import org.apache.commons.text.StrLookup;
|
||||||
@ -28,19 +28,25 @@ import java.util.function.Function;
|
|||||||
public class StrInterpolator implements Function<String, String> {
|
public class StrInterpolator implements Function<String, String> {
|
||||||
|
|
||||||
private MultiMap multimap = new MultiMap();
|
private MultiMap multimap = new MultiMap();
|
||||||
private StringSubstitutor substitutor=
|
private StringSubstitutor substitutor =
|
||||||
new StringSubstitutor(multimap,"<<",">>",'\\')
|
new StringSubstitutor(multimap, "<<", ">>", '\\')
|
||||||
.setEnableSubstitutionInVariables(true);
|
.setEnableSubstitutionInVariables(true)
|
||||||
|
.setEnableUndefinedVariableException(true)
|
||||||
|
.setDisableSubstitutionInValues(true);
|
||||||
|
|
||||||
private StringSubstitutor substitutor2 =
|
private StringSubstitutor substitutor2 =
|
||||||
new StringSubstitutor(multimap, "TEMPLATE(", ")", '\\')
|
new StringSubstitutor(multimap, "TEMPLATE(", ")", '\\')
|
||||||
.setEnableSubstitutionInVariables(true);
|
.setEnableSubstitutionInVariables(true)
|
||||||
|
.setEnableUndefinedVariableException(true)
|
||||||
|
.setDisableSubstitutionInValues(true);
|
||||||
|
|
||||||
public StrInterpolator(ActivityDef... activityDefs) {
|
public StrInterpolator(ActivityDef... activityDefs) {
|
||||||
Arrays.stream(activityDefs)
|
Arrays.stream(activityDefs)
|
||||||
.map(ad -> ad.getParams().getStringStringMap())
|
.map(ad -> ad.getParams().getStringStringMap())
|
||||||
.forEach(multimap::add);
|
.forEach(multimap::add);
|
||||||
}
|
}
|
||||||
public StrInterpolator(Map<String,String> basicMap) {
|
|
||||||
|
public StrInterpolator(Map<String, String> basicMap) {
|
||||||
multimap.add(basicMap);
|
multimap.add(basicMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,14 +59,14 @@ public class StrInterpolator implements Function<String, String> {
|
|||||||
public String apply(String raw) {
|
public String apply(String raw) {
|
||||||
String after = substitutor.replace(substitutor2.replace(raw));
|
String after = substitutor.replace(substitutor2.replace(raw));
|
||||||
while (!after.equals(raw)) {
|
while (!after.equals(raw)) {
|
||||||
raw=after;
|
raw = after;
|
||||||
after = substitutor.replace(substitutor2.replace(raw));
|
after = substitutor.replace(substitutor2.replace(raw));
|
||||||
}
|
}
|
||||||
return after;
|
return after;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkedHashMap<String,String> getTemplateDetails(String input) {
|
public LinkedHashMap<String, String> getTemplateDetails(String input) {
|
||||||
LinkedHashMap<String,String> details = new LinkedHashMap<>();
|
LinkedHashMap<String, String> details = new LinkedHashMap<>();
|
||||||
|
|
||||||
return details;
|
return details;
|
||||||
}
|
}
|
||||||
@ -70,13 +76,13 @@ public class StrInterpolator implements Function<String, String> {
|
|||||||
private List<Map<String, String>> maps = new ArrayList<>();
|
private List<Map<String, String>> maps = new ArrayList<>();
|
||||||
private String warnPrefix = "UNSET";
|
private String warnPrefix = "UNSET";
|
||||||
|
|
||||||
public void add(Map<String,String> addedMap) {
|
public void add(Map<String, String> addedMap) {
|
||||||
maps.add(addedMap);
|
maps.add(addedMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String lookup(String key) {
|
public String lookup(String key) {
|
||||||
String defval=null;
|
String defval = null;
|
||||||
|
|
||||||
String[] parts = key.split("[:,]", 2);
|
String[] parts = key.split("[:,]", 2);
|
||||||
if (parts.length == 2) {
|
if (parts.length == 2) {
|
Loading…
Reference in New Issue
Block a user