avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r818296 - in /hadoop/avro/trunk: CHANGES.txt src/java/org/apache/avro/generic/GenericData.java
Date Wed, 23 Sep 2009 22:37:50 GMT
Author: cutting
Date: Wed Sep 23 22:37:49 2009
New Revision: 818296

URL: http://svn.apache.org/viewvc?rev=818296&view=rev
Log:
AVRO-119. Add Java GenericData.Array#toString() implementation.

Modified:
    hadoop/avro/trunk/CHANGES.txt
    hadoop/avro/trunk/src/java/org/apache/avro/generic/GenericData.java

Modified: hadoop/avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=818296&r1=818295&r2=818296&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Wed Sep 23 22:37:49 2009
@@ -18,6 +18,9 @@
     AVRO-116.  Make C++ compatible with Boost 1.32.
     (Scott Banachowski via cutting)
 
+    AVRO-119.  Add Java GenericData.Array#toString() implementation,
+    to facillitate debugging. (cutting)
+
   OPTIMIZATIONS
 
   BUG FIXES

Modified: hadoop/avro/trunk/src/java/org/apache/avro/generic/GenericData.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/java/org/apache/avro/generic/GenericData.java?rev=818296&r1=818295&r2=818296&view=diff
==============================================================================
--- hadoop/avro/trunk/src/java/org/apache/avro/generic/GenericData.java (original)
+++ hadoop/avro/trunk/src/java/org/apache/avro/generic/GenericData.java Wed Sep 23 22:37:49
2009
@@ -115,6 +115,18 @@
     public int compareTo(Array<T> that) {
       return GenericData.get().compare(this, that, this.getSchema());
     }
+    public String toString() {
+      StringBuffer buffer = new StringBuffer();
+      buffer.append("[");
+      int count = 0;
+      for (T e : this) {
+        buffer.append(e==null ? "null" : e.toString());
+        if (++count < size())
+          buffer.append(", ");
+      }
+      buffer.append("]");
+      return buffer.toString();
+    }
   }
 
   public static class Fixed implements GenericFixed, Comparable<Fixed> {



Mime
View raw message