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:
parent
43db5237ab
commit
aa3b4bbccc
|
@ -75,7 +75,7 @@
|
||||||
* @author Nikolay Metchev
|
* @author Nikolay Metchev
|
||||||
* @author Matthew Hawthorne
|
* @author Matthew Hawthorne
|
||||||
* @since 2.0
|
* @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 {
|
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) {
|
public static boolean isSameType(final Object array1, final Object array2) {
|
||||||
if (array1 == null || array2 == null) {
|
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());
|
return array1.getClass().getName().equals(array2.getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
* @author Jeff Varszegi
|
* @author Jeff Varszegi
|
||||||
* @since 1.0
|
* @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 {
|
public class SerializationUtils {
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ public static Object clone(Serializable object) {
|
||||||
*/
|
*/
|
||||||
public static void serialize(Serializable obj, OutputStream outputStream) {
|
public static void serialize(Serializable obj, OutputStream outputStream) {
|
||||||
if (outputStream == null) {
|
if (outputStream == null) {
|
||||||
throw new NullArgumentException("OutputStream");
|
throw new IllegalArgumentException("The OutputStream must not be null");
|
||||||
}
|
}
|
||||||
ObjectOutputStream out = null;
|
ObjectOutputStream out = null;
|
||||||
try {
|
try {
|
||||||
|
@ -182,7 +182,7 @@ public static byte[] serialize(Serializable obj) {
|
||||||
*/
|
*/
|
||||||
public static Object deserialize(InputStream inputStream) {
|
public static Object deserialize(InputStream inputStream) {
|
||||||
if (inputStream == null) {
|
if (inputStream == null) {
|
||||||
throw new NullArgumentException("InputStream");
|
throw new IllegalArgumentException("The InputStream must not be null");
|
||||||
}
|
}
|
||||||
ObjectInputStream in = null;
|
ObjectInputStream in = null;
|
||||||
try {
|
try {
|
||||||
|
@ -215,7 +215,7 @@ public static Object deserialize(InputStream inputStream) {
|
||||||
*/
|
*/
|
||||||
public static Object deserialize(byte[] objectData) {
|
public static Object deserialize(byte[] objectData) {
|
||||||
if (objectData == null) {
|
if (objectData == null) {
|
||||||
throw new NullArgumentException("byte[]");
|
throw new IllegalArgumentException("The byte[] must not be null");
|
||||||
}
|
}
|
||||||
ByteArrayInputStream bais = new ByteArrayInputStream(objectData);
|
ByteArrayInputStream bais = new ByteArrayInputStream(objectData);
|
||||||
return deserialize(bais);
|
return deserialize(bais);
|
||||||
|
|
|
@ -73,7 +73,7 @@
|
||||||
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
|
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
|
||||||
* @author Phil Steitz
|
* @author Phil Steitz
|
||||||
* @since 2.0
|
* @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 {
|
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 {
|
private static void escapeJavaStyleString(Writer out, String str, boolean escapeSingleQuote) throws IOException {
|
||||||
if (out == null) {
|
if (out == null) {
|
||||||
throw new NullArgumentException("Writer");
|
throw new IllegalArgumentException("The Writer must not be null");
|
||||||
}
|
}
|
||||||
if (str == null) {
|
if (str == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -311,7 +311,7 @@ public static String unescapeJava(String str) {
|
||||||
*/
|
*/
|
||||||
public static void unescapeJava(Writer out, String str) throws IOException {
|
public static void unescapeJava(Writer out, String str) throws IOException {
|
||||||
if (out == null) {
|
if (out == null) {
|
||||||
throw new NullArgumentException("Writer");
|
throw new IllegalArgumentException("The Writer must not be null");
|
||||||
}
|
}
|
||||||
if (str == null) {
|
if (str == null) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -67,7 +67,6 @@
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.apache.commons.lang.NullArgumentException;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang.SystemUtils;
|
import org.apache.commons.lang.SystemUtils;
|
||||||
|
|
||||||
|
@ -80,7 +79,7 @@
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
|
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
|
||||||
* @since 1.0
|
* @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 {
|
public class ExceptionUtils {
|
||||||
|
|
||||||
|
@ -509,7 +508,7 @@ public static void printRootCauseStackTrace(Throwable throwable, PrintStream str
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (stream == null) {
|
if (stream == null) {
|
||||||
throw new NullArgumentException("PrintStream");
|
throw new IllegalArgumentException("The PrintStream must not be null");
|
||||||
}
|
}
|
||||||
String trace[] = getRootCauseStackTrace(throwable);
|
String trace[] = getRootCauseStackTrace(throwable);
|
||||||
for (int i = 0; i < trace.length; i++) {
|
for (int i = 0; i < trace.length; i++) {
|
||||||
|
@ -538,7 +537,7 @@ public static void printRootCauseStackTrace(Throwable throwable, PrintWriter wri
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (writer == null) {
|
if (writer == null) {
|
||||||
throw new NullArgumentException("PrintWriter");
|
throw new IllegalArgumentException("The PrintWriter must not be null");
|
||||||
}
|
}
|
||||||
String trace[] = getRootCauseStackTrace(throwable);
|
String trace[] = getRootCauseStackTrace(throwable);
|
||||||
for (int i = 0; i < trace.length; i++) {
|
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) {
|
public static void removeCommonFrames(List causeFrames, List wrapperFrames) {
|
||||||
if (causeFrames == null || wrapperFrames == null) {
|
if (causeFrames == null || wrapperFrames == null) {
|
||||||
throw new NullArgumentException("List");
|
throw new IllegalArgumentException("The List must not be null");
|
||||||
}
|
}
|
||||||
int causeFrameIndex = causeFrames.size() - 1;
|
int causeFrameIndex = causeFrames.size() - 1;
|
||||||
int wrapperFrameIndex = wrapperFrames.size() - 1;
|
int wrapperFrameIndex = wrapperFrames.size() - 1;
|
||||||
|
|
|
@ -56,7 +56,6 @@
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
||||||
import org.apache.commons.lang.NullArgumentException;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,7 +70,7 @@
|
||||||
* @author Matthew Hawthorne
|
* @author Matthew Hawthorne
|
||||||
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
|
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
|
||||||
* @since 2.0
|
* @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 {
|
public class NumberUtils {
|
||||||
|
|
||||||
|
@ -490,13 +489,13 @@ public static BigDecimal createBigDecimal(String str) {
|
||||||
*
|
*
|
||||||
* @param array an array, must not be null or empty
|
* @param array an array, must not be null or empty
|
||||||
* @return the minimum value in the array
|
* @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
|
* @throws IllegalArgumentException if <code>array</code> is empty
|
||||||
*/
|
*/
|
||||||
public static long min(long[] array) {
|
public static long min(long[] array) {
|
||||||
// Validates input
|
// Validates input
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
throw new NullArgumentException("Array");
|
throw new IllegalArgumentException("The Array must not be null");
|
||||||
} else if (array.length == 0) {
|
} else if (array.length == 0) {
|
||||||
throw new IllegalArgumentException("Array cannot be empty.");
|
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
|
* @param array an array, must not be null or empty
|
||||||
* @return the minimum value in the array
|
* @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
|
* @throws IllegalArgumentException if <code>array</code> is empty
|
||||||
*/
|
*/
|
||||||
public static int min(int[] array) {
|
public static int min(int[] array) {
|
||||||
// Validates input
|
// Validates input
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
throw new NullArgumentException("Array");
|
throw new IllegalArgumentException("The Array must not be null");
|
||||||
} else if (array.length == 0) {
|
} else if (array.length == 0) {
|
||||||
throw new IllegalArgumentException("Array cannot be empty.");
|
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
|
* @param array an array, must not be null or empty
|
||||||
* @return the minimum value in the array
|
* @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
|
* @throws IllegalArgumentException if <code>array</code> is empty
|
||||||
*/
|
*/
|
||||||
public static short min(short[] array) {
|
public static short min(short[] array) {
|
||||||
// Validates input
|
// Validates input
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
throw new NullArgumentException("Array");
|
throw new IllegalArgumentException("The Array must not be null");
|
||||||
} else if (array.length == 0) {
|
} else if (array.length == 0) {
|
||||||
throw new IllegalArgumentException("Array cannot be empty.");
|
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
|
* @param array an array, must not be null or empty
|
||||||
* @return the minimum value in the array
|
* @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
|
* @throws IllegalArgumentException if <code>array</code> is empty
|
||||||
*/
|
*/
|
||||||
public static double min(double[] array) {
|
public static double min(double[] array) {
|
||||||
// Validates input
|
// Validates input
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
throw new NullArgumentException("Array");
|
throw new IllegalArgumentException("The Array must not be null");
|
||||||
} else if (array.length == 0) {
|
} else if (array.length == 0) {
|
||||||
throw new IllegalArgumentException("Array cannot be empty.");
|
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
|
* @param array an array, must not be null or empty
|
||||||
* @return the minimum value in the array
|
* @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
|
* @throws IllegalArgumentException if <code>array</code> is empty
|
||||||
*/
|
*/
|
||||||
public static float min(float[] array) {
|
public static float min(float[] array) {
|
||||||
// Validates input
|
// Validates input
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
throw new NullArgumentException("Array");
|
throw new IllegalArgumentException("The Array must not be null");
|
||||||
} else if (array.length == 0) {
|
} else if (array.length == 0) {
|
||||||
throw new IllegalArgumentException("Array cannot be empty.");
|
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
|
* @param array an array, must not be null or empty
|
||||||
* @return the minimum value in the array
|
* @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
|
* @throws IllegalArgumentException if <code>array</code> is empty
|
||||||
*/
|
*/
|
||||||
public static long max(long[] array) {
|
public static long max(long[] array) {
|
||||||
// Validates input
|
// Validates input
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
throw new NullArgumentException("Array");
|
throw new IllegalArgumentException("The Array must not be null");
|
||||||
} else if (array.length == 0) {
|
} else if (array.length == 0) {
|
||||||
throw new IllegalArgumentException("Array cannot be empty.");
|
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
|
* @param array an array, must not be null or empty
|
||||||
* @return the minimum value in the array
|
* @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
|
* @throws IllegalArgumentException if <code>array</code> is empty
|
||||||
*/
|
*/
|
||||||
public static int max(int[] array) {
|
public static int max(int[] array) {
|
||||||
// Validates input
|
// Validates input
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
throw new NullArgumentException("Array");
|
throw new IllegalArgumentException("The Array must not be null");
|
||||||
} else if (array.length == 0) {
|
} else if (array.length == 0) {
|
||||||
throw new IllegalArgumentException("Array cannot be empty.");
|
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
|
* @param array an array, must not be null or empty
|
||||||
* @return the minimum value in the array
|
* @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
|
* @throws IllegalArgumentException if <code>array</code> is empty
|
||||||
*/
|
*/
|
||||||
public static short max(short[] array) {
|
public static short max(short[] array) {
|
||||||
// Validates input
|
// Validates input
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
throw new NullArgumentException("Array");
|
throw new IllegalArgumentException("The Array must not be null");
|
||||||
} else if (array.length == 0) {
|
} else if (array.length == 0) {
|
||||||
throw new IllegalArgumentException("Array cannot be empty.");
|
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
|
* @param array an array, must not be null or empty
|
||||||
* @return the minimum value in the array
|
* @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
|
* @throws IllegalArgumentException if <code>array</code> is empty
|
||||||
*/
|
*/
|
||||||
public static double max(double[] array) {
|
public static double max(double[] array) {
|
||||||
// Validates input
|
// Validates input
|
||||||
if (array== null) {
|
if (array== null) {
|
||||||
throw new NullArgumentException("Array");
|
throw new IllegalArgumentException("The Array must not be null");
|
||||||
} else if (array.length == 0) {
|
} else if (array.length == 0) {
|
||||||
throw new IllegalArgumentException("Array cannot be empty.");
|
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
|
* @param array an array, must not be null or empty
|
||||||
* @return the minimum value in the array
|
* @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
|
* @throws IllegalArgumentException if <code>array</code> is empty
|
||||||
*/
|
*/
|
||||||
public static float max(float[] array) {
|
public static float max(float[] array) {
|
||||||
// Validates input
|
// Validates input
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
throw new NullArgumentException("Array");
|
throw new IllegalArgumentException("The Array must not be null");
|
||||||
} else if (array.length == 0) {
|
} else if (array.length == 0) {
|
||||||
throw new IllegalArgumentException("Array cannot be empty.");
|
throw new IllegalArgumentException("Array cannot be empty.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue