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

Michael Osipov updated TEXT-229:
--------------------------------
    Fix Version/s: 1.11.0

> Add XmlEncoderStringLookup/XmlDecoderStringLookup
> -------------------------------------------------
>
>                 Key: TEXT-229
>                 URL: https://issues.apache.org/jira/browse/TEXT-229
>             Project: Commons Text
>          Issue Type: New Feature
>    Affects Versions: 1.10.0
>            Reporter: Michael Osipov
>            Assignee: Michael Osipov
>            Priority: Major
>             Fix For: 1.11.0
>
>
> While we have URL encoder and decoder it'd be helpful to have builtin 
> {{XmlEncoderStringLookup}} and {{XmlDecoderStringLookup}}.
> A quick hack works for me:
> {code:java}
>       public static void main(String[] args) {
>               Map<String, StringLookup> lookups = new HashMap<>();
>               lookups.put("xmlEncoder", XmlEncoderStringLookup.INSTANCE);
>               Map<String, String> vars = new HashMap<>();
>               vars.put("foo", "bar");
>               vars.put("baz", "<password>");
>               StringLookupFactory factory = StringLookupFactory.INSTANCE;
>               StringLookup interpolatorStringLookup = 
> factory.interpolatorStringLookup(lookups, factory.mapStringLookup(vars), 
> false);
>               StringSubstitutor sub = new 
> StringSubstitutor(interpolatorStringLookup);
>               sub.setEnableSubstitutionInVariables(true);
>               System.out.println(sub.replace("${foo}, ${xmlEncoder:<foo 
> bar='sdfsf' />} ${xmlEncoder:${baz}}"));
>       }
> {code}
> {noformat}
> bar, &lt;foo bar=&apos;sdfsf&apos; /&gt; &lt;password&gt;
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to