[
https://issues.apache.org/jira/browse/LANG-893?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13718536#comment-13718536
]
Woonsan Ko commented on LANG-893:
---------------------------------
Good to hear that. I'd like to try to create/upload a patch for this soon.
Regarding the default delimiter for the default value, I searched on the
internet and found this page:
- http://en.wikipedia.org/wiki/Null_coalescing_operator
Each programming language has its own solution:
For example, Freemarker and Velocity uses '!'. Javascript, Ruby and PHP use
'||'. Perl uses '//'. Groovy uses '?:' (which seems to be most similar to your
suggestion). C# uses '??', and so forth.
Personally, I started liking '||' followed by double or single quoted string
after the research. e.g, ${number||"N/A"} or ${number||'N/A'}. It seems most
intuitive to me. ;-)
Anyway, selection of the default delimiter doesn't make any block here, so I
can continue.
I'm open to any suggestions for the default delimiter string. Otherwise, I'd
like to start with '||' as default for now.
Cheers,
Woonsan
> Default value for StrSubstitutor
> --------------------------------
>
> Key: LANG-893
> URL: https://issues.apache.org/jira/browse/LANG-893
> Project: Commons Lang
> Issue Type: Improvement
> Components: lang.text.*
> Affects Versions: 2.4
> Reporter: Lauri Siltanen
> Priority: Minor
>
> public static void main(String[] args) {
> String s = "The number of ${item} items currently available:
> ${number}";
> String result = StrSubstitutor.replace(s,
> Collections.singletonMap("item", "monitor"));
> System.out.println(result);
> }
> This results in: "The number of monitor items currently available: ${number}".
> I'd need a default value for a placeholder that cannot be resolved.
> String result = StrSubstitutor.replace(s, Collections.singletonMap("item",
> "monitor"), "N/A");
> -> "The number of monitor items currently available: N/A".
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira