Move to Commons Base
[lgpl/argeo-commons.git] / osgi / runtime / org.argeo.osgi.boot / src / main / java / org / argeo / osgi / boot / internal / springutil / ObjectUtils.java
diff --git a/osgi/runtime/org.argeo.osgi.boot/src/main/java/org/argeo/osgi/boot/internal/springutil/ObjectUtils.java b/osgi/runtime/org.argeo.osgi.boot/src/main/java/org/argeo/osgi/boot/internal/springutil/ObjectUtils.java
deleted file mode 100644 (file)
index 223b2a1..0000000
+++ /dev/null
@@ -1,833 +0,0 @@
-/*\r
- * Copyright 2002-2007 the original author or authors.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.argeo.osgi.boot.internal.springutil;\r
-\r
-import java.lang.reflect.Array;\r
-import java.util.Arrays;\r
-\r
-/**\r
- * Miscellaneous object utility methods. Mainly for internal use within the\r
- * framework; consider Jakarta's Commons Lang for a more comprehensive suite\r
- * of object utilities.\r
- *\r
- * @author Juergen Hoeller\r
- * @author Keith Donald\r
- * @author Rod Johnson\r
- * @author Rob Harrop\r
- * @author Alex Ruiz\r
- * @since 19.03.2004\r
- * @see org.apache.commons.lang.ObjectUtils\r
- */\r
-public abstract class ObjectUtils {\r
-\r
-       private static final int INITIAL_HASH = 7;\r
-       private static final int MULTIPLIER = 31;\r
-\r
-       private static final String EMPTY_STRING = "";\r
-       private static final String NULL_STRING = "null";\r
-       private static final String ARRAY_START = "{";\r
-       private static final String ARRAY_END = "}";\r
-       private static final String EMPTY_ARRAY = ARRAY_START + ARRAY_END;\r
-       private static final String ARRAY_ELEMENT_SEPARATOR = ", ";\r
-\r
-\r
-       /**\r
-        * Return whether the given throwable is a checked exception:\r
-        * that is, neither a RuntimeException nor an Error.\r
-        * @param ex the throwable to check\r
-        * @return whether the throwable is a checked exception\r
-        * @see java.lang.Exception\r
-        * @see java.lang.RuntimeException\r
-        * @see java.lang.Error\r
-        */\r
-       public static boolean isCheckedException(Throwable ex) {\r
-               return !(ex instanceof RuntimeException || ex instanceof Error);\r
-       }\r
-\r
-       /**\r
-        * Check whether the given exception is compatible with the exceptions\r
-        * declared in a throws clause.\r
-        * @param ex the exception to checked\r
-        * @param declaredExceptions the exceptions declared in the throws clause\r
-        * @return whether the given exception is compatible\r
-        */\r
-       public static boolean isCompatibleWithThrowsClause(Throwable ex, Class[] declaredExceptions) {\r
-               if (!isCheckedException(ex)) {\r
-                       return true;\r
-               }\r
-               if (declaredExceptions != null) {\r
-                       for (int i = 0; i < declaredExceptions.length; i++) {\r
-                               if (declaredExceptions[i].isAssignableFrom(ex.getClass())) {\r
-                                       return true;\r
-                               }\r
-                       }\r
-               }\r
-               return false;\r
-       }\r
-\r
-       /**\r
-        * Return whether the given array is empty: that is, <code>null</code>\r
-        * or of zero length.\r
-        * @param array the array to check\r
-        * @return whether the given array is empty\r
-        */\r
-       public static boolean isEmpty(Object[] array) {\r
-               return (array == null || array.length == 0);\r
-       }\r
-\r
-       /**\r
-        * Check whether the given array contains the given element.\r
-        * @param array the array to check (may be <code>null</code>,\r
-        * in which case the return value will always be <code>false</code>)\r
-        * @param element the element to check for\r
-        * @return whether the element has been found in the given array\r
-        */\r
-       public static boolean containsElement(Object[] array, Object element) {\r
-               if (array == null) {\r
-                       return false;\r
-               }\r
-               for (int i = 0; i < array.length; i++) {\r
-                       if (nullSafeEquals(array[i], element)) {\r
-                               return true;\r
-                       }\r
-               }\r
-               return false;\r
-       }\r
-\r
-       /**\r
-        * Append the given Object to the given array, returning a new array\r
-        * consisting of the input array contents plus the given Object.\r
-        * @param array the array to append to (can be <code>null</code>)\r
-        * @param obj the Object to append\r
-        * @return the new array (of the same component type; never <code>null</code>)\r
-        */\r
-       public static Object[] addObjectToArray(Object[] array, Object obj) {\r
-               Class compType = Object.class;\r
-               if (array != null) {\r
-                       compType = array.getClass().getComponentType();\r
-               }\r
-               else if (obj != null) {\r
-                       compType = obj.getClass();\r
-               }\r
-               int newArrLength = (array != null ? array.length + 1 : 1);\r
-               Object[] newArr = (Object[]) Array.newInstance(compType, newArrLength);\r
-               if (array != null) {\r
-                       System.arraycopy(array, 0, newArr, 0, array.length);\r
-               }\r
-               newArr[newArr.length - 1] = obj;\r
-               return newArr;\r
-       }\r
-\r
-       /**\r
-        * Convert the given array (which may be a primitive array) to an\r
-        * object array (if necessary of primitive wrapper objects).\r
-        * <p>A <code>null</code> source value will be converted to an\r
-        * empty Object array.\r
-        * @param source the (potentially primitive) array\r
-        * @return the corresponding object array (never <code>null</code>)\r
-        * @throws IllegalArgumentException if the parameter is not an array\r
-        */\r
-       public static Object[] toObjectArray(Object source) {\r
-               if (source instanceof Object[]) {\r
-                       return (Object[]) source;\r
-               }\r
-               if (source == null) {\r
-                       return new Object[0];\r
-               }\r
-               if (!source.getClass().isArray()) {\r
-                       throw new IllegalArgumentException("Source is not an array: " + source);\r
-               }\r
-               int length = Array.getLength(source);\r
-               if (length == 0) {\r
-                       return new Object[0];\r
-               }\r
-               Class wrapperType = Array.get(source, 0).getClass();\r
-               Object[] newArray = (Object[]) Array.newInstance(wrapperType, length);\r
-               for (int i = 0; i < length; i++) {\r
-                       newArray[i] = Array.get(source, i);\r
-               }\r
-               return newArray;\r
-       }\r
-\r
-\r
-       //---------------------------------------------------------------------\r
-       // Convenience methods for content-based equality/hash-code handling\r
-       //---------------------------------------------------------------------\r
-\r
-       /**\r
-        * Determine if the given objects are equal, returning <code>true</code>\r
-        * if both are <code>null</code> or <code>false</code> if only one is\r
-        * <code>null</code>.\r
-        * <p>Compares arrays with <code>Arrays.equals</code>, performing an equality\r
-        * check based on the array elements rather than the array reference.\r
-        * @param o1 first Object to compare\r
-        * @param o2 second Object to compare\r
-        * @return whether the given objects are equal\r
-        * @see java.util.Arrays#equals\r
-        */\r
-       public static boolean nullSafeEquals(Object o1, Object o2) {\r
-               if (o1 == o2) {\r
-                       return true;\r
-               }\r
-               if (o1 == null || o2 == null) {\r
-                       return false;\r
-               }\r
-               if (o1.equals(o2)) {\r
-                       return true;\r
-               }\r
-               if (o1.getClass().isArray() && o2.getClass().isArray()) {\r
-                       if (o1 instanceof Object[] && o2 instanceof Object[]) {\r
-                               return Arrays.equals((Object[]) o1, (Object[]) o2);\r
-                       }\r
-                       if (o1 instanceof boolean[] && o2 instanceof boolean[]) {\r
-                               return Arrays.equals((boolean[]) o1, (boolean[]) o2);\r
-                       }\r
-                       if (o1 instanceof byte[] && o2 instanceof byte[]) {\r
-                               return Arrays.equals((byte[]) o1, (byte[]) o2);\r
-                       }\r
-                       if (o1 instanceof char[] && o2 instanceof char[]) {\r
-                               return Arrays.equals((char[]) o1, (char[]) o2);\r
-                       }\r
-                       if (o1 instanceof double[] && o2 instanceof double[]) {\r
-                               return Arrays.equals((double[]) o1, (double[]) o2);\r
-                       }\r
-                       if (o1 instanceof float[] && o2 instanceof float[]) {\r
-                               return Arrays.equals((float[]) o1, (float[]) o2);\r
-                       }\r
-                       if (o1 instanceof int[] && o2 instanceof int[]) {\r
-                               return Arrays.equals((int[]) o1, (int[]) o2);\r
-                       }\r
-                       if (o1 instanceof long[] && o2 instanceof long[]) {\r
-                               return Arrays.equals((long[]) o1, (long[]) o2);\r
-                       }\r
-                       if (o1 instanceof short[] && o2 instanceof short[]) {\r
-                               return Arrays.equals((short[]) o1, (short[]) o2);\r
-                       }\r
-               }\r
-               return false;\r
-       }\r
-\r
-       /**\r
-        * Return as hash code for the given object; typically the value of\r
-        * <code>{@link Object#hashCode()}</code>. If the object is an array,\r
-        * this method will delegate to any of the <code>nullSafeHashCode</code>\r
-        * methods for arrays in this class. If the object is <code>null</code>,\r
-        * this method returns 0.\r
-        * @see #nullSafeHashCode(Object[])\r
-        * @see #nullSafeHashCode(boolean[])\r
-        * @see #nullSafeHashCode(byte[])\r
-        * @see #nullSafeHashCode(char[])\r
-        * @see #nullSafeHashCode(double[])\r
-        * @see #nullSafeHashCode(float[])\r
-        * @see #nullSafeHashCode(int[])\r
-        * @see #nullSafeHashCode(long[])\r
-        * @see #nullSafeHashCode(short[])\r
-        */\r
-       public static int nullSafeHashCode(Object obj) {\r
-               if (obj == null) {\r
-                       return 0;\r
-               }\r
-               if (obj.getClass().isArray()) {\r
-                       if (obj instanceof Object[]) {\r
-                               return nullSafeHashCode((Object[]) obj);\r
-                       }\r
-                       if (obj instanceof boolean[]) {\r
-                               return nullSafeHashCode((boolean[]) obj);\r
-                       }\r
-                       if (obj instanceof byte[]) {\r
-                               return nullSafeHashCode((byte[]) obj);\r
-                       }\r
-                       if (obj instanceof char[]) {\r
-                               return nullSafeHashCode((char[]) obj);\r
-                       }\r
-                       if (obj instanceof double[]) {\r
-                               return nullSafeHashCode((double[]) obj);\r
-                       }\r
-                       if (obj instanceof float[]) {\r
-                               return nullSafeHashCode((float[]) obj);\r
-                       }\r
-                       if (obj instanceof int[]) {\r
-                               return nullSafeHashCode((int[]) obj);\r
-                       }\r
-                       if (obj instanceof long[]) {\r
-                               return nullSafeHashCode((long[]) obj);\r
-                       }\r
-                       if (obj instanceof short[]) {\r
-                               return nullSafeHashCode((short[]) obj);\r
-                       }\r
-               }\r
-               return obj.hashCode();\r
-       }\r
-\r
-       /**\r
-        * Return a hash code based on the contents of the specified array.\r
-        * If <code>array</code> is <code>null</code>, this method returns 0.\r
-        */\r
-       public static int nullSafeHashCode(Object[] array) {\r
-               if (array == null) {\r
-                       return 0;\r
-               }\r
-               int hash = INITIAL_HASH;\r
-               int arraySize = array.length;\r
-               for (int i = 0; i < arraySize; i++) {\r
-                       hash = MULTIPLIER * hash + nullSafeHashCode(array[i]);\r
-               }\r
-               return hash;\r
-       }\r
-\r
-       /**\r
-        * Return a hash code based on the contents of the specified array.\r
-        * If <code>array</code> is <code>null</code>, this method returns 0.\r
-        */\r
-       public static int nullSafeHashCode(boolean[] array) {\r
-               if (array == null) {\r
-                       return 0;\r
-               }\r
-               int hash = INITIAL_HASH;\r
-               int arraySize = array.length;\r
-               for (int i = 0; i < arraySize; i++) {\r
-                       hash = MULTIPLIER * hash + hashCode(array[i]);\r
-               }\r
-               return hash;\r
-       }\r
-\r
-       /**\r
-        * Return a hash code based on the contents of the specified array.\r
-        * If <code>array</code> is <code>null</code>, this method returns 0.\r
-        */\r
-       public static int nullSafeHashCode(byte[] array) {\r
-               if (array == null) {\r
-                       return 0;\r
-               }\r
-               int hash = INITIAL_HASH;\r
-               int arraySize = array.length;\r
-               for (int i = 0; i < arraySize; i++) {\r
-                       hash = MULTIPLIER * hash + array[i];\r
-               }\r
-               return hash;\r
-       }\r
-\r
-       /**\r
-        * Return a hash code based on the contents of the specified array.\r
-        * If <code>array</code> is <code>null</code>, this method returns 0.\r
-        */\r
-       public static int nullSafeHashCode(char[] array) {\r
-               if (array == null) {\r
-                       return 0;\r
-               }\r
-               int hash = INITIAL_HASH;\r
-               int arraySize = array.length;\r
-               for (int i = 0; i < arraySize; i++) {\r
-                       hash = MULTIPLIER * hash + array[i];\r
-               }\r
-               return hash;\r
-       }\r
-\r
-       /**\r
-        * Return a hash code based on the contents of the specified array.\r
-        * If <code>array</code> is <code>null</code>, this method returns 0.\r
-        */\r
-       public static int nullSafeHashCode(double[] array) {\r
-               if (array == null) {\r
-                       return 0;\r
-               }\r
-               int hash = INITIAL_HASH;\r
-               int arraySize = array.length;\r
-               for (int i = 0; i < arraySize; i++) {\r
-                       hash = MULTIPLIER * hash + hashCode(array[i]);\r
-               }\r
-               return hash;\r
-       }\r
-\r
-       /**\r
-        * Return a hash code based on the contents of the specified array.\r
-        * If <code>array</code> is <code>null</code>, this method returns 0.\r
-        */\r
-       public static int nullSafeHashCode(float[] array) {\r
-               if (array == null) {\r
-                       return 0;\r
-               }\r
-               int hash = INITIAL_HASH;\r
-               int arraySize = array.length;\r
-               for (int i = 0; i < arraySize; i++) {\r
-                       hash = MULTIPLIER * hash + hashCode(array[i]);\r
-               }\r
-               return hash;\r
-       }\r
-\r
-       /**\r
-        * Return a hash code based on the contents of the specified array.\r
-        * If <code>array</code> is <code>null</code>, this method returns 0.\r
-        */\r
-       public static int nullSafeHashCode(int[] array) {\r
-               if (array == null) {\r
-                       return 0;\r
-               }\r
-               int hash = INITIAL_HASH;\r
-               int arraySize = array.length;\r
-               for (int i = 0; i < arraySize; i++) {\r
-                       hash = MULTIPLIER * hash + array[i];\r
-               }\r
-               return hash;\r
-       }\r
-\r
-       /**\r
-        * Return a hash code based on the contents of the specified array.\r
-        * If <code>array</code> is <code>null</code>, this method returns 0.\r
-        */\r
-       public static int nullSafeHashCode(long[] array) {\r
-               if (array == null) {\r
-                       return 0;\r
-               }\r
-               int hash = INITIAL_HASH;\r
-               int arraySize = array.length;\r
-               for (int i = 0; i < arraySize; i++) {\r
-                       hash = MULTIPLIER * hash + hashCode(array[i]);\r
-               }\r
-               return hash;\r
-       }\r
-\r
-       /**\r
-        * Return a hash code based on the contents of the specified array.\r
-        * If <code>array</code> is <code>null</code>, this method returns 0.\r
-        */\r
-       public static int nullSafeHashCode(short[] array) {\r
-               if (array == null) {\r
-                       return 0;\r
-               }\r
-               int hash = INITIAL_HASH;\r
-               int arraySize = array.length;\r
-               for (int i = 0; i < arraySize; i++) {\r
-                       hash = MULTIPLIER * hash + array[i];\r
-               }\r
-               return hash;\r
-       }\r
-\r
-       /**\r
-        * Return the same value as <code>{@link Boolean#hashCode()}</code>.\r
-        * @see Boolean#hashCode()\r
-        */\r
-       public static int hashCode(boolean bool) {\r
-               return bool ? 1231 : 1237;\r
-       }\r
-\r
-       /**\r
-        * Return the same value as <code>{@link Double#hashCode()}</code>.\r
-        * @see Double#hashCode()\r
-        */\r
-       public static int hashCode(double dbl) {\r
-               long bits = Double.doubleToLongBits(dbl);\r
-               return hashCode(bits);\r
-       }\r
-\r
-       /**\r
-        * Return the same value as <code>{@link Float#hashCode()}</code>.\r
-        * @see Float#hashCode()\r
-        */\r
-       public static int hashCode(float flt) {\r
-               return Float.floatToIntBits(flt);\r
-       }\r
-\r
-       /**\r
-        * Return the same value as <code>{@link Long#hashCode()}</code>.\r
-        * @see Long#hashCode()\r
-        */\r
-       public static int hashCode(long lng) {\r
-               return (int) (lng ^ (lng >>> 32));\r
-       }\r
-\r
-\r
-       //---------------------------------------------------------------------\r
-       // Convenience methods for toString output\r
-       //---------------------------------------------------------------------\r
-\r
-       /**\r
-        * Return a String representation of an object's overall identity.\r
-        * @param obj the object (may be <code>null</code>)\r
-        * @return the object's identity as String representation,\r
-        * or an empty String if the object was <code>null</code>\r
-        */\r
-       public static String identityToString(Object obj) {\r
-               if (obj == null) {\r
-                       return EMPTY_STRING;\r
-               }\r
-               return obj.getClass().getName() + "@" + getIdentityHexString(obj);\r
-       }\r
-\r
-       /**\r
-        * Return a hex String form of an object's identity hash code.\r
-        * @param obj the object\r
-        * @return the object's identity code in hex notation\r
-        */\r
-       public static String getIdentityHexString(Object obj) {\r
-               return Integer.toHexString(System.identityHashCode(obj));\r
-       }\r
-\r
-       /**\r
-        * Return a content-based String representation if <code>obj</code> is\r
-        * not <code>null</code>; otherwise returns an empty String.\r
-        * <p>Differs from {@link #nullSafeToString(Object)} in that it returns\r
-        * an empty String rather than "null" for a <code>null</code> value.\r
-        * @param obj the object to build a display String for\r
-        * @return a display String representation of <code>obj</code>\r
-        * @see #nullSafeToString(Object)\r
-        */\r
-       public static String getDisplayString(Object obj) {\r
-               if (obj == null) {\r
-                       return EMPTY_STRING;\r
-               }\r
-               return nullSafeToString(obj);\r
-       }\r
-\r
-       /**\r
-        * Determine the class name for the given object.\r
-        * <p>Returns <code>"null"</code> if <code>obj</code> is <code>null</code>.\r
-        * @param obj the object to introspect (may be <code>null</code>)\r
-        * @return the corresponding class name\r
-        */\r
-       public static String nullSafeClassName(Object obj) {\r
-               return (obj != null ? obj.getClass().getName() : NULL_STRING);\r
-       }\r
-\r
-       /**\r
-        * Return a String representation of the specified Object.\r
-        * <p>Builds a String representation of the contents in case of an array.\r
-        * Returns <code>"null"</code> if <code>obj</code> is <code>null</code>.\r
-        * @param obj the object to build a String representation for\r
-        * @return a String representation of <code>obj</code>\r
-        */\r
-       public static String nullSafeToString(Object obj) {\r
-               if (obj == null) {\r
-                       return NULL_STRING;\r
-               }\r
-               if (obj instanceof String) {\r
-                       return (String) obj;\r
-               }\r
-               if (obj instanceof Object[]) {\r
-                       return nullSafeToString((Object[]) obj);\r
-               }\r
-               if (obj instanceof boolean[]) {\r
-                       return nullSafeToString((boolean[]) obj);\r
-               }\r
-               if (obj instanceof byte[]) {\r
-                       return nullSafeToString((byte[]) obj);\r
-               }\r
-               if (obj instanceof char[]) {\r
-                       return nullSafeToString((char[]) obj);\r
-               }\r
-               if (obj instanceof double[]) {\r
-                       return nullSafeToString((double[]) obj);\r
-               }\r
-               if (obj instanceof float[]) {\r
-                       return nullSafeToString((float[]) obj);\r
-               }\r
-               if (obj instanceof int[]) {\r
-                       return nullSafeToString((int[]) obj);\r
-               }\r
-               if (obj instanceof long[]) {\r
-                       return nullSafeToString((long[]) obj);\r
-               }\r
-               if (obj instanceof short[]) {\r
-                       return nullSafeToString((short[]) obj);\r
-               }\r
-               String str = obj.toString();\r
-               return (str != null ? str : EMPTY_STRING);\r
-       }\r
-\r
-       /**\r
-        * Return a String representation of the contents of the specified array.\r
-        * <p>The String representation consists of a list of the array's elements,\r
-        * enclosed in curly braces (<code>"{}"</code>). Adjacent elements are separated\r
-        * by the characters <code>", "</code> (a comma followed by a space). Returns\r
-        * <code>"null"</code> if <code>array</code> is <code>null</code>.\r
-        * @param array the array to build a String representation for\r
-        * @return a String representation of <code>array</code>\r
-        */\r
-       public static String nullSafeToString(Object[] array) {\r
-               if (array == null) {\r
-                       return NULL_STRING;\r
-               }\r
-               int length = array.length;\r
-               if (length == 0) {\r
-                       return EMPTY_ARRAY;\r
-               }\r
-               StringBuffer buffer = new StringBuffer();\r
-               for (int i = 0; i < length; i++) {\r
-                       if (i == 0) {\r
-                               buffer.append(ARRAY_START);\r
-                       }\r
-                       else {\r
-                               buffer.append(ARRAY_ELEMENT_SEPARATOR);\r
-                       }\r
-                       buffer.append(String.valueOf(array[i]));\r
-               }\r
-               buffer.append(ARRAY_END);\r
-               return buffer.toString();\r
-       }\r
-\r
-       /**\r
-        * Return a String representation of the contents of the specified array.\r
-        * <p>The String representation consists of a list of the array's elements,\r
-        * enclosed in curly braces (<code>"{}"</code>). Adjacent elements are separated\r
-        * by the characters <code>", "</code> (a comma followed by a space). Returns\r
-        * <code>"null"</code> if <code>array</code> is <code>null</code>.\r
-        * @param array the array to build a String representation for\r
-        * @return a String representation of <code>array</code>\r
-        */\r
-       public static String nullSafeToString(boolean[] array) {\r
-               if (array == null) {\r
-                       return NULL_STRING;\r
-               }\r
-               int length = array.length;\r
-               if (length == 0) {\r
-                       return EMPTY_ARRAY;\r
-               }\r
-               StringBuffer buffer = new StringBuffer();\r
-               for (int i = 0; i < length; i++) {\r
-                       if (i == 0) {\r
-                               buffer.append(ARRAY_START);\r
-                       }\r
-                       else {\r
-                               buffer.append(ARRAY_ELEMENT_SEPARATOR);\r
-                       }\r
-\r
-                       buffer.append(array[i]);\r
-               }\r
-               buffer.append(ARRAY_END);\r
-               return buffer.toString();\r
-       }\r
-\r
-       /**\r
-        * Return a String representation of the contents of the specified array.\r
-        * <p>The String representation consists of a list of the array's elements,\r
-        * enclosed in curly braces (<code>"{}"</code>). Adjacent elements are separated\r
-        * by the characters <code>", "</code> (a comma followed by a space). Returns\r
-        * <code>"null"</code> if <code>array</code> is <code>null</code>.\r
-        * @param array the array to build a String representation for\r
-        * @return a String representation of <code>array</code>\r
-        */\r
-       public static String nullSafeToString(byte[] array) {\r
-               if (array == null) {\r
-                       return NULL_STRING;\r
-               }\r
-               int length = array.length;\r
-               if (length == 0) {\r
-                       return EMPTY_ARRAY;\r
-               }\r
-               StringBuffer buffer = new StringBuffer();\r
-               for (int i = 0; i < length; i++) {\r
-                       if (i == 0) {\r
-                               buffer.append(ARRAY_START);\r
-                       }\r
-                       else {\r
-                               buffer.append(ARRAY_ELEMENT_SEPARATOR);\r
-                       }\r
-                       buffer.append(array[i]);\r
-               }\r
-               buffer.append(ARRAY_END);\r
-               return buffer.toString();\r
-       }\r
-\r
-       /**\r
-        * Return a String representation of the contents of the specified array.\r
-        * <p>The String representation consists of a list of the array's elements,\r
-        * enclosed in curly braces (<code>"{}"</code>). Adjacent elements are separated\r
-        * by the characters <code>", "</code> (a comma followed by a space). Returns\r
-        * <code>"null"</code> if <code>array</code> is <code>null</code>.\r
-        * @param array the array to build a String representation for\r
-        * @return a String representation of <code>array</code>\r
-        */\r
-       public static String nullSafeToString(char[] array) {\r
-               if (array == null) {\r
-                       return NULL_STRING;\r
-               }\r
-               int length = array.length;\r
-               if (length == 0) {\r
-                       return EMPTY_ARRAY;\r
-               }\r
-               StringBuffer buffer = new StringBuffer();\r
-               for (int i = 0; i < length; i++) {\r
-                       if (i == 0) {\r
-                               buffer.append(ARRAY_START);\r
-                       }\r
-                       else {\r
-                               buffer.append(ARRAY_ELEMENT_SEPARATOR);\r
-                       }\r
-                       buffer.append("'").append(array[i]).append("'");\r
-               }\r
-               buffer.append(ARRAY_END);\r
-               return buffer.toString();\r
-       }\r
-\r
-       /**\r
-        * Return a String representation of the contents of the specified array.\r
-        * <p>The String representation consists of a list of the array's elements,\r
-        * enclosed in curly braces (<code>"{}"</code>). Adjacent elements are separated\r
-        * by the characters <code>", "</code> (a comma followed by a space). Returns\r
-        * <code>"null"</code> if <code>array</code> is <code>null</code>.\r
-        * @param array the array to build a String representation for\r
-        * @return a String representation of <code>array</code>\r
-        */\r
-       public static String nullSafeToString(double[] array) {\r
-               if (array == null) {\r
-                       return NULL_STRING;\r
-               }\r
-               int length = array.length;\r
-               if (length == 0) {\r
-                       return EMPTY_ARRAY;\r
-               }\r
-               StringBuffer buffer = new StringBuffer();\r
-               for (int i = 0; i < length; i++) {\r
-                       if (i == 0) {\r
-                               buffer.append(ARRAY_START);\r
-                       }\r
-                       else {\r
-                               buffer.append(ARRAY_ELEMENT_SEPARATOR);\r
-                       }\r
-\r
-                       buffer.append(array[i]);\r
-               }\r
-               buffer.append(ARRAY_END);\r
-               return buffer.toString();\r
-       }\r
-\r
-       /**\r
-        * Return a String representation of the contents of the specified array.\r
-        * <p>The String representation consists of a list of the array's elements,\r
-        * enclosed in curly braces (<code>"{}"</code>). Adjacent elements are separated\r
-        * by the characters <code>", "</code> (a comma followed by a space). Returns\r
-        * <code>"null"</code> if <code>array</code> is <code>null</code>.\r
-        * @param array the array to build a String representation for\r
-        * @return a String representation of <code>array</code>\r
-        */\r
-       public static String nullSafeToString(float[] array) {\r
-               if (array == null) {\r
-                       return NULL_STRING;\r
-               }\r
-               int length = array.length;\r
-               if (length == 0) {\r
-                       return EMPTY_ARRAY;\r
-               }\r
-               StringBuffer buffer = new StringBuffer();\r
-               for (int i = 0; i < length; i++) {\r
-                       if (i == 0) {\r
-                               buffer.append(ARRAY_START);\r
-                       }\r
-                       else {\r
-                               buffer.append(ARRAY_ELEMENT_SEPARATOR);\r
-                       }\r
-\r
-                       buffer.append(array[i]);\r
-               }\r
-               buffer.append(ARRAY_END);\r
-               return buffer.toString();\r
-       }\r
-\r
-       /**\r
-        * Return a String representation of the contents of the specified array.\r
-        * <p>The String representation consists of a list of the array's elements,\r
-        * enclosed in curly braces (<code>"{}"</code>). Adjacent elements are separated\r
-        * by the characters <code>", "</code> (a comma followed by a space). Returns\r
-        * <code>"null"</code> if <code>array</code> is <code>null</code>.\r
-        * @param array the array to build a String representation for\r
-        * @return a String representation of <code>array</code>\r
-        */\r
-       public static String nullSafeToString(int[] array) {\r
-               if (array == null) {\r
-                       return NULL_STRING;\r
-               }\r
-               int length = array.length;\r
-               if (length == 0) {\r
-                       return EMPTY_ARRAY;\r
-               }\r
-               StringBuffer buffer = new StringBuffer();\r
-               for (int i = 0; i < length; i++) {\r
-                       if (i == 0) {\r
-                               buffer.append(ARRAY_START);\r
-                       }\r
-                       else {\r
-                               buffer.append(ARRAY_ELEMENT_SEPARATOR);\r
-                       }\r
-                       buffer.append(array[i]);\r
-               }\r
-               buffer.append(ARRAY_END);\r
-               return buffer.toString();\r
-       }\r
-\r
-       /**\r
-        * Return a String representation of the contents of the specified array.\r
-        * <p>The String representation consists of a list of the array's elements,\r
-        * enclosed in curly braces (<code>"{}"</code>). Adjacent elements are separated\r
-        * by the characters <code>", "</code> (a comma followed by a space). Returns\r
-        * <code>"null"</code> if <code>array</code> is <code>null</code>.\r
-        * @param array the array to build a String representation for\r
-        * @return a String representation of <code>array</code>\r
-        */\r
-       public static String nullSafeToString(long[] array) {\r
-               if (array == null) {\r
-                       return NULL_STRING;\r
-               }\r
-               int length = array.length;\r
-               if (length == 0) {\r
-                       return EMPTY_ARRAY;\r
-               }\r
-               StringBuffer buffer = new StringBuffer();\r
-               for (int i = 0; i < length; i++) {\r
-                       if (i == 0) {\r
-                               buffer.append(ARRAY_START);\r
-                       }\r
-                       else {\r
-                               buffer.append(ARRAY_ELEMENT_SEPARATOR);\r
-                       }\r
-                       buffer.append(array[i]);\r
-               }\r
-               buffer.append(ARRAY_END);\r
-               return buffer.toString();\r
-       }\r
-\r
-       /**\r
-        * Return a String representation of the contents of the specified array.\r
-        * <p>The String representation consists of a list of the array's elements,\r
-        * enclosed in curly braces (<code>"{}"</code>). Adjacent elements are separated\r
-        * by the characters <code>", "</code> (a comma followed by a space). Returns\r
-        * <code>"null"</code> if <code>array</code> is <code>null</code>.\r
-        * @param array the array to build a String representation for\r
-        * @return a String representation of <code>array</code>\r
-        */\r
-       public static String nullSafeToString(short[] array) {\r
-               if (array == null) {\r
-                       return NULL_STRING;\r
-               }\r
-               int length = array.length;\r
-               if (length == 0) {\r
-                       return EMPTY_ARRAY;\r
-               }\r
-               StringBuffer buffer = new StringBuffer();\r
-               for (int i = 0; i < length; i++) {\r
-                       if (i == 0) {\r
-                               buffer.append(ARRAY_START);\r
-                       }\r
-                       else {\r
-                               buffer.append(ARRAY_ELEMENT_SEPARATOR);\r
-                       }\r
-                       buffer.append(array[i]);\r
-               }\r
-               buffer.append(ARRAY_END);\r
-               return buffer.toString();\r
-       }\r
-\r
-}\r