You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "James Sawle (JIRA)" <ji...@apache.org> on 2014/10/14 23:11:34 UTC

[jira] [Comment Edited] (LANG-1048) Improve internationalisation by accepting more than one possible true string value in BooleanUtils.toBoolean()

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

James Sawle edited comment on LANG-1048 at 10/14/14 9:10 PM:
-------------------------------------------------------------

I would suggest 3 or possibly 4 methods.

- boolean toBoolean(final String str, final String... trueStrings)
- boolean toBoolean(final String str, final Set<String> trueStrings)
- boolean toBoolean(final String str, final Set<String> trueStrings, final Set<String> falseStrings)
- Boolean toBooleanObject(final Strng str, final Set,String> trueStrings, final Set<String> falseStrings, final String<String> nullStrings)


was (Author: jamessawle):
I would suggest 3 or possibly 4 methods.

- boolean toBoolean(final String str, final String... trueStrings)
- boolean toBoolean(final String str, final Set<String> trueStrings)
- boolean toBoolean(final String str, final Set<String> trueStrings, final Set<String> falseStrings)
- Boolean toBooleanObject(final Strng str, final Set,String> trueStrings, final Set<String> falseStrings, final String<String> nullStrings)

When we have these the public static Boolean toBooleanObject(final String str) method should probably be migrated to use the last version, and it should be tuned to keep the performance close to the current functions.

> Improve internationalisation by accepting more than one possible true string value in BooleanUtils.toBoolean()
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: LANG-1048
>                 URL: https://issues.apache.org/jira/browse/LANG-1048
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.*
>    Affects Versions: 3.3.2
>            Reporter: Duncan Jones
>            Priority: Minor
>             Fix For: Discussion
>
>
> As part of a [recent ML discussion|http://markmail.org/message/3yvgfm2fuqkvwb7q] it was noted that {{BooleanUtils.toBoolean(String)}} is biased towards English speakers.
> We could match the behaviour of this method for non-English users by adding:
> {code:java}
> boolean toBoolean(String str, String... trueStrings)
> {code}
> and match in a case-insensitive fashion. Anything that doesn't match a true string is false. 
> The current {{toBoolean(String)}} method would just be a special case of this new method, with the arguments {{toBoolean(str, "true", "on", "y", "t", "yes")}}.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)