Example usage for org.apache.commons.lang3.text StrSubstitutor setEnableSubstitutionInVariables

List of usage examples for org.apache.commons.lang3.text StrSubstitutor setEnableSubstitutionInVariables

Introduction

In this page you can find the example usage for org.apache.commons.lang3.text StrSubstitutor setEnableSubstitutionInVariables.

Prototype

public void setEnableSubstitutionInVariables(final boolean enableSubstitutionInVariables) 

Source Link

Document

Sets a flag whether substitution is done in variable names.

Usage

From source file:io.fabric8.karaf.core.Support.java

public static StrSubstitutor createStrSubstitutor(String prefix, String suffix, StrLookup<String> lookup) {
    StrSubstitutor substitutor = new StrSubstitutor();
    substitutor.setEnableSubstitutionInVariables(true);
    substitutor.setVariablePrefix(prefix);
    substitutor.setVariableSuffix(suffix);
    substitutor.setVariableResolver(lookup);

    return substitutor;
}

From source file:com.cybernostics.jsp2thymeleaf.api.util.SimpleStringTemplateProcessor.java

public static StrSubstitutor getSubstitutor(StrLookup<String> variableResolver) {
    StrSubstitutor strSubstitutor = new StrSubstitutor(variableResolver);
    strSubstitutor.setEscapeChar('%');
    strSubstitutor.setVariablePrefix("%{");
    strSubstitutor.setEnableSubstitutionInVariables(false);
    return strSubstitutor;
}

From source file:io.openshift.launchpad.ReadmeProcessor.java

public String processTemplate(String template, Map<String, String> values) {
    StrSubstitutor strSubstitutor = new StrSubstitutor(values);
    strSubstitutor.setEnableSubstitutionInVariables(true);
    return strSubstitutor.replace(template);
}

From source file:com.thinkbiganalytics.feedmgr.nifi.PropertyExpressionResolverTest.java

@Test
public void testStrSubstitutor() {
    String template1 = "${metadata.feedName}_config.xx";
    Map<String, String> map1 = new HashMap<>();
    map1.put("metadata.feedName", "category.feed");
    StrSubstitutor ss1 = new StrSubstitutor(map1);
    ss1.setEnableSubstitutionInVariables(true);
    Assert.assertEquals("category.feed_config.xx", ss1.replace(template1));

    String template2 = "$${${metadata.feedName}_config.xx}";
    StrSubstitutor ss2 = new StrSubstitutor(map1);
    ss2.setEnableSubstitutionInVariables(true);
    Assert.assertEquals("${category.feed_config.xx}", ss2.replace(template2));

    String template3 = "${${metadata.feedName}_config.xx}";
    map1.put("category.feed_config.xx", "runtime value");
    StrSubstitutor ss3 = new StrSubstitutor(map1);
    ss3.setEnableSubstitutionInVariables(true);
    Assert.assertEquals("runtime value", ss3.replace(template3));

}