commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Arend v. Reinersdorff (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (TEXT-74) StrSubstitutor: Ability to turn off substitution in values
Date Thu, 13 Jul 2017 19:21:00 GMT

     [ https://issues.apache.org/jira/browse/TEXT-74?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Arend v. Reinersdorff updated TEXT-74:
--------------------------------------
    Description: 
In StrSubstitutor variable replacement works in a recursive way. And currently there's no
way to turn this off.

Why turn it off: I want to replace some variables in a simple template. Some of the replacemnt
values are arbitrary user input.

At the moment I escape all dollar signs in the replacement values with "$$". This is annoying.
Especially as I use one template with variables as a value for another variable. Here I have
to escape twice.

Here's some example code. At the moment it prints "Hello world". The commented line is my
suggestion for this feature. If it works, it should print "Hello ${key2}":
{code}
Map<String, String> valueMap = new HashMap<>();
valueMap.put("key", "$${key2}");
valueMap.put("key2", "world");

String source = "Hello ${key}";

StrSubstitutor strSubstitutor = new StrSubstitutor(valueMap);
// strSubstitutor.setEnableSubstitutionInValues(false);
System.out.println(strSubstitutor.replace(source));
{code}

  was:
In StrSubstitutor variable replacement works in a recursive way. And currently there's no
way to turn this off.

Why turn it off: I want to replace some variables in a simple template. Some of the replacemnt
values are arbitrary user input.

At the moment I escape all dollar signs in the replacement values with "$$". This is annoying.
Especially as I use one template with variables as a value for another variable. Here I have
to escape twice.

Here's some example code. At the moment it prints "Hello world". The commented line is my
suggestion for this feature. If it works, it should print "Hello ${key2}":

Map<String, String> valueMap = new HashMap<>();
valueMap.put("key", "$${key2}");
valueMap.put("key2", "world");

String source = "Hello ${key}";

StrSubstitutor strSubstitutor = new StrSubstitutor(valueMap);
// strSubstitutor.setEnableSubstitutionInValues(false);
System.out.println(strSubstitutor.replace(source));



> StrSubstitutor: Ability to turn off substitution in values
> ----------------------------------------------------------
>
>                 Key: TEXT-74
>                 URL: https://issues.apache.org/jira/browse/TEXT-74
>             Project: Commons Text
>          Issue Type: Improvement
>            Reporter: Arend v. Reinersdorff
>            Priority: Minor
>              Labels: features
>             Fix For: 1.x
>
>
> In StrSubstitutor variable replacement works in a recursive way. And currently there's
no way to turn this off.
> Why turn it off: I want to replace some variables in a simple template. Some of the replacemnt
values are arbitrary user input.
> At the moment I escape all dollar signs in the replacement values with "$$". This is
annoying. Especially as I use one template with variables as a value for another variable.
Here I have to escape twice.
> Here's some example code. At the moment it prints "Hello world". The commented line is
my suggestion for this feature. If it works, it should print "Hello ${key2}":
> {code}
> Map<String, String> valueMap = new HashMap<>();
> valueMap.put("key", "$${key2}");
> valueMap.put("key2", "world");
> String source = "Hello ${key}";
> StrSubstitutor strSubstitutor = new StrSubstitutor(valueMap);
> // strSubstitutor.setEnableSubstitutionInValues(false);
> System.out.println(strSubstitutor.replace(source));
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message