fredrik 2004/01/19 15:24:07
Modified: lang/src/java/org/apache/commons/lang ArrayUtils.java
CharSetUtils.java Validate.java
Log:
Using ArrayUtils.isEmpty() when testing arrays.
Revision Changes Path
1.33 +9 -9
jakarta-commons/lang/src/java/org/apache/commons/lang/ArrayUtils.java
Index: ArrayUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/ArrayUtils.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- ArrayUtils.java 19 Jan 2004 21:50:06 -0000 1.32
+++ ArrayUtils.java 19 Jan 2004 23:24:07 -0000 1.33
@@ -1765,7 +1765,7 @@
* <code>-1</code> if not found or <code>null</code> array input
*/
public static int indexOf(final double[] array, final double valueToFind, int
startIndex) {
- if (array == null || array.length == 0) {
+ if (ArrayUtils.isEmpty(array)) {
return -1;
}
if (startIndex < 0) {
@@ -1797,7 +1797,7 @@
* <code>-1</code> if not found or <code>null</code> array input
*/
public static int indexOf(final double[] array, final double valueToFind, int
startIndex, double tolerance) {
- if (array == null || array.length == 0) {
+ if (ArrayUtils.isEmpty(array)) {
return -1;
}
if (startIndex < 0) {
@@ -1859,7 +1859,7 @@
* <code>-1</code> if not found or <code>null</code> array input
*/
public static int lastIndexOf(final double[] array, final double valueToFind,
int startIndex) {
- if (array == null || array.length == 0) {
+ if (ArrayUtils.isEmpty(array)) {
return -1;
}
if (startIndex < 0) {
@@ -1893,7 +1893,7 @@
* <code>-1</code> if not found or <code>null</code> array input
*/
public static int lastIndexOf(final double[] array, final double valueToFind,
int startIndex, double tolerance) {
- if (array == null || array.length == 0) {
+ if (ArrayUtils.isEmpty(array)) {
return -1;
}
if (startIndex < 0) {
@@ -1972,7 +1972,7 @@
* <code>-1</code> if not found or <code>null</code> array input
*/
public static int indexOf(final float[] array, final float valueToFind, int
startIndex) {
- if (array == null || array.length == 0) {
+ if (ArrayUtils.isEmpty(array)) {
return -1;
}
if (startIndex < 0) {
@@ -2015,7 +2015,7 @@
* <code>-1</code> if not found or <code>null</code> array input
*/
public static int lastIndexOf(final float[] array, final float valueToFind, int
startIndex) {
- if (array == null || array.length == 0) {
+ if (ArrayUtils.isEmpty(array)) {
return -1;
}
if (startIndex < 0) {
@@ -2075,7 +2075,7 @@
* <code>-1</code> if not found or <code>null</code> array input
*/
public static int indexOf(final boolean[] array, final boolean valueToFind, int
startIndex) {
- if (array == null || array.length == 0) {
+ if (ArrayUtils.isEmpty(array)) {
return -1;
}
if (startIndex < 0) {
@@ -2118,7 +2118,7 @@
* <code>-1</code> if not found or <code>null</code> array input
*/
public static int lastIndexOf(final boolean[] array, final boolean valueToFind,
int startIndex) {
- if (array == null || array.length == 0) {
+ if (ArrayUtils.isEmpty(array)) {
return -1;
}
if (startIndex < 0) {
1.30 +6 -6
jakarta-commons/lang/src/java/org/apache/commons/lang/CharSetUtils.java
Index: CharSetUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/CharSetUtils.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- CharSetUtils.java 4 Nov 2003 21:16:34 -0000 1.29
+++ CharSetUtils.java 19 Jan 2004 23:24:07 -0000 1.30
@@ -1,7 +1,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -154,7 +154,7 @@
* @return modified String, <code>null</code> if null string input
*/
public static String squeeze(String str, String[] set) {
- if (StringUtils.isEmpty(str) || set == null || set.length == 0) {
+ if (StringUtils.isEmpty(str) || ArrayUtils.isEmpty(set)) {
return str;
}
CharSet chars = evaluateSet(set);
@@ -220,7 +220,7 @@
* @return character count, zero if null string input
*/
public static int count(String str, String[] set) {
- if (StringUtils.isEmpty(str) || set == null || set.length == 0) {
+ if (StringUtils.isEmpty(str) || ArrayUtils.isEmpty(set)) {
return 0;
}
CharSet chars = evaluateSet(set);
@@ -288,7 +288,7 @@
if (str == null) {
return null;
}
- if (str.length() == 0 || set == null || set.length == 0) {
+ if (str.length() == 0 || ArrayUtils.isEmpty(set)) {
return "";
}
return modify(str, set, true);
@@ -339,7 +339,7 @@
* @return modified String, <code>null</code> if null string input
*/
public static String delete(String str, String[] set) {
- if (StringUtils.isEmpty(str) || set == null || set.length == 0) {
+ if (StringUtils.isEmpty(str) || ArrayUtils.isEmpty(set)) {
return str;
}
return modify(str, set, false);
1.7 +4 -4
jakarta-commons/lang/src/java/org/apache/commons/lang/Validate.java
Index: Validate.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/lang/src/java/org/apache/commons/lang/Validate.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Validate.java 23 Aug 2003 10:39:20 -0000 1.6
+++ Validate.java 19 Jan 2004 23:24:07 -0000 1.7
@@ -1,7 +1,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -273,7 +273,7 @@
* @throws IllegalArgumentException if the array is empty
*/
public static void notEmpty(Object[] array, String message) {
- if (array == null || array.length == 0) {
+ if (ArrayUtils.isEmpty(array)) {
throw new IllegalArgumentException(message);
}
}
@@ -292,7 +292,7 @@
* @throws IllegalArgumentException if the array is empty
*/
public static void notEmpty(Object[] array) {
- if (array == null || array.length == 0) {
+ if (ArrayUtils.isEmpty(array)) {
throw new IllegalArgumentException("The validated array is empty");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]