Commons Lang
  1. Commons Lang
  2. LANG-471

I would like to add isLowerCase and isUpperCase methods to WordUtils in the commons.lang package

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4
    • Fix Version/s: 2.5
    • Component/s: lang.*
    • Labels:
      None

      Description

      public static boolean isLowerCase(String s)
      {
      if (s == null || s.trim().length() == 0) return false;

      char[] chars = new char[s.length()];
      s.getChars(0, s.length(), chars, 0);
      boolean ilc = true;
      for (int i = 0; i < chars.length; i++)
      {
      if (Character.isUpperCase(chars[i]))

      { ilc = false; break; }

      }

      return ilc;
      }

      public static boolean isUpperCase(String s)
      {
      if (s == null || s.trim().length() == 0) return false;

      char[] chars = new char[s.length()];
      s.getChars(0, s.length(), chars, 0);
      boolean iuc = true;
      for (int i = 0; i < chars.length; i++)
      {
      if (Character.isLowerCase(chars[i]))

      { iuc = false; break; }

      }

      return iuc;
      }

      1. LANG-471.patch
        4 kB
        Vincent Ricard

        Activity

        Ivica Mikic created issue -
        Ivica Mikic made changes -
        Field Original Value New Value
        Summary I would like to add isLowerCase and isUpperCase methods to the lang package I would like to add isLowerCase and isUpperCase methods to WordUtils in the lang package
        Ivica Mikic made changes -
        Summary I would like to add isLowerCase and isUpperCase methods to WordUtils in the lang package I would like to add isLowerCase and isUpperCase methods to WordUtils in the commons.lang package
        Ivica Mikic made changes -
        Description public static boolean isLowerCase(String s)
          {
          if (s == null || s.trim().length() == 0) return s;
          
          char[] chars = new char[s.length()];
          s.getChars(0, s.length(), chars, 0);
          boolean ilc = true;
          for (int i = 0; i < chars.length; i++)
            {
            if (Character.isUpperCase(chars[i]))
              {
              ilc = false;
              break;
              }
            }
          
          return ilc;
          }
          
          
        public static boolean isUpperCase(String s)
          {
          if (s == null || s.trim().length() == 0) return s;
          
          char[] chars = new char[s.length()];
          s.getChars(0, s.length(), chars, 0);
          boolean iuc = true;
          for (int i = 0; i < chars.length; i++)
            {
            if (Character.isLowerCase(chars[i]))
              {
              iuc = false;
              break;
              }
            }
          
          return iuc;
          }
        public static boolean isLowerCase(String s)
          {
          if (s == null || s.trim().length() == 0) return false;
          
          char[] chars = new char[s.length()];
          s.getChars(0, s.length(), chars, 0);
          boolean ilc = true;
          for (int i = 0; i < chars.length; i++)
            {
            if (Character.isUpperCase(chars[i]))
              {
              ilc = false;
              break;
              }
            }
          
          return ilc;
          }
          
          
        public static boolean isUpperCase(String s)
          {
          if (s == null || s.trim().length() == 0) return false;
          
          char[] chars = new char[s.length()];
          s.getChars(0, s.length(), chars, 0);
          boolean iuc = true;
          for (int i = 0; i < chars.length; i++)
            {
            if (Character.isLowerCase(chars[i]))
              {
              iuc = false;
              break;
              }
            }
          
          return iuc;
          }
        Hide
        James Carman added a comment -

        I don't know if it belongs in WordUtils. I'd say put it in StringUtils. You might also want to call them isAllUpperCase() or isAllLowerCase().

        Show
        James Carman added a comment - I don't know if it belongs in WordUtils. I'd say put it in StringUtils. You might also want to call them isAllUpperCase() or isAllLowerCase().
        Hide
        Ivica Mikic added a comment -

        Yes, StringUtils is more appropriate. What do I need to do to ensure it's included in the next version/release? Thanks.

        Show
        Ivica Mikic added a comment - Yes, StringUtils is more appropriate. What do I need to do to ensure it's included in the next version/release? Thanks.
        Hide
        James Carman added a comment -

        Providing a proper patch (with test cases) would be a great start.

        Show
        James Carman added a comment - Providing a proper patch (with test cases) would be a great start.
        Henri Yandell made changes -
        Fix Version/s 3.0 [ 12311714 ]
        Hide
        Vincent Ricard added a comment -

        Here is a patch.

        Show
        Vincent Ricard added a comment - Here is a patch.
        Vincent Ricard made changes -
        Attachment LANG-471.patch [ 12401840 ]
        Hide
        Henri Yandell added a comment -

        Thanks Vincent.

        svn ci -m "Applying Vincent Ricard's patch in LANG-471 (reported by Ivica Mikic) adding isAllUpperCase and isAllLowerCase to StringUtils"

        Sending src/java/org/apache/commons/lang/StringUtils.java
        Sending src/test/org/apache/commons/lang/StringUtilsTest.java
        Transmitting file data ..
        Committed revision 789573.

        Show
        Henri Yandell added a comment - Thanks Vincent. svn ci -m "Applying Vincent Ricard's patch in LANG-471 (reported by Ivica Mikic) adding isAllUpperCase and isAllLowerCase to StringUtils" Sending src/java/org/apache/commons/lang/StringUtils.java Sending src/test/org/apache/commons/lang/StringUtilsTest.java Transmitting file data .. Committed revision 789573.
        Henri Yandell made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]
        Henri Yandell made changes -
        Component/s lang.* [ 12313203 ]
        Niall Pemberton made changes -
        Fix Version/s 2.5 [ 12314743 ]
        Fix Version/s 3.0 [ 12311714 ]
        Mark Thomas made changes -
        Workflow jira [ 12446453 ] Default workflow, editable Closed status [ 12602425 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Closed Closed
        224d 13h 19m 1 Henri Yandell 30/Jun/09 06:24

          People

          • Assignee:
            Unassigned
            Reporter:
            Ivica Mikic
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 0.25h
              0.25h
              Remaining:
              Remaining Estimate - 0.25h
              0.25h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development