Class CaseHelper


  • public final class CaseHelper
    extends Object
    Simple helper for case conversion like toLowerCase(String) or toUpperCase(String). This seems pointless in the first place but prevents typical programming mistakes. Many developers will expect that "HI".toLowerCase() returns "hi". However, this is not always the case! String.toLowerCase() will actually do toLowerCase(Locale.getDefault()). The latter operation is obviously a Locale sensitive operation and can behave differently depending on the given Locale. So e.g. if your Locale is actually Turkish (tr_TR resp. tr-TR) the result of "HI".toLowerCase() will actually be "hı" (notice the missing dot on the i character!). This can lead to serious bugs when creating filenames, URLs or the like via case conversion. Due to such bug nobody with Turkish locale could install Lotus Notes 8.5.1 when it was released.
    Simply use this small helper as indirection to the standard String case operations to prevent such mistakes and also to document this fact.