List of usage examples for org.apache.commons.lang3.text StrSubstitutor StrSubstitutor
public StrSubstitutor(final StrLookup<?> variableResolver)
From source file:de.britter.beyondstringutils.StrSubstitutorExample.java
public static void main(String[] args) { Map<String, String> values = singletonMap("key", "a value"); String tmpl = "Replacing ${key} & fallbacks ${undefined:-1234}"; StrSubstitutor sub = new StrSubstitutor(values); String replaced = sub.replace(tmpl); System.out.println(replaced); }
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:mamo.vanillaVotifier.utils.SubstitutionUtils.java
@NotNull public static StrSubstitutor buildStrSubstitutor(@Nullable Entry<String, Object>... substitutions) { HashMap<String, Object> substitutionsMap = new HashMap<String, Object>(); if (substitutions != null) { for (Entry<String, Object> substitution : substitutions) { if (substitution.getValue() != null) { if (!(substitution.getValue() instanceof Throwable)) { substitutionsMap.put(substitution.getKey(), substitution.getValue()); } else { substitutionsMap.put(substitution.getKey(), ExceptionUtils.getStackTrace((Throwable) substitution.getValue())); }// www .jav a 2s.com } else { substitutionsMap.put(substitution.getKey(), ""); } } } return new StrSubstitutor(substitutionsMap); }
From source file:com.opensymphony.xwork2.config.providers.EnvsValueSubstitutor.java
public EnvsValueSubstitutor() { strSubstitutor = new StrSubstitutor(System.getenv()); strSubstitutor.setVariablePrefix("${env."); strSubstitutor.setVariableSuffix('}'); strSubstitutor.setValueDelimiter(":"); }
From source file:com.teradata.tempto.internal.configuration.ConfigurationVariableResolver.java
private Configuration resolveVariables(Configuration configuration, Map<String, ? extends Object> variables) { StrSubstitutor strSubstitutor = new StrSubstitutor(variables); return new MapConfiguration(resolveVariables(configuration, strSubstitutor)); }
From source file:io.anserini.doc.GenerateRegressionDocsTest.java
@Test public void main() throws Exception { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); URL resource = GenerateRegressionDocsTest.class.getResource("/regression/all.yaml"); DataModel data = mapper.readValue(Paths.get(resource.toURI()).toFile(), DataModel.class); //System.out.println(ReflectionToStringBuilder.toString(data, ToStringStyle.MULTI_LINE_STYLE)); for (String collection : data.getCollections().keySet()) { Map<String, String> valuesMap = new HashMap<>(); valuesMap.put("index_cmds", data.generateIndexingCommand(collection)); valuesMap.put("ranking_cmds", data.generateRankingCommand(collection)); valuesMap.put("eval_cmds", data.generateEvalCommand(collection)); valuesMap.put("effectiveness", data.generateEffectiveness(collection)); StrSubstitutor sub = new StrSubstitutor(valuesMap); URL template = GenerateRegressionDocsTest.class .getResource(String.format("/docgen/templates/%s.template", collection)); Scanner scanner = new Scanner(Paths.get(template.toURI()).toFile(), "UTF-8"); String text = scanner.useDelimiter("\\A").next(); scanner.close();//w w w .jav a 2 s . co m String resolvedString = sub.replace(text); FileUtils.writeStringToFile(new File(String.format("docs/experiments-%s.md", collection)), resolvedString, "UTF-8"); } }
From source file:com.ibasco.agql.core.AbstractWebApiRequest.java
public AbstractWebApiRequest(int apiVersion) { this.apiVersion = apiVersion; this.baseUrlParams = new HashMap<>(); this.substitutor = new StrSubstitutor(this.baseUrlParams); }
From source file:com.mesosphere.dcos.cassandra.executor.Main.java
@Override public void initialize(Bootstrap<CassandraExecutorConfiguration> bootstrap) { super.initialize(bootstrap); bootstrap.addBundle(new Java8Bundle()); bootstrap.setConfigurationSourceProvider( new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(), new StrSubstitutor(new EnvironmentVariableLookup(false)))); }
From source file:edu.isi.pegasus.common.util.VariableExpander.java
/** * Overloaded constructor// w w w . j av a 2 s . c o m * * @param map containing variable names and values that need to be expanded * @param caseSensitive boolean indicating whether you want lookups to be * case sensitive or not. */ public VariableExpander(Map<String, String> map, boolean caseSensitive) { mValuesMap = map; mExpander = new StrSubstitutor(map); mExpander.setVariableResolver(new CaseSensitiveStrLookup(this.mValuesMap, caseSensitive)); }
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); }