You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2018/07/29 20:29:00 UTC

[jira] [Commented] (TEXT-127) Detect when a variable is unknown in StringSubstitutor

    [ https://issues.apache.org/jira/browse/TEXT-127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16561261#comment-16561261 ] 

Sebb commented on TEXT-127:
---------------------------

Are you saying that you want different behaviour for the following cases?

String templateString = "This is underfined with default: ${undefined.number:-1234567890}.";
String templateString = "This is underfined without default: ${undefined.number}.";

If not, then a custom StringLookup that raises an exception when the variable is unknown will work fine.

Or are you asking for something more like the shell :?text modifier?

Please provide some sample code and expected results.

> Detect when a variable is unknown in StringSubstitutor
> ------------------------------------------------------
>
>                 Key: TEXT-127
>                 URL: https://issues.apache.org/jira/browse/TEXT-127
>             Project: Commons Text
>          Issue Type: Improvement
>            Reporter: Jean-Baptiste REICH
>            Priority: Minor
>
> Currently, StringSubstitutor is not replacing a variable that is unknown. It would be nice to define the behavior in this case and to allow raising an exception.
> A workaround is to define a custom StringLookup that raises an exception when the variable is unknown but this prevent from using the default value feature from StringSubstitutor



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)