[
https://issues.apache.org/jira/browse/LANG-1043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14165299#comment-14165299
]
Frédéric JECKER commented on LANG-1043:
---------------------------------------
+1 for Sebb, I should have RTFM, where it is clearly stated that
bq. StringUtils.isAllUpperCase(" ") = false
But, in a hurry, i missed that sneaky example and I think that a more trivial
example should be added like
bq. StringUtils.isAllUpperCase(" ABC DEF GHI ") = false
I also agree that changing this method's behavior could be harmful as it would
break backward compatibility
I can however not agree Sebb's last statemet as there is no valid use-case.
IMHO in its current form isAllUpperCase() is useless.
In my understanding UpperCase is all about alpha characters, uppcase is not
applying to spaces, and punctuation signs, when using such a method I need to
know whether the alpha charatcters in my String are uppercased I dont care
about other characters.
There are plenty of real world use cases where checking that a string contains
only uppercased alpha characters, i.e I came to that point while sanitizing
user display names.
The solution for me would be to overload this method (or add a new
isAllUpperCaseAlpha method) and only check the upper case state for characters
where isAlpha() is true.
> isAllUpperCase should only check Alpha characters
> -------------------------------------------------
>
> Key: LANG-1043
> URL: https://issues.apache.org/jira/browse/LANG-1043
> Project: Commons Lang
> Issue Type: Improvement
> Components: lang.*
> Affects Versions: 3.3.2
> Reporter: Frédéric JECKER
> Fix For: Discussion
>
> Attachments: LANG-1043.patch
>
>
> Currently, isAllUpperCase checks character by character if the current
> character is UpperCase or not using Character.isUpperCase().
> The problem is that characters like spaces aren't considered as uppercase
> characters.
> IMHO, isAllUpperCase should only check the state of alpha characters so that :
> - StringUtils.isAllUpperCase("ABC DEF GHI") = true (false currently)
> - StringUtils.isAllUpperCase("ABC / DEF") = true (false currently)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)