Unify exception handling re IAE

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137544 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2003-07-31 23:45:28 +00:00
parent 43db5237ab
commit aa3b4bbccc
5 changed files with 34 additions and 36 deletions

View File

@ -75,7 +75,7 @@
* @author Nikolay Metchev
* @author Matthew Hawthorne
* @since 2.0
* @version $Id: ArrayUtils.java,v 1.19 2003/07/19 20:17:12 scolebourne Exp $
* @version $Id: ArrayUtils.java,v 1.20 2003/07/31 23:45:28 scolebourne Exp $
*/
public class ArrayUtils {
@ -607,7 +607,7 @@ public static boolean isSameLength(final boolean[] array1, final boolean[] array
*/
public static boolean isSameType(final Object array1, final Object array2) {
if (array1 == null || array2 == null) {
throw new NullArgumentException("Array");
throw new IllegalArgumentException("The Array must not be null");
}
return array1.getClass().getName().equals(array2.getClass().getName());
}

View File

@ -81,7 +81,7 @@
* @author Stephen Colebourne
* @author Jeff Varszegi
* @since 1.0
* @version $Id: SerializationUtils.java,v 1.7 2003/07/19 20:22:36 scolebourne Exp $
* @version $Id: SerializationUtils.java,v 1.8 2003/07/31 23:45:28 scolebourne Exp $
*/
public class SerializationUtils {
@ -130,7 +130,7 @@ public static Object clone(Serializable object) {
*/
public static void serialize(Serializable obj, OutputStream outputStream) {
if (outputStream == null) {
throw new NullArgumentException("OutputStream");
throw new IllegalArgumentException("The OutputStream must not be null");
}
ObjectOutputStream out = null;
try {
@ -182,7 +182,7 @@ public static byte[] serialize(Serializable obj) {
*/
public static Object deserialize(InputStream inputStream) {
if (inputStream == null) {
throw new NullArgumentException("InputStream");
throw new IllegalArgumentException("The InputStream must not be null");
}
ObjectInputStream in = null;
try {
@ -215,7 +215,7 @@ public static Object deserialize(InputStream inputStream) {
*/
public static Object deserialize(byte[] objectData) {
if (objectData == null) {
throw new NullArgumentException("byte[]");
throw new IllegalArgumentException("The byte[] must not be null");
}
ByteArrayInputStream bais = new ByteArrayInputStream(objectData);
return deserialize(bais);

View File

@ -73,7 +73,7 @@
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
* @author Phil Steitz
* @since 2.0
* @version $Id: StringEscapeUtils.java,v 1.21 2003/07/28 16:17:57 ggregory Exp $
* @version $Id: StringEscapeUtils.java,v 1.22 2003/07/31 23:45:28 scolebourne Exp $
*/
public class StringEscapeUtils {
@ -191,7 +191,7 @@ private static String escapeJavaStyleString(String str, boolean escapeSingleQuot
private static void escapeJavaStyleString(Writer out, String str, boolean escapeSingleQuote) throws IOException {
if (out == null) {
throw new NullArgumentException("Writer");
throw new IllegalArgumentException("The Writer must not be null");
}
if (str == null) {
return;
@ -311,7 +311,7 @@ public static String unescapeJava(String str) {
*/
public static void unescapeJava(Writer out, String str) throws IOException {
if (out == null) {
throw new NullArgumentException("Writer");
throw new IllegalArgumentException("The Writer must not be null");
}
if (str == null) {
return;

View File

@ -67,7 +67,6 @@
import java.util.StringTokenizer;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.NullArgumentException;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.SystemUtils;
@ -80,7 +79,7 @@
* @author Stephen Colebourne
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
* @since 1.0
* @version $Id: ExceptionUtils.java,v 1.30 2003/07/26 14:22:21 scolebourne Exp $
* @version $Id: ExceptionUtils.java,v 1.31 2003/07/31 23:45:28 scolebourne Exp $
*/
public class ExceptionUtils {
@ -509,7 +508,7 @@ public static void printRootCauseStackTrace(Throwable throwable, PrintStream str
return;
}
if (stream == null) {
throw new NullArgumentException("PrintStream");
throw new IllegalArgumentException("The PrintStream must not be null");
}
String trace[] = getRootCauseStackTrace(throwable);
for (int i = 0; i < trace.length; i++) {
@ -538,7 +537,7 @@ public static void printRootCauseStackTrace(Throwable throwable, PrintWriter wri
return;
}
if (writer == null) {
throw new NullArgumentException("PrintWriter");
throw new IllegalArgumentException("The PrintWriter must not be null");
}
String trace[] = getRootCauseStackTrace(throwable);
for (int i = 0; i < trace.length; i++) {
@ -590,7 +589,7 @@ public static String[] getRootCauseStackTrace(Throwable throwable) {
*/
public static void removeCommonFrames(List causeFrames, List wrapperFrames) {
if (causeFrames == null || wrapperFrames == null) {
throw new NullArgumentException("List");
throw new IllegalArgumentException("The List must not be null");
}
int causeFrameIndex = causeFrames.size() - 1;
int wrapperFrameIndex = wrapperFrames.size() - 1;

View File

@ -56,7 +56,6 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import org.apache.commons.lang.NullArgumentException;
import org.apache.commons.lang.StringUtils;
/**
@ -71,7 +70,7 @@
* @author Matthew Hawthorne
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
* @since 2.0
* @version $Id: NumberUtils.java,v 1.8 2003/07/28 21:37:32 scolebourne Exp $
* @version $Id: NumberUtils.java,v 1.9 2003/07/31 23:45:28 scolebourne Exp $
*/
public class NumberUtils {
@ -490,13 +489,13 @@ public static BigDecimal createBigDecimal(String str) {
*
* @param array an array, must not be null or empty
* @return the minimum value in the array
* @throws NullArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is empty
*/
public static long min(long[] array) {
// Validates input
if (array == null) {
throw new NullArgumentException("Array");
throw new IllegalArgumentException("The Array must not be null");
} else if (array.length == 0) {
throw new IllegalArgumentException("Array cannot be empty.");
}
@ -517,13 +516,13 @@ public static long min(long[] array) {
*
* @param array an array, must not be null or empty
* @return the minimum value in the array
* @throws NullArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is empty
*/
public static int min(int[] array) {
// Validates input
if (array == null) {
throw new NullArgumentException("Array");
throw new IllegalArgumentException("The Array must not be null");
} else if (array.length == 0) {
throw new IllegalArgumentException("Array cannot be empty.");
}
@ -544,13 +543,13 @@ public static int min(int[] array) {
*
* @param array an array, must not be null or empty
* @return the minimum value in the array
* @throws NullArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is empty
*/
public static short min(short[] array) {
// Validates input
if (array == null) {
throw new NullArgumentException("Array");
throw new IllegalArgumentException("The Array must not be null");
} else if (array.length == 0) {
throw new IllegalArgumentException("Array cannot be empty.");
}
@ -571,13 +570,13 @@ public static short min(short[] array) {
*
* @param array an array, must not be null or empty
* @return the minimum value in the array
* @throws NullArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is empty
*/
public static double min(double[] array) {
// Validates input
if (array == null) {
throw new NullArgumentException("Array");
throw new IllegalArgumentException("The Array must not be null");
} else if (array.length == 0) {
throw new IllegalArgumentException("Array cannot be empty.");
}
@ -598,13 +597,13 @@ public static double min(double[] array) {
*
* @param array an array, must not be null or empty
* @return the minimum value in the array
* @throws NullArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is empty
*/
public static float min(float[] array) {
// Validates input
if (array == null) {
throw new NullArgumentException("Array");
throw new IllegalArgumentException("The Array must not be null");
} else if (array.length == 0) {
throw new IllegalArgumentException("Array cannot be empty.");
}
@ -627,13 +626,13 @@ public static float min(float[] array) {
*
* @param array an array, must not be null or empty
* @return the minimum value in the array
* @throws NullArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is empty
*/
public static long max(long[] array) {
// Validates input
if (array == null) {
throw new NullArgumentException("Array");
throw new IllegalArgumentException("The Array must not be null");
} else if (array.length == 0) {
throw new IllegalArgumentException("Array cannot be empty.");
}
@ -654,13 +653,13 @@ public static long max(long[] array) {
*
* @param array an array, must not be null or empty
* @return the minimum value in the array
* @throws NullArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is empty
*/
public static int max(int[] array) {
// Validates input
if (array == null) {
throw new NullArgumentException("Array");
throw new IllegalArgumentException("The Array must not be null");
} else if (array.length == 0) {
throw new IllegalArgumentException("Array cannot be empty.");
}
@ -681,13 +680,13 @@ public static int max(int[] array) {
*
* @param array an array, must not be null or empty
* @return the minimum value in the array
* @throws NullArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is empty
*/
public static short max(short[] array) {
// Validates input
if (array == null) {
throw new NullArgumentException("Array");
throw new IllegalArgumentException("The Array must not be null");
} else if (array.length == 0) {
throw new IllegalArgumentException("Array cannot be empty.");
}
@ -708,13 +707,13 @@ public static short max(short[] array) {
*
* @param array an array, must not be null or empty
* @return the minimum value in the array
* @throws NullArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is empty
*/
public static double max(double[] array) {
// Validates input
if (array== null) {
throw new NullArgumentException("Array");
throw new IllegalArgumentException("The Array must not be null");
} else if (array.length == 0) {
throw new IllegalArgumentException("Array cannot be empty.");
}
@ -735,13 +734,13 @@ public static double max(double[] array) {
*
* @param array an array, must not be null or empty
* @return the minimum value in the array
* @throws NullArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is <code>null</code>
* @throws IllegalArgumentException if <code>array</code> is empty
*/
public static float max(float[] array) {
// Validates input
if (array == null) {
throw new NullArgumentException("Array");
throw new IllegalArgumentException("The Array must not be null");
} else if (array.length == 0) {
throw new IllegalArgumentException("Array cannot be empty.");
}