|
@@ -19,8 +19,9 @@ |
19 |
19 |
|
public static final String NOT_ALLOWED_TO_BE_NULL = ": Not allowed to be null"; |
20 |
20 |
|
|
21 |
21 |
|
public static final String ASCII_127 = "DEL"; |
22 |
|
- |
public static final String[] ASCII_LOW_32 = new String[]{"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US"}; |
23 |
|
- |
|
|
22 |
+ |
public static final String[] ASCII_LOW_32 = |
|
23 |
+ |
new String[]{"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", "DLE", "DC1", "DC2", "DC3", |
|
24 |
+ |
"DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US"}; |
24 |
25 |
|
|
25 |
26 |
|
protected UtilsCommon() |
26 |
27 |
|
{ |
|
@@ -616,15 +617,6 @@ |
616 |
617 |
|
return rv; |
617 |
618 |
|
} |
618 |
619 |
|
|
619 |
|
- |
public static void assertNotNullNotEmpty( String pErrorMessage, Collection pCollectionToAssert ) |
620 |
|
- |
throws IllegalArgumentException |
621 |
|
- |
{ |
622 |
|
- |
if ( isNullOrEmpty( pCollectionToAssert ) ) |
623 |
|
- |
{ |
624 |
|
- |
Strings.nullOrEmpty( pErrorMessage, "Collection" ); |
625 |
|
- |
} |
626 |
|
- |
} |
627 |
|
- |
|
628 |
620 |
|
public static String assertNoLeadingOrTrailingWhiteSpace( String pErrorMessage, String pStringToAssert ) |
629 |
621 |
|
throws IllegalArgumentException |
630 |
622 |
|
{ |
|
@@ -820,12 +812,12 @@ |
820 |
812 |
|
|
821 |
813 |
|
public static String padIt( int pMinDesiredLength, int pIt ) |
822 |
814 |
|
{ |
823 |
|
- |
return padIt( pMinDesiredLength, "" + pIt ); |
|
815 |
+ |
return Strings.padIt( pMinDesiredLength, "" + pIt ); |
824 |
816 |
|
} |
825 |
817 |
|
|
826 |
818 |
|
public static String iTpad( int pIt, int pMinDesiredLength ) |
827 |
819 |
|
{ |
828 |
|
- |
return iTpad( "" + pIt, pMinDesiredLength ); |
|
820 |
+ |
return Strings.iTpad( "" + pIt, pMinDesiredLength ); |
829 |
821 |
|
} |
830 |
822 |
|
|
831 |
823 |
|
public static boolean isNullOrEmpty( int[] pArrayToCheck ) |
|
@@ -833,16 +825,6 @@ |
833 |
825 |
|
return (pArrayToCheck == null || pArrayToCheck.length == 0); |
834 |
826 |
|
} |
835 |
827 |
|
|
836 |
|
- |
public static boolean isNullOrEmpty( Collection pCollectionToCheck ) |
837 |
|
- |
{ |
838 |
|
- |
return (pCollectionToCheck == null || pCollectionToCheck.isEmpty()); |
839 |
|
- |
} |
840 |
|
- |
|
841 |
|
- |
public static boolean isNotNullOrEmpty( Collection pCollectionToCheck ) |
842 |
|
- |
{ |
843 |
|
- |
return (pCollectionToCheck != null && !pCollectionToCheck.isEmpty()); |
844 |
|
- |
} |
845 |
|
- |
|
846 |
828 |
|
public static boolean areArraysEqual( byte[] pThis, byte[] pThat ) |
847 |
829 |
|
{ |
848 |
830 |
|
if ( pThis == pThat ) // handles if both are null |
|
@@ -889,12 +871,12 @@ |
889 |
871 |
|
|
890 |
872 |
|
public static String padIt( int pMinDesiredLength, Object pIt ) |
891 |
873 |
|
{ |
892 |
|
- |
return padIt( pMinDesiredLength, "" + pIt ); |
|
874 |
+ |
return Strings.padIt( pMinDesiredLength, "" + pIt ); |
893 |
875 |
|
} |
894 |
876 |
|
|
895 |
877 |
|
public static String iTpad( Object pIt, int pMinDesiredLength ) |
896 |
878 |
|
{ |
897 |
|
- |
return iTpad( "" + pIt, pMinDesiredLength ); |
|
879 |
+ |
return Strings.iTpad( "" + pIt, pMinDesiredLength ); |
898 |
880 |
|
} |
899 |
881 |
|
|
900 |
882 |
|
private static void assertElementsNotNull( String pErrorMessage, Object[] pArrayToAssert ) |
|
@@ -1117,73 +1099,6 @@ |
1117 |
1099 |
|
return appendStringArrays( pCurArray, new String[]{pNewLast} ); |
1118 |
1100 |
|
} |
1119 |
1101 |
|
|
1120 |
|
- |
public static String noSpaces( String pSource ) |
1121 |
|
- |
{ |
1122 |
|
- |
if ( (pSource == null) || (pSource.length() == 0) || (pSource.indexOf( ' ' ) == -1) ) |
1123 |
|
- |
{ |
1124 |
|
- |
return pSource; |
1125 |
|
- |
} |
1126 |
|
- |
StringBuilder sb = new StringBuilder( pSource ); |
1127 |
|
- |
for ( int i = pSource.length(); --i >= 0; ) |
1128 |
|
- |
{ |
1129 |
|
- |
if ( sb.charAt( i ) == ' ' ) |
1130 |
|
- |
{ |
1131 |
|
- |
sb.deleteCharAt( i ); |
1132 |
|
- |
} |
1133 |
|
- |
} |
1134 |
|
- |
return sb.toString(); |
1135 |
|
- |
} |
1136 |
|
- |
|
1137 |
|
- |
public static String padIt( int pMinDesiredLength, String pIt ) |
1138 |
|
- |
{ |
1139 |
|
- |
String rv = Strings.deNull( pIt ); |
1140 |
|
- |
int padBy = pMinDesiredLength - rv.length(); |
1141 |
|
- |
return (padBy <= 0) ? rv : (Strings.spaces( padBy ) + rv); |
1142 |
|
- |
} |
1143 |
|
- |
|
1144 |
|
- |
public static String iTpad( String pIt, int pMinDesiredLength ) |
1145 |
|
- |
{ |
1146 |
|
- |
String rv = Strings.deNull( pIt ); |
1147 |
|
- |
int padBy = pMinDesiredLength - rv.length(); |
1148 |
|
- |
return (padBy <= 0) ? rv : (rv + Strings.spaces( padBy )); |
1149 |
|
- |
} |
1150 |
|
- |
|
1151 |
|
- |
public static boolean containsAnyOf( String pToCheck, String pCharsToCheckFor ) |
1152 |
|
- |
{ |
1153 |
|
- |
if ( (pToCheck != null) && (pToCheck.length() > 0) && // |
1154 |
|
- |
(pCharsToCheckFor != null) && (pCharsToCheckFor.length() > 0) ) |
1155 |
|
- |
{ |
1156 |
|
- |
for ( int i = 0; i < pCharsToCheckFor.length(); i++ ) |
1157 |
|
- |
{ |
1158 |
|
- |
if ( -1 != pToCheck.indexOf( pCharsToCheckFor.charAt( i ) ) ) |
1159 |
|
- |
{ |
1160 |
|
- |
return true; |
1161 |
|
- |
} |
1162 |
|
- |
} |
1163 |
|
- |
} |
1164 |
|
- |
return false; |
1165 |
|
- |
} |
1166 |
|
- |
|
1167 |
|
- |
public static String getCommonTail( String pStr1, String pStr2 ) |
1168 |
|
- |
{ |
1169 |
|
- |
// Binary Search |
1170 |
|
- |
int goodTailLength = 0; |
1171 |
|
- |
for ( int potentialLength = Math.min( pStr1.length(), pStr2.length() ); potentialLength > goodTailLength; ) |
1172 |
|
- |
{ |
1173 |
|
- |
int mid = (goodTailLength + potentialLength + 1) / 2; |
1174 |
|
- |
String tail = pStr1.substring( pStr1.length() - mid ); |
1175 |
|
- |
if ( pStr2.endsWith( tail ) ) |
1176 |
|
- |
{ |
1177 |
|
- |
goodTailLength = mid; |
1178 |
|
- |
} |
1179 |
|
- |
else |
1180 |
|
- |
{ |
1181 |
|
- |
potentialLength = mid - 1; |
1182 |
|
- |
} |
1183 |
|
- |
} |
1184 |
|
- |
return (goodTailLength == 0) ? "" : pStr1.substring( pStr1.length() - goodTailLength ); |
1185 |
|
- |
} |
1186 |
|
- |
|
1187 |
1102 |
|
public static String toStringNullToEmpty( Object pObject ) |
1188 |
1103 |
|
{ |
1189 |
1104 |
|
if ( pObject != null ) |