1 19 package org.enhydra.zeus.util; 20 21 33 public class CapitalizationUtils { 34 35 47 public static String initialUpper(String original) { 48 if (original == null) { 49 throw new IllegalArgumentException ("A non-null String must be " + 50 "supplied to CapitalizationUtils methods."); 51 } 52 if (original.length() == 0) { 53 return original; 54 } 55 56 char[] originalChars = original.toCharArray(); 57 char firstLetter = 58 Character.toUpperCase(original.charAt(0)); 59 originalChars[0] = firstLetter; 60 61 return new String (originalChars); 62 } 63 64 76 public static String justInitialUpper(String original) { 77 if (original == null) { 78 throw new IllegalArgumentException ("A non-null String must be " + 79 "supplied to CapitalizationUtils methods."); 80 } 81 82 String lowercaseOriginal = allLower(original); 83 return initialUpper(lowercaseOriginal); 84 } 85 86 103 public static String allUpper(String original) { 104 if (original == null) { 105 throw new IllegalArgumentException ("A non-null String must be " + 106 "supplied to CapitalizationUtils methods."); 107 } 108 109 return original.toUpperCase(); 110 } 111 112 124 public static String initialLower(String original) { 125 if (original == null) { 126 throw new IllegalArgumentException ("A non-null String must be " + 127 "supplied to CapitalizationUtils methods."); 128 } 129 if (original.length() == 0) { 130 return original; 131 } 132 133 char[] originalChars = original.toCharArray(); 134 char firstLetter = 135 Character.toLowerCase(original.charAt(0)); 136 originalChars[0] = firstLetter; 137 138 return new String (originalChars); 139 } 140 141 158 public static String allLower(String original) { 159 if (original == null) { 160 throw new IllegalArgumentException ("A non-null String must be " + 161 "supplied to CapitalizationUtils methods."); 162 } 163 164 return original.toLowerCase(); 165 } 166 } 167 | Popular Tags |