Implemented the toString methods from java.util.Arrays that JAPI pointed
out were missing.

2005-11-07  Anthony Balkissoon  <[EMAIL PROTECTED]>

        * java/util/Arrays.java:
        (toString(long[])): New API method.
        (toString(int[])): Likewise.
        (toString(short[])): Likewise.
        (toString(char[])): Likewise.
        (toString(byte[])): Likewise.
        (toString(boolean[])): Likewise.
        (toString(float[])): Likewise.
        (toString(double[])): Likewise.
        (toString(Object[])): Likewise. 

--Tony
Index: java/util/Arrays.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Arrays.java,v
retrieving revision 1.25
diff -u -r1.25 Arrays.java
--- java/util/Arrays.java	2 Jul 2005 20:32:41 -0000	1.25
+++ java/util/Arrays.java	7 Nov 2005 19:06:14 -0000
@@ -2353,6 +2353,186 @@
   }
 
   /**
+   * Returns a String representation of the argument array.  Returns "null"
+   * if <code>a</code> is null.
+   * @param a the array to represent
+   * @return a String representing this array
+   * @since 1.5
+   */
+  public static String toString (long[] a)
+  {
+    if (a == null)
+      return "null";
+    if (a.length == 0)
+      return "[]";
+    String result = "[";
+    for (int i = 0; i < a.length - 1; i++)
+      result += String.valueOf(a[i]) + ", ";
+    result += String.valueOf(a[a.length - 1]) + "]";
+    return result;
+  }  
+  
+  /**
+   * Returns a String representation of the argument array.  Returns "null"
+   * if <code>a</code> is null.
+   * @param a the array to represent
+   * @return a String representing this array
+   * @since 1.5
+   */
+  public static String toString (int[] a)
+  {
+    if (a == null)
+      return "null";
+    if (a.length == 0)
+      return "[]";
+    String result = "[";
+    for (int i = 0; i < a.length - 1; i++)
+      result += String.valueOf(a[i]) + ", ";
+    result += String.valueOf(a[a.length - 1]) + "]";
+    return result;
+  }  
+  
+  /**
+   * Returns a String representation of the argument array.  Returns "null"
+   * if <code>a</code> is null.
+   * @param a the array to represent
+   * @return a String representing this array
+   * @since 1.5
+   */
+  public static String toString (short[] a)
+  {
+    if (a == null)
+      return "null";
+    if (a.length == 0)
+      return "[]";
+    String result = "[";
+    for (int i = 0; i < a.length - 1; i++)
+      result += String.valueOf(a[i]) + ", ";
+    result += String.valueOf(a[a.length - 1]) + "]";
+    return result;
+  }  
+
+  /**
+   * Returns a String representation of the argument array.  Returns "null"
+   * if <code>a</code> is null.
+   * @param a the array to represent
+   * @return a String representing this array
+   * @since 1.5
+   */
+  public static String toString (char[] a)
+  {
+    if (a == null)
+      return "null";
+    if (a.length == 0)
+      return "[]";
+    String result = "[";
+    for (int i = 0; i < a.length - 1; i++)
+      result += String.valueOf(a[i]) + ", ";
+    result += String.valueOf(a[a.length - 1]) + "]";
+    return result;
+  }  
+
+  /**
+   * Returns a String representation of the argument array.  Returns "null"
+   * if <code>a</code> is null.
+   * @param a the array to represent
+   * @return a String representing this array
+   * @since 1.5
+   */
+  public static String toString (byte[] a)
+  {
+    if (a == null)
+      return "null";
+    if (a.length == 0)
+      return "[]";
+    String result = "[";
+    for (int i = 0; i < a.length - 1; i++)
+      result += String.valueOf(a[i]) + ", ";
+    result += String.valueOf(a[a.length - 1]) + "]";
+    return result;
+  }  
+
+  /**
+   * Returns a String representation of the argument array.  Returns "null"
+   * if <code>a</code> is null.
+   * @param a the array to represent
+   * @return a String representing this array
+   * @since 1.5
+   */
+  public static String toString (boolean[] a)
+  {
+    if (a == null)
+      return "null";
+    if (a.length == 0)
+      return "[]";
+    String result = "[";
+    for (int i = 0; i < a.length - 1; i++)
+      result += String.valueOf(a[i]) + ", ";
+    result += String.valueOf(a[a.length - 1]) + "]";
+    return result;
+  }  
+
+  /**
+   * Returns a String representation of the argument array.  Returns "null"
+   * if <code>a</code> is null.
+   * @param a the array to represent
+   * @return a String representing this array
+   * @since 1.5
+   */
+  public static String toString (float[] a)
+  {
+    if (a == null)
+      return "null";
+    if (a.length == 0)
+      return "[]";
+    String result = "[";
+    for (int i = 0; i < a.length - 1; i++)
+      result += String.valueOf(a[i]) + ", ";
+    result += String.valueOf(a[a.length - 1]) + "]";
+    return result;
+  }  
+  
+  /**
+   * Returns a String representation of the argument array.  Returns "null"
+   * if <code>a</code> is null.
+   * @param a the array to represent
+   * @return a String representing this array
+   * @since 1.5
+   */
+  public static String toString (double[] a)
+  {
+    if (a == null)
+      return "null";
+    if (a.length == 0)
+      return "[]";
+    String result = "[";
+    for (int i = 0; i < a.length - 1; i++)
+      result += String.valueOf(a[i]) + ", ";
+    result += String.valueOf(a[a.length - 1]) + "]";
+    return result;
+  }  
+
+  /**
+   * Returns a String representation of the argument array.  Returns "null"
+   * if <code>a</code> is null.
+   * @param a the array to represent
+   * @return a String representing this array
+   * @since 1.5
+   */
+  public static String toString (Object[] a)
+  {
+    if (a == null)
+      return "null";
+    if (a.length == 0)
+      return "[]";
+    String result = "[";
+    for (int i = 0; i < a.length - 1; i++)
+      result += String.valueOf(a[i]) + ", ";
+    result += String.valueOf(a[a.length - 1]) + "]";
+    return result;
+  }  
+
+  /**
    * Inner class used by [EMAIL PROTECTED] #asList(Object[])} to provide a list interface
    * to an array. The name, though it clashes with java.util.ArrayList, is
    * Sun's choice for Serialization purposes. Element addition and removal
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to