avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1162253 [2/2] - in /avro/trunk: ./ lang/java/avro/src/main/java/org/apache/avro/ lang/java/avro/src/main/java/org/apache/avro/data/ lang/java/avro/src/main/java/org/apache/avro/generic/ lang/java/avro/src/main/java/org/apache/avro/io/parsi...
Date Fri, 26 Aug 2011 20:54:52 GMT
Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java?rev=1162253&r1=1162252&r2=1162253&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java Fri Aug 26 20:54:50 2011
@@ -24,6 +24,7 @@ import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
@@ -36,6 +37,8 @@ import javax.tools.JavaCompiler.Compilat
 import org.apache.avro.AvroTestUtil;
 import org.apache.avro.Protocol;
 import org.apache.avro.Schema;
+import org.apache.avro.Schema.Field;
+import org.apache.avro.Schema.Type;
 import org.apache.avro.TestProtocolParsing;
 import org.apache.avro.TestSchema;
 import org.apache.avro.compiler.specific.SpecificCompiler.OutputFile;
@@ -222,6 +225,404 @@ public class TestSpecificCompiler {
     SpecificCompiler.compileSchema(inputFile, outputDir);
     assertTrue(lastModified != outputFile.lastModified());
   }
+  
+  /**
+   * Creates a record with the given name, error status, and fields.
+   * @param name the name of the schema.
+   * @param isError true if the schema represents an error; false otherwise.
+   * @param fields the field(s) to add to the schema.
+   * @return the schema.
+   */
+  private Schema createRecord(String name, 
+      boolean isError, Field... fields) {
+    Schema record = Schema.createRecord(name, null, null, isError);
+    record.setFields(Arrays.asList(fields));
+    return record;
+  }
+  
+  @Test
+  public void generateGetMethod() {
+    Field height = new Field("height", Schema.create(Type.INT), null, null);
+    Field Height = new Field("Height", Schema.create(Type.INT), null, null);
+    Field height_and_width = 
+        new Field("height_and_width", Schema.create(Type.STRING), null, null);
+    Field message = 
+        new Field("message", Schema.create(Type.STRING), null, null);
+    Field Message = 
+        new Field("Message", Schema.create(Type.STRING), null, null);
+    Field cause = 
+        new Field("cause", Schema.create(Type.STRING), null, null);
+    Field clasz = 
+        new Field("class", Schema.create(Type.STRING), null, null);
+    Field schema = 
+        new Field("schema", Schema.create(Type.STRING), null, null);
+    Field Schema$ = 
+        new Field("Schema", Schema.create(Type.STRING), null, null);
+    
+    assertEquals("getHeight", SpecificCompiler.generateGetMethod(
+        createRecord("test", false, height), height));
+    
+    assertEquals("getHeightAndWidth", SpecificCompiler.generateGetMethod(
+        createRecord("test", false, height_and_width), height_and_width));
+  
+    assertEquals("getMessage", SpecificCompiler.generateGetMethod(
+        createRecord("test", false, message), message));
+    message = new Field("message", Schema.create(Type.STRING), null, null);
+    assertEquals("getMessage$", SpecificCompiler.generateGetMethod(
+        createRecord("test", true, message), message));
+ 
+    assertEquals("getCause", SpecificCompiler.generateGetMethod(
+        createRecord("test", false, cause), cause));
+    cause = new Field("cause", Schema.create(Type.STRING), null, null);
+    assertEquals("getCause$", SpecificCompiler.generateGetMethod(
+        createRecord("test", true, cause), cause));
+
+    
+    assertEquals("getClass$", SpecificCompiler.generateGetMethod(
+        createRecord("test", false, clasz), clasz));
+    clasz = new Field("class", Schema.create(Type.STRING), null, null);
+    assertEquals("getClass$", SpecificCompiler.generateGetMethod(
+        createRecord("test", true, clasz), clasz));
+
+    assertEquals("getSchema$", SpecificCompiler.generateGetMethod(
+        createRecord("test", false, schema), schema));
+    schema = new Field("schema", Schema.create(Type.STRING), null, null);
+    assertEquals("getSchema$", SpecificCompiler.generateGetMethod(
+        createRecord("test", true, schema), schema));
+
+    height = new Field("height", Schema.create(Type.INT), null, null);
+    Height = new Field("Height", Schema.create(Type.INT), null, null);
+    assertEquals("getHeight", SpecificCompiler.generateGetMethod(
+        createRecord("test", false, Height), Height));
+    
+    height = new Field("height", Schema.create(Type.INT), null, null);
+    Height = new Field("Height", Schema.create(Type.INT), null, null);
+    assertEquals("getHeight$0", SpecificCompiler.generateGetMethod(
+        createRecord("test", false, height, Height), height));
+    
+    height = new Field("height", Schema.create(Type.INT), null, null);
+    Height = new Field("Height", Schema.create(Type.INT), null, null);
+    assertEquals("getHeight$1", SpecificCompiler.generateGetMethod(
+        createRecord("test", false, height, Height), Height));
+    
+    message = new Field("message", Schema.create(Type.STRING), null, null);
+    Message = new Field("Message", Schema.create(Type.STRING), null, null);
+    assertEquals("getMessage$", SpecificCompiler.generateGetMethod(
+        createRecord("test", true, Message), Message));
+    
+    message = new Field("message", Schema.create(Type.STRING), null, null);
+    Message = new Field("Message", Schema.create(Type.STRING), null, null);
+    assertEquals("getMessage$0", SpecificCompiler.generateGetMethod(
+        createRecord("test", true, message, Message), message));
+    
+    message = new Field("message", Schema.create(Type.STRING), null, null);
+    Message = new Field("Message", Schema.create(Type.STRING), null, null);
+    assertEquals("getMessage$1", SpecificCompiler.generateGetMethod(
+        createRecord("test", true, message, Message), Message));
+    
+    schema = new Field("schema", Schema.create(Type.STRING), null, null);
+    Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
+    assertEquals("getSchema$", SpecificCompiler.generateGetMethod(
+        createRecord("test", false, Schema$), Schema$));
+    
+    schema = new Field("schema", Schema.create(Type.STRING), null, null);
+    Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
+    assertEquals("getSchema$0", SpecificCompiler.generateGetMethod(
+        createRecord("test", false, schema, Schema$), schema));
+    
+    schema = new Field("schema", Schema.create(Type.STRING), null, null);
+    Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
+    assertEquals("getSchema$1", SpecificCompiler.generateGetMethod(
+        createRecord("test", false, schema, Schema$), Schema$));
+  }
+
+  @Test
+  public void generateSetMethod() {
+    Field height = new Field("height", Schema.create(Type.INT), null, null);
+    Field Height = new Field("Height", Schema.create(Type.INT), null, null);
+    Field height_and_width = 
+        new Field("height_and_width", Schema.create(Type.STRING), null, null);
+    Field message = 
+        new Field("message", Schema.create(Type.STRING), null, null);
+    Field Message = 
+        new Field("Message", Schema.create(Type.STRING), null, null);
+    Field cause = 
+        new Field("cause", Schema.create(Type.STRING), null, null);
+    Field clasz = 
+        new Field("class", Schema.create(Type.STRING), null, null);
+    Field schema = 
+        new Field("schema", Schema.create(Type.STRING), null, null);
+    Field Schema$ = 
+        new Field("Schema", Schema.create(Type.STRING), null, null);
+    
+    assertEquals("setHeight", SpecificCompiler.generateSetMethod(
+        createRecord("test", false, height), height));
+    
+    assertEquals("setHeightAndWidth", SpecificCompiler.generateSetMethod(
+        createRecord("test", false, height_and_width), height_and_width));
+  
+    assertEquals("setMessage", SpecificCompiler.generateSetMethod(
+        createRecord("test", false, message), message));
+    message = new Field("message", Schema.create(Type.STRING), null, null);
+    assertEquals("setMessage$", SpecificCompiler.generateSetMethod(
+        createRecord("test", true, message), message));
+ 
+    assertEquals("setCause", SpecificCompiler.generateSetMethod(
+        createRecord("test", false, cause), cause));
+    cause = new Field("cause", Schema.create(Type.STRING), null, null);
+    assertEquals("setCause$", SpecificCompiler.generateSetMethod(
+        createRecord("test", true, cause), cause));
+
+    
+    assertEquals("setClass$", SpecificCompiler.generateSetMethod(
+        createRecord("test", false, clasz), clasz));
+    clasz = new Field("class", Schema.create(Type.STRING), null, null);
+    assertEquals("setClass$", SpecificCompiler.generateSetMethod(
+        createRecord("test", true, clasz), clasz));
+
+    assertEquals("setSchema$", SpecificCompiler.generateSetMethod(
+        createRecord("test", false, schema), schema));
+    schema = new Field("schema", Schema.create(Type.STRING), null, null);
+    assertEquals("setSchema$", SpecificCompiler.generateSetMethod(
+        createRecord("test", true, schema), schema));
+
+    height = new Field("height", Schema.create(Type.INT), null, null);
+    Height = new Field("Height", Schema.create(Type.INT), null, null);
+    assertEquals("setHeight", SpecificCompiler.generateSetMethod(
+        createRecord("test", false, Height), Height));
+    
+    height = new Field("height", Schema.create(Type.INT), null, null);
+    Height = new Field("Height", Schema.create(Type.INT), null, null);
+    assertEquals("setHeight$0", SpecificCompiler.generateSetMethod(
+        createRecord("test", false, height, Height), height));
+    
+    height = new Field("height", Schema.create(Type.INT), null, null);
+    Height = new Field("Height", Schema.create(Type.INT), null, null);
+    assertEquals("setHeight$1", SpecificCompiler.generateSetMethod(
+        createRecord("test", false, height, Height), Height));
+    
+    message = new Field("message", Schema.create(Type.STRING), null, null);
+    Message = new Field("Message", Schema.create(Type.STRING), null, null);
+    assertEquals("setMessage$", SpecificCompiler.generateSetMethod(
+        createRecord("test", true, Message), Message));
+    
+    message = new Field("message", Schema.create(Type.STRING), null, null);
+    Message = new Field("Message", Schema.create(Type.STRING), null, null);
+    assertEquals("setMessage$0", SpecificCompiler.generateSetMethod(
+        createRecord("test", true, message, Message), message));
+    
+    message = new Field("message", Schema.create(Type.STRING), null, null);
+    Message = new Field("Message", Schema.create(Type.STRING), null, null);
+    assertEquals("setMessage$1", SpecificCompiler.generateSetMethod(
+        createRecord("test", true, message, Message), Message));
+    
+    schema = new Field("schema", Schema.create(Type.STRING), null, null);
+    Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
+    assertEquals("setSchema$", SpecificCompiler.generateSetMethod(
+        createRecord("test", false, Schema$), Schema$));
+    
+    schema = new Field("schema", Schema.create(Type.STRING), null, null);
+    Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
+    assertEquals("setSchema$0", SpecificCompiler.generateSetMethod(
+        createRecord("test", false, schema, Schema$), schema));
+    
+    schema = new Field("schema", Schema.create(Type.STRING), null, null);
+    Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
+    assertEquals("setSchema$1", SpecificCompiler.generateSetMethod(
+        createRecord("test", false, schema, Schema$), Schema$));
+  }
+  
+  @Test
+  public void generateHasMethod() {
+    Field height = new Field("height", Schema.create(Type.INT), null, null);
+    Field Height = new Field("Height", Schema.create(Type.INT), null, null);
+    Field height_and_width = 
+        new Field("height_and_width", Schema.create(Type.STRING), null, null);
+    Field message = 
+        new Field("message", Schema.create(Type.STRING), null, null);
+    Field Message = 
+        new Field("Message", Schema.create(Type.STRING), null, null);
+    Field cause = 
+        new Field("cause", Schema.create(Type.STRING), null, null);
+    Field clasz = 
+        new Field("class", Schema.create(Type.STRING), null, null);
+    Field schema = 
+        new Field("schema", Schema.create(Type.STRING), null, null);
+    Field Schema$ = 
+        new Field("Schema", Schema.create(Type.STRING), null, null);
+    
+    assertEquals("hasHeight", SpecificCompiler.generateHasMethod(
+        createRecord("test", false, height), height));
+    
+    assertEquals("hasHeightAndWidth", SpecificCompiler.generateHasMethod(
+        createRecord("test", false, height_and_width), height_and_width));
+  
+    assertEquals("hasMessage", SpecificCompiler.generateHasMethod(
+        createRecord("test", false, message), message));
+    message = new Field("message", Schema.create(Type.STRING), null, null);
+    assertEquals("hasMessage$", SpecificCompiler.generateHasMethod(
+        createRecord("test", true, message), message));
+ 
+    assertEquals("hasCause", SpecificCompiler.generateHasMethod(
+        createRecord("test", false, cause), cause));
+    cause = new Field("cause", Schema.create(Type.STRING), null, null);
+    assertEquals("hasCause$", SpecificCompiler.generateHasMethod(
+        createRecord("test", true, cause), cause));
+
+    
+    assertEquals("hasClass$", SpecificCompiler.generateHasMethod(
+        createRecord("test", false, clasz), clasz));
+    clasz = new Field("class", Schema.create(Type.STRING), null, null);
+    assertEquals("hasClass$", SpecificCompiler.generateHasMethod(
+        createRecord("test", true, clasz), clasz));
+
+    assertEquals("hasSchema$", SpecificCompiler.generateHasMethod(
+        createRecord("test", false, schema), schema));
+    schema = new Field("schema", Schema.create(Type.STRING), null, null);
+    assertEquals("hasSchema$", SpecificCompiler.generateHasMethod(
+        createRecord("test", true, schema), schema));
+
+    height = new Field("height", Schema.create(Type.INT), null, null);
+    Height = new Field("Height", Schema.create(Type.INT), null, null);
+    assertEquals("hasHeight", SpecificCompiler.generateHasMethod(
+        createRecord("test", false, Height), Height));
+    
+    height = new Field("height", Schema.create(Type.INT), null, null);
+    Height = new Field("Height", Schema.create(Type.INT), null, null);
+    assertEquals("hasHeight$0", SpecificCompiler.generateHasMethod(
+        createRecord("test", false, height, Height), height));
+    
+    height = new Field("height", Schema.create(Type.INT), null, null);
+    Height = new Field("Height", Schema.create(Type.INT), null, null);
+    assertEquals("hasHeight$1", SpecificCompiler.generateHasMethod(
+        createRecord("test", false, height, Height), Height));
+    
+    message = new Field("message", Schema.create(Type.STRING), null, null);
+    Message = new Field("Message", Schema.create(Type.STRING), null, null);
+    assertEquals("hasMessage$", SpecificCompiler.generateHasMethod(
+        createRecord("test", true, Message), Message));
+    
+    message = new Field("message", Schema.create(Type.STRING), null, null);
+    Message = new Field("Message", Schema.create(Type.STRING), null, null);
+    assertEquals("hasMessage$0", SpecificCompiler.generateHasMethod(
+        createRecord("test", true, message, Message), message));
+    
+    message = new Field("message", Schema.create(Type.STRING), null, null);
+    Message = new Field("Message", Schema.create(Type.STRING), null, null);
+    assertEquals("hasMessage$1", SpecificCompiler.generateHasMethod(
+        createRecord("test", true, message, Message), Message));
+    
+    schema = new Field("schema", Schema.create(Type.STRING), null, null);
+    Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
+    assertEquals("hasSchema$", SpecificCompiler.generateHasMethod(
+        createRecord("test", false, Schema$), Schema$));
+    
+    schema = new Field("schema", Schema.create(Type.STRING), null, null);
+    Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
+    assertEquals("hasSchema$0", SpecificCompiler.generateHasMethod(
+        createRecord("test", false, schema, Schema$), schema));
+    
+    schema = new Field("schema", Schema.create(Type.STRING), null, null);
+    Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
+    assertEquals("hasSchema$1", SpecificCompiler.generateHasMethod(
+        createRecord("test", false, schema, Schema$), Schema$));
+  }
+  
+  @Test
+  public void generateClearMethod() {
+    Field height = new Field("height", Schema.create(Type.INT), null, null);
+    Field Height = new Field("Height", Schema.create(Type.INT), null, null);
+    Field height_and_width = 
+        new Field("height_and_width", Schema.create(Type.STRING), null, null);
+    Field message = 
+        new Field("message", Schema.create(Type.STRING), null, null);
+    Field Message = 
+        new Field("Message", Schema.create(Type.STRING), null, null);
+    Field cause = 
+        new Field("cause", Schema.create(Type.STRING), null, null);
+    Field clasz = 
+        new Field("class", Schema.create(Type.STRING), null, null);
+    Field schema = 
+        new Field("schema", Schema.create(Type.STRING), null, null);
+    Field Schema$ = 
+        new Field("Schema", Schema.create(Type.STRING), null, null);
+    
+    assertEquals("clearHeight", SpecificCompiler.generateClearMethod(
+        createRecord("test", false, height), height));
+    
+    assertEquals("clearHeightAndWidth", SpecificCompiler.generateClearMethod(
+        createRecord("test", false, height_and_width), height_and_width));
+  
+    assertEquals("clearMessage", SpecificCompiler.generateClearMethod(
+        createRecord("test", false, message), message));
+    message = new Field("message", Schema.create(Type.STRING), null, null);
+    assertEquals("clearMessage$", SpecificCompiler.generateClearMethod(
+        createRecord("test", true, message), message));
+ 
+    assertEquals("clearCause", SpecificCompiler.generateClearMethod(
+        createRecord("test", false, cause), cause));
+    cause = new Field("cause", Schema.create(Type.STRING), null, null);
+    assertEquals("clearCause$", SpecificCompiler.generateClearMethod(
+        createRecord("test", true, cause), cause));
+
+    
+    assertEquals("clearClass$", SpecificCompiler.generateClearMethod(
+        createRecord("test", false, clasz), clasz));
+    clasz = new Field("class", Schema.create(Type.STRING), null, null);
+    assertEquals("clearClass$", SpecificCompiler.generateClearMethod(
+        createRecord("test", true, clasz), clasz));
+
+    assertEquals("clearSchema$", SpecificCompiler.generateClearMethod(
+        createRecord("test", false, schema), schema));
+    schema = new Field("schema", Schema.create(Type.STRING), null, null);
+    assertEquals("clearSchema$", SpecificCompiler.generateClearMethod(
+        createRecord("test", true, schema), schema));
+
+    height = new Field("height", Schema.create(Type.INT), null, null);
+    Height = new Field("Height", Schema.create(Type.INT), null, null);
+    assertEquals("clearHeight", SpecificCompiler.generateClearMethod(
+        createRecord("test", false, Height), Height));
+    
+    height = new Field("height", Schema.create(Type.INT), null, null);
+    Height = new Field("Height", Schema.create(Type.INT), null, null);
+    assertEquals("clearHeight$0", SpecificCompiler.generateClearMethod(
+        createRecord("test", false, height, Height), height));
+    
+    height = new Field("height", Schema.create(Type.INT), null, null);
+    Height = new Field("Height", Schema.create(Type.INT), null, null);
+    assertEquals("clearHeight$1", SpecificCompiler.generateClearMethod(
+        createRecord("test", false, height, Height), Height));
+    
+    message = new Field("message", Schema.create(Type.STRING), null, null);
+    Message = new Field("Message", Schema.create(Type.STRING), null, null);
+    assertEquals("clearMessage$", SpecificCompiler.generateClearMethod(
+        createRecord("test", true, Message), Message));
+    
+    message = new Field("message", Schema.create(Type.STRING), null, null);
+    Message = new Field("Message", Schema.create(Type.STRING), null, null);
+    assertEquals("clearMessage$0", SpecificCompiler.generateClearMethod(
+        createRecord("test", true, message, Message), message));
+    
+    message = new Field("message", Schema.create(Type.STRING), null, null);
+    Message = new Field("Message", Schema.create(Type.STRING), null, null);
+    assertEquals("clearMessage$1", SpecificCompiler.generateClearMethod(
+        createRecord("test", true, message, Message), Message));
+    
+    schema = new Field("schema", Schema.create(Type.STRING), null, null);
+    Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
+    assertEquals("clearSchema$", SpecificCompiler.generateClearMethod(
+        createRecord("test", false, Schema$), Schema$));
+    
+    schema = new Field("schema", Schema.create(Type.STRING), null, null);
+    Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
+    assertEquals("clearSchema$0", SpecificCompiler.generateClearMethod(
+        createRecord("test", false, schema, Schema$), schema));
+    
+    schema = new Field("schema", Schema.create(Type.STRING), null, null);
+    Schema$ = new Field("Schema", Schema.create(Type.STRING), null, null);
+    assertEquals("clearSchema$1", SpecificCompiler.generateClearMethod(
+        createRecord("test", false, schema, Schema$), Schema$));
+  }
 
   /**
    * Checks that a schema passes through the SpecificCompiler, and,

Added: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/generic/TestDeepCopy.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/generic/TestDeepCopy.java?rev=1162253&view=auto
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/generic/TestDeepCopy.java (added)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/generic/TestDeepCopy.java Fri Aug 26 20:54:50 2011
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.avro.generic;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.avro.Foo;
+import org.apache.avro.Interop;
+import org.apache.avro.Kind;
+import org.apache.avro.MD5;
+import org.apache.avro.Node;
+import org.apache.avro.Schema.Field;
+import org.apache.avro.Schema.Type;
+import org.apache.avro.specific.SpecificData;
+import org.apache.avro.util.Utf8;
+import org.junit.Test;
+
+/** Unit test for performing a deep copy of an object with a schema */
+public class TestDeepCopy {
+  @Test
+  public void testDeepCopy() {
+    // Set all non-default fields in an Interop instance:
+    Interop.Builder interopBuilder = Interop.newBuilder();
+    interopBuilder.setArrayField(
+        Arrays.asList(new Double[] { 1.1, 1.2, 1.3, 1.4 }));
+    interopBuilder.setBoolField(true);
+    interopBuilder.setBytesField(ByteBuffer.wrap(new byte[] { 1, 2, 3, 4 }));
+    interopBuilder.setDoubleField(3.14d);
+    interopBuilder.setEnumField(Kind.B);
+    interopBuilder.setFixedField(new MD5(new byte[] { 
+        4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1 }));
+    interopBuilder.setFloatField(6.022f);
+    interopBuilder.setIntField(32);
+    interopBuilder.setLongField(64L);
+    
+    Map<java.lang.CharSequence,org.apache.avro.Foo> map = 
+      new HashMap<java.lang.CharSequence,org.apache.avro.Foo>(1);
+    map.put(new Utf8("foo"), 
+        Foo.newBuilder().setLabel(new Utf8("bar")).build());
+    interopBuilder.setMapField(map);
+    
+    interopBuilder.setNullField(null);
+    
+    Node.Builder rootBuilder = Node.newBuilder().setLabel(new Utf8("/"));
+    Node.Builder homeBuilder = Node.newBuilder().setLabel(new Utf8("home"));
+    homeBuilder.setChildren(new ArrayList<Node>(0));
+    rootBuilder.setChildren(Arrays.asList(new Node[] { homeBuilder.build() }));
+    interopBuilder.setRecordField(rootBuilder.build());
+    
+    interopBuilder.setStringField(new Utf8("Hello"));
+    interopBuilder.setUnionField(true);
+    
+    Interop interop = interopBuilder.build();
+    
+    // Verify that deepCopy works for all fields:
+    for (Field field : Interop.SCHEMA$.getFields()) {
+      // Original field and deep copy should be equivalent:
+      if (interop.get(field.pos()) instanceof ByteBuffer) {
+        assertTrue(Arrays.equals(((ByteBuffer)interop.get(field.pos())).array(),
+            ((ByteBuffer)GenericData.get().deepCopy(field.schema(), 
+                interop.get(field.pos()))).array()));
+      }
+      else {
+        assertEquals(interop.get(field.pos()),
+            SpecificData.get().deepCopy(
+                field.schema(), interop.get(field.pos())));
+      }
+      
+      // Original field and deep copy should be different instances:
+      if ((field.schema().getType() != Type.ENUM) && 
+          (field.schema().getType() != Type.NULL)) {
+        assertFalse("Field " + field.name() + " is same instance in deep copy",
+            interop.get(field.pos()) == 
+              GenericData.get().deepCopy(
+                  field.schema(), interop.get(field.pos())));
+      }
+    }
+  }
+}

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServer.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServer.java?rev=1162253&r1=1162252&r2=1162253&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServer.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServer.java Fri Aug 26 20:54:50 2011
@@ -48,9 +48,9 @@ public class TestNettyServer {
     
     // in this simple example just return details of the message
     public CharSequence send(Message message) {
-      return new Utf8("Sent message to [" + message.to.toString() + "] from ["
-          + message.from.toString() + "] with body [" + message.body.toString()
-          + "]");
+      return new Utf8("Sent message to [" + message.getTo().toString() + 
+          "] from [" + message.getFrom().toString() + "] with body [" + 
+          message.getBody().toString() + "]");
     }
     
     public void fireandforget(Message message) {
@@ -129,10 +129,11 @@ public class TestNettyServer {
   }
 
   private Message createMessage() {
-    Message msg = new Message();
-    msg.to = new Utf8("wife");
-    msg.from = new Utf8("husband");
-    msg.body = new Utf8("I love you!");
+    Message msg = Message.newBuilder().
+      setTo(new Utf8("wife")).
+      setFrom(new Utf8("husband")).
+      setBody(new Utf8("I love you!")).
+      build();
     return msg;
   }
 

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServerWithCallbacks.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServerWithCallbacks.java?rev=1162253&r1=1162252&r2=1162253&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServerWithCallbacks.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServerWithCallbacks.java Fri Aug 26 20:54:50 2011
@@ -111,11 +111,11 @@ public class TestNettyServerWithCallback
   
   @Test
   public void echo() throws Exception {
-    TestRecord record = new TestRecord();
-    record.hash = new org.apache.avro.test.MD5();
-    record.hash.bytes(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8 } );
-    record.kind = org.apache.avro.test.Kind.FOO;
-    record.name = "My Record";
+    TestRecord record = TestRecord.newBuilder().setHash(
+        new org.apache.avro.test.MD5(
+            new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8 })).
+        setKind(org.apache.avro.test.Kind.FOO).
+        setName("My Record").build();
     
     // Test synchronous RPC:
     Assert.assertEquals(record, simpleClient.echo(record));
@@ -284,6 +284,7 @@ public class TestNettyServerWithCallback
 
         // Shut down server:
         server2.close();
+        Thread.sleep(1000L);
 
         // Send a new RPC, and verify that it throws an Exception that 
         // can be detected by the client:
@@ -445,9 +446,7 @@ public class TestNettyServerWithCallback
 
     @Override
     public Void error() throws AvroRemoteException, TestError {
-      TestError error = new TestError();
-      error.message = "Test Message";
-      throw error;
+      throw TestError.newBuilder().setMessage$("Test Message").build();
     }
 
     @Override

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestRpcPluginOrdering.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestRpcPluginOrdering.java?rev=1162253&r1=1162252&r2=1162253&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestRpcPluginOrdering.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestRpcPluginOrdering.java Fri Aug 26 20:54:50 2011
@@ -83,10 +83,11 @@ public class TestRpcPluginOrdering {
   }
 
   private Message createTestMessage() {
-    Message message = new Message();
-    message.to = new Utf8("me@test.com");
-    message.from = new Utf8("you@test.com");
-    message.body = new Utf8("plugin testing");
+    Message message = Message.newBuilder().
+      setTo(new Utf8("me@test.com")).
+      setFrom(new Utf8("you@test.com")).
+      setBody(new Utf8("plugin testing")).
+      build();
     return message;
   }
   

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/trace/TestBasicTracing.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/trace/TestBasicTracing.java?rev=1162253&r1=1162252&r2=1162253&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/trace/TestBasicTracing.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/trace/TestBasicTracing.java Fri Aug 26 20:54:50 2011
@@ -100,17 +100,18 @@ public class TestBasicTracing {
       Span requestorSpan = requestorSpans.get(0);
       
       // Check meta propagation     
-      assertEquals(null, requestorSpan.parentSpanID);
-      assertEquals(responderSpan.parentSpanID, requestorSpan.parentSpanID);
-      assertEquals(responderSpan.traceID, requestorSpan.traceID);
+      assertEquals(null, requestorSpan.getParentSpanID());
+      assertEquals(responderSpan.getParentSpanID(), 
+          requestorSpan.getParentSpanID());
+      assertEquals(responderSpan.getTraceID(), requestorSpan.getTraceID());
       
       // Check other data
-      assertEquals(2, requestorSpan.events.size());
-      assertEquals(2, responderSpan.events.size());
-      assertTrue("m".equals(requestorSpan.messageName.toString()));
-      assertTrue("m".equals(responderSpan.messageName.toString()));
-      assertFalse(requestorSpan.complete);
-      assertFalse(responderSpan.complete);
+      assertEquals(2, requestorSpan.getEvents().size());
+      assertEquals(2, responderSpan.getEvents().size());
+      assertTrue("m".equals(requestorSpan.getMessageName().toString()));
+      assertTrue("m".equals(responderSpan.getMessageName().toString()));
+      assertFalse(requestorSpan.getComplete());
+      assertFalse(responderSpan.getComplete());
     }
     
     server.close();
@@ -285,48 +286,48 @@ public class TestBasicTracing {
     assertEquals(1, cPlugin.storage.getAllSpans().size());
     assertEquals(1, dPlugin.storage.getAllSpans().size());
     
-    ID traceID = aPlugin.storage.getAllSpans().get(0).traceID;
+    ID traceID = aPlugin.storage.getAllSpans().get(0).getTraceID();
     ID rootSpanID = null;
     
     // Verify event counts and trace ID propagation
     for (Span s: aPlugin.storage.getAllSpans()) {
-      assertEquals(2, s.events.size());
-      assertTrue(Util.idsEqual(traceID, s.traceID));
-      assertFalse(s.complete);
-      rootSpanID = s.spanID;
+      assertEquals(2, s.getEvents().size());
+      assertTrue(Util.idsEqual(traceID, s.getTraceID()));
+      assertFalse(s.getComplete());
+      rootSpanID = s.getSpanID();
     }
     
     for (Span s: bPlugin.storage.getAllSpans()) {
-      assertEquals(2, s.events.size());
-      assertEquals(traceID, s.traceID);
-      assertFalse(s.complete);
+      assertEquals(2, s.getEvents().size());
+      assertEquals(traceID, s.getTraceID());
+      assertFalse(s.getComplete());
     }
     
     for (Span s: cPlugin.storage.getAllSpans()) {
-      assertEquals(2, s.events.size());
-      assertEquals(traceID, s.traceID);
-      assertFalse(s.complete);
+      assertEquals(2, s.getEvents().size());
+      assertEquals(traceID, s.getTraceID());
+      assertFalse(s.getComplete());
     }
     for (Span s: dPlugin.storage.getAllSpans()) {
-      assertEquals(2, s.events.size());
-      assertEquals(traceID, s.traceID);
-      assertFalse(s.complete);
+      assertEquals(2, s.getEvents().size());
+      assertEquals(traceID, s.getTraceID());
+      assertFalse(s.getComplete());
     }
     
     // Verify span propagation.
-    ID firstSpanID = aPlugin.storage.getAllSpans().get(0).spanID;
-    ID secondSpanID = cPlugin.storage.getAllSpans().get(0).spanID;
-    ID thirdSpanID = dPlugin.storage.getAllSpans().get(0).spanID;
+    ID firstSpanID = aPlugin.storage.getAllSpans().get(0).getSpanID();
+    ID secondSpanID = cPlugin.storage.getAllSpans().get(0).getSpanID();
+    ID thirdSpanID = dPlugin.storage.getAllSpans().get(0).getSpanID();
     
     boolean firstFound = false, secondFound = false, thirdFound = false;
     for (Span s: bPlugin.storage.getAllSpans()) {
-      if (Util.idsEqual(s.spanID, firstSpanID)) {
+      if (Util.idsEqual(s.getSpanID(), firstSpanID)) {
         firstFound = true;
       }
-      else if (Util.idsEqual(s.spanID, secondSpanID)) {
+      else if (Util.idsEqual(s.getSpanID(), secondSpanID)) {
         secondFound = true;
       }
-      else if (Util.idsEqual(s.spanID, thirdSpanID)) {
+      else if (Util.idsEqual(s.getSpanID(), thirdSpanID)) {
         thirdFound = true;
       }
     }

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/trace/TestFileSpanStorage.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/trace/TestFileSpanStorage.java?rev=1162253&r1=1162252&r2=1162253&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/trace/TestFileSpanStorage.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/trace/TestFileSpanStorage.java Fri Aug 26 20:54:50 2011
@@ -39,7 +39,7 @@ public class TestFileSpanStorage {
     TracePluginConfiguration conf = new TracePluginConfiguration();
     FileSpanStorage test = new FileSpanStorage(false, conf);
     Span s = Util.createEventlessSpan(Util.idValue(1), Util.idValue(1), null);
-    s.messageName = new Utf8("message");
+    s.setMessageName(new Utf8("message"));
     test.addSpan(s);
     try {
       Thread.sleep(1000);
@@ -58,7 +58,7 @@ public class TestFileSpanStorage {
     List<Span> spans = new ArrayList<Span>(50000);
     for (int i = 0; i < 50000; i++) {
       Span s = Util.createEventlessSpan(Util.idValue(i), Util.idValue(i), null);
-      s.messageName = new Utf8("message");
+      s.setMessageName(new Utf8("message"));
       test.addSpan(s);
       spans.add(s);
     }
@@ -76,7 +76,7 @@ public class TestFileSpanStorage {
     spans.clear();
     for (int i = 0; i < 5000; i++) {
       Span s = Util.createEventlessSpan(Util.idValue(i), Util.idValue(i), null);
-      s.messageName = new Utf8("message");
+      s.setMessageName(new Utf8("message"));
       test2.addSpan(s);
       spans.add(s);
     }
@@ -99,14 +99,14 @@ public class TestFileSpanStorage {
     // Add a bunch of spans
     for (int i = 0; i < 100; i++) {
       Span s = Util.createEventlessSpan(Util.idValue(i), Util.idValue(i), null);
-      s.messageName = new Utf8("message");
+      s.setMessageName(new Utf8("message"));
       test.addSpan(s);
     }
     
     List<Span> lastNine = new LinkedList<Span>();
     for (int i = 0; i < 9; i++) {
       Span s = Util.createEventlessSpan(Util.idValue(100 + i), Util.idValue(100 + i), null);
-      s.messageName = new Utf8("message");
+      s.setMessageName(new Utf8("message"));
       lastNine.add(s);
       test.addSpan(s);
     }
@@ -141,16 +141,16 @@ public class TestFileSpanStorage {
       
       Span s = Util.createEventlessSpan(Util.idValue(i), Util.idValue(i), null);
       TimestampedEvent te1 = new TimestampedEvent();
-      te1.timeStamp = System.currentTimeMillis() * 1000000;
-      te1.event = SpanEvent.CLIENT_SEND;
+      te1.setTimeStamp(System.currentTimeMillis() * 1000000);
+      te1.setEvent(SpanEvent.CLIENT_SEND);
       
       TimestampedEvent te2 = new TimestampedEvent();
-      te2.timeStamp = System.currentTimeMillis() * 1000000;
-      te2.event = SpanEvent.CLIENT_RECV;
-      s.events.add(te1);
-      s.events.add(te2);
+      te2.setTimeStamp(System.currentTimeMillis() * 1000000);
+      te2.setEvent(SpanEvent.CLIENT_RECV);
+      s.getEvents().add(te1);
+      s.getEvents().add(te2);
       
-      s.messageName = new Utf8("message");
+      s.setMessageName(new Utf8("message"));
       test.addSpan(s);
       spans[i] = s;
       

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/trace/TestSpanAggregation.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/trace/TestSpanAggregation.java?rev=1162253&r1=1162252&r2=1162253&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/trace/TestSpanAggregation.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/trace/TestSpanAggregation.java Fri Aug 26 20:54:50 2011
@@ -45,12 +45,12 @@ public class TestSpanAggregation {
   @Test
   public void testSpanCompletion1() {
     Span span1a = createClientSpan(idValue(1), idValue(1), null, new Utf8("a"));
-    span1a.requestPayloadSize = 10;
-    span1a.responsePayloadSize = 0;
+    span1a.setRequestPayloadSize(10L);
+    span1a.setResponsePayloadSize(0L);
     
     Span span1b = createServerSpan(idValue(1), idValue(1), null, new Utf8("a"));
-    span1b.requestPayloadSize = 0;
-    span1b.responsePayloadSize = 11;
+    span1b.setRequestPayloadSize(0L);
+    span1b.setResponsePayloadSize(11L);
     
     List<Span> partials = new ArrayList<Span>();
     partials.add(span1a);
@@ -63,11 +63,11 @@ public class TestSpanAggregation {
     assertTrue(results.completeSpans.size() == 1);
     
     Span result = results.completeSpans.get(0);
-    assertEquals(null, result.parentSpanID);
-    assertTrue(idsEqual(idValue(1), result.spanID));
-    assertEquals(4, result.events.size());
-    assertEquals(10, result.requestPayloadSize);
-    assertEquals(11, result.responsePayloadSize);
+    assertEquals(null, result.getParentSpanID());
+    assertTrue(idsEqual(idValue(1), result.getSpanID()));
+    assertEquals(4, result.getEvents().size());
+    assertEquals(new Long(10), result.getRequestPayloadSize());
+    assertEquals(new Long(11), result.getResponsePayloadSize());
   }
   
   /**
@@ -112,12 +112,12 @@ public class TestSpanAggregation {
     
     assertTrue(results.completeSpans.size() == 1);
     Span result = results.completeSpans.get(0);
-    assertTrue(result.complete);
-    assertTrue(idsEqual(idValue(1), result.spanID));
-    assertEquals(new Utf8("requestorHostname"), result.requestorHostname);
-    assertEquals(new Utf8("responderHostname"), result.responderHostname);
-    assertNull(result.parentSpanID);
-    assertEquals(new Utf8("a"), result.messageName);
+    assertTrue(result.getComplete());
+    assertTrue(idsEqual(idValue(1), result.getSpanID()));
+    assertEquals(new Utf8("requestorHostname"), result.getRequestorHostname());
+    assertEquals(new Utf8("responderHostname"), result.getResponderHostname());
+    assertNull(result.getParentSpanID());
+    assertEquals(new Utf8("a"), result.getMessageName());
   }
   
   /**
@@ -151,8 +151,8 @@ public class TestSpanAggregation {
     
     assertEquals(5, merged.size());
     for (Span s: merged) {
-      assertEquals(new Utf8("requestorHostname"), s.requestorHostname);
-      assertEquals(new Utf8("responderHostname"), s.responderHostname);
+      assertEquals(new Utf8("requestorHostname"), s.getRequestorHostname());
+      assertEquals(new Utf8("responderHostname"), s.getResponderHostname());
     }
     
     List<Trace> traces = SpanAggregator.getTraces(merged).traces;
@@ -167,28 +167,28 @@ public class TestSpanAggregation {
    */
   public Span createClientSpan(ID traceID, ID spanID, ID parentID, Utf8 msgName) {
     Span out = new Span();
-    out.spanID = spanID;
-    out.traceID = traceID;
-    out.requestorHostname = new Utf8("requestorHostname");
+    out.setSpanID(spanID);
+    out.setTraceID(traceID);
+    out.setRequestorHostname(new Utf8("requestorHostname"));
     
     if (parentID != null) {
-      out.parentSpanID = parentID;
+      out.setParentSpanID(parentID);
     }
-    out.messageName = msgName;
-    out.complete = false;
+    out.setMessageName(msgName);
+    out.setComplete(false);
     
     TimestampedEvent event1 = new TimestampedEvent();
-    event1.event = SpanEvent.CLIENT_SEND;
-    event1.timeStamp = System.currentTimeMillis() * 1000000;
+    event1.setEvent(SpanEvent.CLIENT_SEND);
+    event1.setTimeStamp(System.currentTimeMillis() * 1000000);
     
     TimestampedEvent event2 = new TimestampedEvent();
-    event2.event = SpanEvent.CLIENT_RECV;
-    event2.timeStamp = System.currentTimeMillis() * 1000000;
+    event2.setEvent(SpanEvent.CLIENT_RECV);
+    event2.setTimeStamp(System.currentTimeMillis() * 1000000);
     
-    out.events = new GenericData.Array<TimestampedEvent>(
-        2, Schema.createArray(TimestampedEvent.SCHEMA$));
-    out.events.add(event1);
-    out.events.add(event2);
+    out.setEvents(new GenericData.Array<TimestampedEvent>(
+        2, Schema.createArray(TimestampedEvent.SCHEMA$)));
+    out.getEvents().add(event1);
+    out.getEvents().add(event2);
     
     return out;
   }
@@ -198,28 +198,28 @@ public class TestSpanAggregation {
    */
   public Span createServerSpan(ID traceID, ID spanID, ID parentID, Utf8 msgName) {
     Span out = new Span();
-    out.spanID = spanID;
-    out.traceID = traceID;
-    out.responderHostname = new Utf8("responderHostname");
+    out.setSpanID(spanID);
+    out.setTraceID(traceID);
+    out.setResponderHostname(new Utf8("responderHostname"));
     
     if (parentID != null) {
-      out.parentSpanID = parentID;
+      out.setParentSpanID(parentID);
     }
-    out.messageName = msgName;
-    out.complete = false;
+    out.setMessageName(msgName);
+    out.setComplete(false);
     
     TimestampedEvent event1 = new TimestampedEvent();
-    event1.event = SpanEvent.SERVER_RECV;
-    event1.timeStamp = System.currentTimeMillis();
+    event1.setEvent(SpanEvent.SERVER_RECV);
+    event1.setTimeStamp(System.currentTimeMillis());
     
     TimestampedEvent event2 = new TimestampedEvent();
-    event2.event = SpanEvent.SERVER_SEND;
-    event2.timeStamp = System.currentTimeMillis();
+    event2.setEvent(SpanEvent.SERVER_SEND);
+    event2.setTimeStamp(System.currentTimeMillis());
     
-    out.events = new GenericData.Array<TimestampedEvent>(
-        2, Schema.createArray(TimestampedEvent.SCHEMA$));
-    out.events.add(event1);
-    out.events.add(event2);
+    out.setEvents(new GenericData.Array<TimestampedEvent>(
+        2, Schema.createArray(TimestampedEvent.SCHEMA$)));
+    out.getEvents().add(event1);
+    out.getEvents().add(event2);
     
     return out;
   }

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/trace/TestSpanTraceFormation.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/trace/TestSpanTraceFormation.java?rev=1162253&r1=1162252&r2=1162253&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/trace/TestSpanTraceFormation.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/ipc/trace/TestSpanTraceFormation.java Fri Aug 26 20:54:50 2011
@@ -36,24 +36,24 @@ public class TestSpanTraceFormation {
   @Test
   public void testSpanEquality() {
     Span root = new Span();
-    root.spanID = Util.idValue(10);
-    root.parentSpanID = null;
-    root.messageName = new Utf8("startCall");
+    root.setSpanID(Util.idValue(10));
+    root.setParentSpanID(null);
+    root.setMessageName(new Utf8("startCall"));
     
     Span a = new Span();
-    a.spanID = Util.idValue(11);
-    a.parentSpanID = Util.idValue(10);
-    a.messageName = new Utf8("childCall1");
+    a.setSpanID(Util.idValue(11));
+    a.setParentSpanID(Util.idValue(10));
+    a.setMessageName(new Utf8("childCall1"));
     
     Span b = new Span();
-    b.spanID = Util.idValue(12);
-    b.parentSpanID = Util.idValue(10);
-    b.messageName = new Utf8("childCall2");
+    b.setSpanID(Util.idValue(12));
+    b.setParentSpanID(Util.idValue(10));
+    b.setMessageName(new Utf8("childCall2"));
     
     Span c = new Span();
-    c.spanID = Util.idValue(13);
-    c.parentSpanID = Util.idValue(10);
-    c.messageName = new Utf8("childCall3");
+    c.setSpanID(Util.idValue(13));
+    c.setParentSpanID(Util.idValue(10));
+    c.setMessageName(new Utf8("childCall3"));
     
     List<Span> spans = new LinkedList<Span>();
     spans.add(root);
@@ -63,19 +63,19 @@ public class TestSpanTraceFormation {
     Trace trace1 = Trace.extractTrace(spans);
     
     Span d = new Span();
-    d.spanID = Util.idValue(11);
-    d.parentSpanID = Util.idValue(10);
-    d.messageName = new Utf8("childCall1");
+    d.setSpanID(Util.idValue(11));
+    d.setParentSpanID(Util.idValue(10));
+    d.setMessageName(new Utf8("childCall1"));
     
     Span e = new Span();
-    e.spanID = Util.idValue(12);
-    e.parentSpanID = Util.idValue(10);
-    e.messageName = new Utf8("childCall2");
+    e.setSpanID(Util.idValue(12));
+    e.setParentSpanID(Util.idValue(10));
+    e.setMessageName(new Utf8("childCall2"));
     
     Span f = new Span();
-    f.spanID = Util.idValue(13);
-    f.parentSpanID = Util.idValue(10);
-    f.messageName = new Utf8("childCall3");
+    f.setSpanID(Util.idValue(13));
+    f.setParentSpanID(Util.idValue(10));
+    f.setMessageName(new Utf8("childCall3"));
     
     spans.clear();
     spans.add(d);
@@ -91,24 +91,24 @@ public class TestSpanTraceFormation {
   @Test
   public void testSpanEquality2() {
     Span root = new Span();
-    root.spanID = Util.idValue(10);
-    root.parentSpanID = null;
-    root.messageName = new Utf8("startCall");
+    root.setSpanID(Util.idValue(10));
+    root.setParentSpanID(null);
+    root.setMessageName(new Utf8("startCall"));
     
     Span a = new Span();
-    a.spanID = Util.idValue(11);
-    a.parentSpanID = Util.idValue(10);
-    a.messageName = new Utf8("childCall1");
+    a.setSpanID(Util.idValue(11));
+    a.setParentSpanID(Util.idValue(10));
+    a.setMessageName(new Utf8("childCall1"));
     
     Span b = new Span();
-    b.spanID = Util.idValue(12);
-    b.parentSpanID = Util.idValue(10);
-    b.messageName = new Utf8("childCall2");
+    b.setSpanID(Util.idValue(12));
+    b.setParentSpanID(Util.idValue(10));
+    b.setMessageName(new Utf8("childCall2"));
     
     Span c = new Span();
-    c.spanID = Util.idValue(13);
-    c.parentSpanID = Util.idValue(10);
-    c.messageName = new Utf8("childCall3");
+    c.setSpanID(Util.idValue(13));
+    c.setParentSpanID(Util.idValue(10));
+    c.setMessageName(new Utf8("childCall3"));
     
     List<Span> spans = new LinkedList<Span>();
     spans.add(root);
@@ -118,24 +118,24 @@ public class TestSpanTraceFormation {
     Trace trace1 = Trace.extractTrace(spans);
     
     Span d = new Span();
-    d.spanID = Util.idValue(11);
-    d.parentSpanID = Util.idValue(10);
-    d.messageName = new Utf8("childCall1");
+    d.setSpanID(Util.idValue(11));
+    d.setParentSpanID(Util.idValue(10));
+    d.setMessageName(new Utf8("childCall1"));
     
     Span e = new Span();
-    e.spanID = Util.idValue(12);
-    e.parentSpanID = Util.idValue(10);
-    e.messageName = new Utf8("childCall2");
+    e.setSpanID(Util.idValue(12));
+    e.setParentSpanID(Util.idValue(10));
+    e.setMessageName(new Utf8("childCall2"));
     
     Span f = new Span();
-    f.spanID = Util.idValue(13);
-    f.parentSpanID = Util.idValue(10);
-    f.messageName = new Utf8("childCall3");
+    f.setSpanID(Util.idValue(13));
+    f.setParentSpanID(Util.idValue(10));
+    f.setMessageName(new Utf8("childCall3"));
     
     Span g = new Span();
-    g.spanID = Util.idValue(14);
-    g.parentSpanID = Util.idValue(13);
-    g.messageName = new Utf8("childCall4");
+    g.setSpanID(Util.idValue(14));
+    g.setParentSpanID(Util.idValue(13));
+    g.setMessageName(new Utf8("childCall4"));
     
     spans.clear();
     spans.add(d);
@@ -151,23 +151,23 @@ public class TestSpanTraceFormation {
   /** Create a span with bogus timing events. */
   public static Span createFullSpan(Long id, Long parentID, String messageName) {
     Span out = new Span();
-    out.spanID = Util.idValue(id);
+    out.setSpanID(Util.idValue(id));
     if (parentID != null) {
-      out.parentSpanID = Util.idValue(parentID);
+      out.setParentSpanID(Util.idValue(parentID));
     }
-    out.messageName = new Utf8(messageName);
+    out.setMessageName(new Utf8(messageName));
     
-    out.events = new GenericData.Array<TimestampedEvent>(
-        4, Schema.createArray(TimestampedEvent.SCHEMA$));
+    out.setEvents(new GenericData.Array<TimestampedEvent>(
+        4, Schema.createArray(TimestampedEvent.SCHEMA$)));
     
     for (SpanEvent ev: SpanEvent.values()) {
       TimestampedEvent newEvent = new TimestampedEvent();
-      newEvent.timeStamp = System.currentTimeMillis() * 1000000;
-      newEvent.event = ev;
-      out.events.add(newEvent);
+      newEvent.setTimeStamp(System.currentTimeMillis() * 1000000);
+      newEvent.setEvent(ev);
+      out.getEvents().add(newEvent);
     }
     
-    out.complete = true;
+    out.setComplete(true);
     
     return out;
   }
@@ -225,24 +225,24 @@ public class TestSpanTraceFormation {
   @Test
   public void testBasicTraceFormation() {
     Span root = new Span();
-    root.spanID = Util.idValue(10);
-    root.parentSpanID = null;
-    root.messageName = new Utf8("startCall");
+    root.setSpanID(Util.idValue(10));
+    root.setParentSpanID(null);
+    root.setMessageName(new Utf8("startCall"));
     
     Span a = new Span();
-    a.spanID = Util.idValue(11);
-    a.parentSpanID = Util.idValue(10);
-    a.messageName = new Utf8("childCall1");
+    a.setSpanID(Util.idValue(11));
+    a.setParentSpanID(Util.idValue(10));
+    a.setMessageName(new Utf8("childCall1"));
     
     Span b = new Span();
-    b.spanID = Util.idValue(12);
-    b.parentSpanID = Util.idValue(10);
-    b.messageName = new Utf8("childCall2");
+    b.setSpanID(Util.idValue(12));
+    b.setParentSpanID(Util.idValue(10));
+    b.setMessageName(new Utf8("childCall2"));
     
     Span c = new Span();
-    c.spanID = Util.idValue(13);
-    c.parentSpanID = Util.idValue(10);
-    c.messageName = new Utf8("childCall3");
+    c.setSpanID(Util.idValue(13));
+    c.setParentSpanID(Util.idValue(10));
+    c.setMessageName(new Utf8("childCall3"));
     
     List<Span> spans = new LinkedList<Span>();
     spans.add(root);
@@ -254,19 +254,19 @@ public class TestSpanTraceFormation {
     assertNotNull(trace);
     
     TraceNode rootNode = trace.getRoot();
-    assertEquals(rootNode.span.messageName, new Utf8("startCall"));
+    assertEquals(rootNode.span.getMessageName(), new Utf8("startCall"));
     assertEquals(3, rootNode.children.size());
     boolean found1, found2, found3;
     found1 = found2 = found3 = false;
     
     for (TraceNode tn: rootNode.children) {
-      if (tn.span.messageName.equals(new Utf8("childCall1"))) {
+      if (tn.span.getMessageName().equals(new Utf8("childCall1"))) {
         found1 = true;
       }
-      if (tn.span.messageName.equals(new Utf8("childCall2"))) {
+      if (tn.span.getMessageName().equals(new Utf8("childCall2"))) {
         found2 = true;
       }
-      if (tn.span.messageName.equals(new Utf8("childCall3"))) {
+      if (tn.span.getMessageName().equals(new Utf8("childCall3"))) {
         found3 = true;
       }
       assertNotNull(tn.children);

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificData.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificData.java?rev=1162253&r1=1162252&r2=1162253&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificData.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificData.java Fri Aug 26 20:54:50 2011
@@ -57,11 +57,9 @@ public class TestSpecificData {
 
     // create a generic instance of this record
     TestRecord nested = new TestRecord();
-    nested.name = new Utf8("foo");
-    nested.kind = Kind.BAR;
-    nested.hash = new MD5();
-    System.arraycopy(new byte[]{0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5}, 0,
-                     nested.hash.bytes(), 0, 16);
+    nested.setName(new Utf8("foo"));
+    nested.setKind(Kind.BAR);
+    nested.setHash(new MD5(new byte[]{0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5}));
     GenericData.Record record = new GenericData.Record(schema);
     record.put("f", nested);
 

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificDatumWriter.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificDatumWriter.java?rev=1162253&r1=1162252&r2=1162253&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificDatumWriter.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificDatumWriter.java Fri Aug 26 20:54:50 2011
@@ -39,16 +39,15 @@ public class TestSpecificDatumWriter {
 
     writer.setSchema(schema);
 
-    TestRecordWithUnion c = new TestRecordWithUnion();
-    c.kind = Kind.BAR;
-    c.value = "rab";
+    TestRecordWithUnion c = TestRecordWithUnion.newBuilder().
+      setKind(Kind.BAR).setValue("rab").build();
     writer.write(c, encoder);
     encoder.flush();
     out.close();
 
     String expectedJson = String.format(
         "{'kind':{'org.apache.avro.test.Kind':'%s'},'value':{'string':'%s'}}",
-        c.kind.toString(), c.value).replace('\'', '"');
+        c.getKind().toString(), c.getValue()).replace('\'', '"');
 
     assertEquals(expectedJson, out.toString("UTF-8"));
   }

Added: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificErrorBuilder.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificErrorBuilder.java?rev=1162253&view=auto
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificErrorBuilder.java (added)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificErrorBuilder.java Fri Aug 26 20:54:50 2011
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.avro.specific;
+
+import org.apache.avro.test.errors.TestError;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Unit test for the SpecificErrorBuilderBase class.
+ */
+public class TestSpecificErrorBuilder {
+  @Test
+  public void testSpecificErrorBuilder() {
+    TestError.Builder testErrorBuilder = TestError.newBuilder().
+      setValue("value").setCause(new NullPointerException()).
+      setMessage$("message$");
+    
+    // Test has methods
+    Assert.assertTrue(testErrorBuilder.hasValue());
+    Assert.assertNotNull(testErrorBuilder.getValue());
+    Assert.assertTrue(testErrorBuilder.hasCause());
+    Assert.assertNotNull(testErrorBuilder.getCause());
+    Assert.assertTrue(testErrorBuilder.hasMessage$());
+    Assert.assertNotNull(testErrorBuilder.getMessage$());
+    
+    TestError testError = testErrorBuilder.build();
+    Assert.assertEquals("value", testError.getValue());
+    Assert.assertEquals("value", testError.getMessage());
+    Assert.assertEquals("message$", testError.getMessage$());
+    
+    // Test copy constructor
+    Assert.assertEquals(testErrorBuilder, 
+        TestError.newBuilder(testErrorBuilder));
+    Assert.assertEquals(testErrorBuilder, TestError.newBuilder(testError));
+    
+    Assert.assertEquals(
+        new TestError("value", new NullPointerException()),
+        TestError.newBuilder().setValue("value").
+          setCause(new NullPointerException()).build());
+    
+    // Test clear
+    testErrorBuilder.clearValue();
+    Assert.assertFalse(testErrorBuilder.hasValue());
+    Assert.assertNull(testErrorBuilder.getValue());
+    testErrorBuilder.clearCause();
+    Assert.assertFalse(testErrorBuilder.hasCause());
+    Assert.assertNull(testErrorBuilder.getCause());
+    testErrorBuilder.clearMessage$();
+    Assert.assertFalse(testErrorBuilder.hasMessage$());
+    Assert.assertNull(testErrorBuilder.getMessage$());
+  }
+  
+  @Test(expected=org.apache.avro.AvroRuntimeException.class)
+  public void attemptToSetNonNullableFieldToNull() {
+    TestError.newBuilder().setMessage$(null);
+  }
+}

Added: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificRecordBuilder.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificRecordBuilder.java?rev=1162253&view=auto
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificRecordBuilder.java (added)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificRecordBuilder.java Fri Aug 26 20:54:50 2011
@@ -0,0 +1,147 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.avro.specific;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.avro.ipc.specific.Person;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Unit test for the SpecificRecordBuilder class.
+ */
+public class TestSpecificRecordBuilder {
+  @Test
+  public void testSpecificBuilder() {
+    // Create a new builder, and leave some fields with default values empty:
+    Person.Builder builder = Person.newBuilder().setName("James Gosling").setYearOfBirth(1955).setState("CA");
+    Assert.assertTrue(builder.hasName());
+    Assert.assertEquals("James Gosling", builder.getName().toString());
+    Assert.assertTrue(builder.hasYearOfBirth());
+    Assert.assertEquals(new Integer(1955), builder.getYearOfBirth());
+    Assert.assertFalse(builder.hasCountry());
+    Assert.assertNull(builder.getCountry());
+    Assert.assertTrue(builder.hasState());
+    Assert.assertEquals("CA", builder.getState().toString());
+    Assert.assertFalse(builder.hasFriends());
+    Assert.assertNull(builder.getFriends());
+    Assert.assertFalse(builder.hasLanguages());
+    Assert.assertNull(builder.getLanguages());
+    
+    Person person = builder.build();
+    Assert.assertEquals("James Gosling", person.getName().toString());
+    Assert.assertEquals(new Integer(1955), person.getYearOfBirth());
+    Assert.assertEquals("US", person.getCountry().toString());  // country should default to "US"
+    Assert.assertEquals("CA", person.getState().toString());
+    Assert.assertNotNull(person.getFriends());  // friends should default to an empty list
+    Assert.assertEquals(0, person.getFriends().size());
+    Assert.assertNotNull(person.getLanguages()); // Languages should now be "English" and "Java"
+    Assert.assertEquals(2, person.getLanguages().size());
+    Assert.assertEquals("English", person.getLanguages().get(0).toString());
+    Assert.assertEquals("Java", person.getLanguages().get(1).toString());
+    
+    // Test copy constructors:
+    Assert.assertEquals(builder, Person.newBuilder(builder));
+    Assert.assertEquals(person, Person.newBuilder(person).build());
+    
+    Person.Builder builderCopy = Person.newBuilder(person);
+    Assert.assertEquals("James Gosling", builderCopy.getName().toString());
+    Assert.assertEquals(new Integer(1955), builderCopy.getYearOfBirth());
+    Assert.assertEquals("US", builderCopy.getCountry().toString());  // country should default to "US"
+    Assert.assertEquals("CA", builderCopy.getState().toString());
+    Assert.assertNotNull(builderCopy.getFriends());  // friends should default to an empty list
+    Assert.assertEquals(0, builderCopy.getFriends().size());
+    
+    // Test clearing fields:
+    builderCopy.clearFriends().clearCountry();
+    Assert.assertFalse(builderCopy.hasFriends());
+    Assert.assertFalse(builderCopy.hasCountry());
+    Assert.assertNull(builderCopy.getFriends());
+    Assert.assertNull(builderCopy.getCountry());
+    Person person2 = builderCopy.build();
+    Assert.assertNotNull(person2.getFriends());
+    Assert.assertTrue(person2.getFriends().isEmpty());
+  }
+  
+  @Test(expected=org.apache.avro.AvroRuntimeException.class)
+  public void attemptToSetNonNullableFieldToNull() {
+    Person.newBuilder().setName(null);
+  }
+  
+  @Ignore
+  @Test
+  public void testBuilderPerformance() {
+    int count = 1000000;
+    List<Person> friends = new ArrayList<Person>(0);
+    List<CharSequence> languages = new ArrayList<CharSequence>(Arrays.asList(new CharSequence[] { "English", "Java" }));
+    long startTimeNanos = System.nanoTime();
+    for (int ii = 0; ii < count; ii++) {
+      Person.newBuilder().setName("James Gosling").setYearOfBirth(1955).setCountry("US").setState("CA").setFriends(friends).
+        setLanguages(languages).build();
+    }
+    long durationNanos = System.nanoTime() - startTimeNanos;
+    double durationMillis = durationNanos / 1e6d;
+    System.out.println("Built " + count + " records in " + durationMillis + "ms (" + 
+        (count / (durationMillis / 1000d)) + " records/sec, " + (durationMillis / count) + 
+        "ms/record");
+  }
+  
+  @Ignore
+  @Test
+  public void testBuilderPerformanceWithDefaultValues() {
+    int count = 1000000;
+    long startTimeNanos = System.nanoTime();
+    for (int ii = 0; ii < count; ii++) {
+      Person.newBuilder().setName("James Gosling").setYearOfBirth(1955).setState("CA").build();
+    }
+    long durationNanos = System.nanoTime() - startTimeNanos;
+    double durationMillis = durationNanos / 1e6d;
+    System.out.println("Built " + count + " records in " + durationMillis + "ms (" + 
+        (count / (durationMillis / 1000d)) + " records/sec, " + (durationMillis / count) + 
+        "ms/record");
+  }
+
+  @Ignore
+  @Test
+  @SuppressWarnings("deprecation")
+  public void testManualBuildPerformance() {
+    int count = 1000000;
+    List<Person> friends = new ArrayList<Person>(0);
+    List<CharSequence> languages = new ArrayList<CharSequence>(Arrays.asList(new CharSequence[] { "English", "Java" }));
+    long startTimeNanos = System.nanoTime();
+    for (int ii = 0; ii < count; ii++) {
+      Person person = new Person();
+      person.name = "James Gosling";
+      person.year_of_birth = 1955;
+      person.state = "CA";
+      person.country = "US";
+      person.friends = friends;
+      person.languages = languages;
+    }
+    long durationNanos = System.nanoTime() - startTimeNanos;
+    double durationMillis = durationNanos / 1e6d;
+    System.out.println("Built " + count + " records in " + durationMillis + "ms (" + 
+        (count / (durationMillis / 1000d)) + " records/sec, " + (durationMillis / count) + 
+        "ms/record");
+  }
+}

Modified: avro/trunk/lang/java/mapred/src/main/java/org/apache/avro/mapred/Pair.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/mapred/src/main/java/org/apache/avro/mapred/Pair.java?rev=1162253&r1=1162252&r2=1162253&view=diff
==============================================================================
--- avro/trunk/lang/java/mapred/src/main/java/org/apache/avro/mapred/Pair.java (original)
+++ avro/trunk/lang/java/mapred/src/main/java/org/apache/avro/mapred/Pair.java Fri Aug 26 20:54:50 2011
@@ -30,7 +30,7 @@ import org.apache.avro.Schema.Field;
 import org.apache.avro.generic.GenericData;
 import org.apache.avro.generic.GenericContainer;
 import org.apache.avro.generic.IndexedRecord;
-import org.apache.avro.specific.SpecificDatumReader.SchemaConstructable;
+import org.apache.avro.specific.SpecificData.SchemaConstructable;
 import org.apache.avro.reflect.ReflectData;
 
 /** A key/value pair. */

Modified: avro/trunk/lang/java/tools/src/test/compiler/output/Player.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/tools/src/test/compiler/output/Player.java?rev=1162253&r1=1162252&r2=1162253&view=diff
==============================================================================
--- avro/trunk/lang/java/tools/src/test/compiler/output/Player.java (original)
+++ avro/trunk/lang/java/tools/src/test/compiler/output/Player.java Fri Aug 26 20:54:50 2011
@@ -7,10 +7,10 @@ package avro.examples.baseball;  
 @SuppressWarnings("all")
 public class Player extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
   public static final org.apache.avro.Schema SCHEMA$ = org.apache.avro.Schema.parse("{\"type\":\"record\",\"name\":\"Player\",\"namespace\":\"avro.examples.baseball\",\"fields\":[{\"name\":\"number\",\"type\":\"int\"},{\"name\":\"first_name\",\"type\":\"string\"},{\"name\":\"last_name\",\"type\":\"string\"},{\"name\":\"position\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"enum\",\"name\":\"Position\",\"symbols\":[\"P\",\"C\",\"B1\",\"B2\",\"B3\",\"SS\",\"LF\",\"CF\",\"RF\",\"DH\"]}}}]}");
-  public int number;
-  public java.lang.CharSequence first_name;
-  public java.lang.CharSequence last_name;
-  public java.util.List<avro.examples.baseball.Position> position;
+  @Deprecated public int number;
+  @Deprecated public java.lang.CharSequence first_name;
+  @Deprecated public java.lang.CharSequence last_name;
+  @Deprecated public java.util.List<avro.examples.baseball.Position> position;
   public org.apache.avro.Schema getSchema() { return SCHEMA$; }
   // Used by DatumWriter.  Applications should not call. 
   public java.lang.Object get(int field$) {
@@ -33,4 +33,235 @@ public class Player extends org.apache.a
     default: throw new org.apache.avro.AvroRuntimeException("Bad index");
     }
   }
+
+  /**
+   * Gets the value of the 'number' field.
+   */
+  public java.lang.Integer getNumber() {
+    return number;
+  }
+
+  /**
+   * Sets the value of the 'number' field.
+   * @param value the value to set.
+   */
+  public void setNumber(java.lang.Integer value) {
+    this.number = value;
+  }
+
+  /**
+   * Gets the value of the 'first_name' field.
+   */
+  public java.lang.CharSequence getFirstName() {
+    return first_name;
+  }
+
+  /**
+   * Sets the value of the 'first_name' field.
+   * @param value the value to set.
+   */
+  public void setFirstName(java.lang.CharSequence value) {
+    this.first_name = value;
+  }
+
+  /**
+   * Gets the value of the 'last_name' field.
+   */
+  public java.lang.CharSequence getLastName() {
+    return last_name;
+  }
+
+  /**
+   * Sets the value of the 'last_name' field.
+   * @param value the value to set.
+   */
+  public void setLastName(java.lang.CharSequence value) {
+    this.last_name = value;
+  }
+
+  /**
+   * Gets the value of the 'position' field.
+   */
+  public java.util.List<avro.examples.baseball.Position> getPosition() {
+    return position;
+  }
+
+  /**
+   * Sets the value of the 'position' field.
+   * @param value the value to set.
+   */
+  public void setPosition(java.util.List<avro.examples.baseball.Position> value) {
+    this.position = value;
+  }
+
+  /** Creates a new Player RecordBuilder */
+  public static avro.examples.baseball.Player.Builder newBuilder() {
+    return new avro.examples.baseball.Player.Builder();
+  }
+  
+  /** Creates a new Player RecordBuilder by copying an existing Builder */
+  public static avro.examples.baseball.Player.Builder newBuilder(avro.examples.baseball.Player.Builder other) {
+    return new avro.examples.baseball.Player.Builder(other);
+  }
+  
+  /** Creates a new Player RecordBuilder by copying an existing Player instance */
+  public static avro.examples.baseball.Player.Builder newBuilder(avro.examples.baseball.Player other) {
+    return new avro.examples.baseball.Player.Builder(other);
+  }
+  
+  /**
+   * RecordBuilder for Player instances.
+   */
+  public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<Player>
+    implements org.apache.avro.data.RecordBuilder<Player> {
+
+    private int number;
+    private java.lang.CharSequence first_name;
+    private java.lang.CharSequence last_name;
+    private java.util.List<avro.examples.baseball.Position> position;
+
+    /** Creates a new Builder */
+    private Builder() {
+      super(avro.examples.baseball.Player.SCHEMA$);
+    }
+    
+    /** Creates a Builder by copying an existing Builder */
+    private Builder(avro.examples.baseball.Player.Builder other) {
+      super(other);
+    }
+    
+    /** Creates a Builder by copying an existing Player instance */
+    private Builder(avro.examples.baseball.Player other) {
+            super(avro.examples.baseball.Player.SCHEMA$);
+      if (isValidValue(fields[0], other.number)) {
+        number = (java.lang.Integer) data.deepCopy(fields[0].schema(), other.number);
+        fieldSetFlags[0] = true;
+      }
+      if (isValidValue(fields[1], other.first_name)) {
+        first_name = (java.lang.CharSequence) data.deepCopy(fields[1].schema(), other.first_name);
+        fieldSetFlags[1] = true;
+      }
+      if (isValidValue(fields[2], other.last_name)) {
+        last_name = (java.lang.CharSequence) data.deepCopy(fields[2].schema(), other.last_name);
+        fieldSetFlags[2] = true;
+      }
+      if (isValidValue(fields[3], other.position)) {
+        position = (java.util.List<avro.examples.baseball.Position>) data.deepCopy(fields[3].schema(), other.position);
+        fieldSetFlags[3] = true;
+      }
+    }
+
+    /** Gets the value of the 'number' field */
+    public java.lang.Integer getNumber() {
+      return number;
+    }
+    
+    /** Sets the value of the 'number' field */
+    public avro.examples.baseball.Player.Builder setNumber(int value) {
+      validate(fields[0], value);
+      this.number = value;
+      fieldSetFlags[0] = true;
+      return this; 
+    }
+    
+    /** Checks whether the 'number' field has been set */
+    public boolean hasNumber() {
+      return fieldSetFlags[0];
+    }
+    
+    /** Clears the value of the 'number' field */
+    public avro.examples.baseball.Player.Builder clearNumber() {
+      fieldSetFlags[0] = false;
+      return this;
+    }
+
+    /** Gets the value of the 'first_name' field */
+    public java.lang.CharSequence getFirstName() {
+      return first_name;
+    }
+    
+    /** Sets the value of the 'first_name' field */
+    public avro.examples.baseball.Player.Builder setFirstName(java.lang.CharSequence value) {
+      validate(fields[1], value);
+      this.first_name = value;
+      fieldSetFlags[1] = true;
+      return this; 
+    }
+    
+    /** Checks whether the 'first_name' field has been set */
+    public boolean hasFirstName() {
+      return fieldSetFlags[1];
+    }
+    
+    /** Clears the value of the 'first_name' field */
+    public avro.examples.baseball.Player.Builder clearFirstName() {
+      first_name = null;
+      fieldSetFlags[1] = false;
+      return this;
+    }
+
+    /** Gets the value of the 'last_name' field */
+    public java.lang.CharSequence getLastName() {
+      return last_name;
+    }
+    
+    /** Sets the value of the 'last_name' field */
+    public avro.examples.baseball.Player.Builder setLastName(java.lang.CharSequence value) {
+      validate(fields[2], value);
+      this.last_name = value;
+      fieldSetFlags[2] = true;
+      return this; 
+    }
+    
+    /** Checks whether the 'last_name' field has been set */
+    public boolean hasLastName() {
+      return fieldSetFlags[2];
+    }
+    
+    /** Clears the value of the 'last_name' field */
+    public avro.examples.baseball.Player.Builder clearLastName() {
+      last_name = null;
+      fieldSetFlags[2] = false;
+      return this;
+    }
+
+    /** Gets the value of the 'position' field */
+    public java.util.List<avro.examples.baseball.Position> getPosition() {
+      return position;
+    }
+    
+    /** Sets the value of the 'position' field */
+    public avro.examples.baseball.Player.Builder setPosition(java.util.List<avro.examples.baseball.Position> value) {
+      validate(fields[3], value);
+      this.position = value;
+      fieldSetFlags[3] = true;
+      return this; 
+    }
+    
+    /** Checks whether the 'position' field has been set */
+    public boolean hasPosition() {
+      return fieldSetFlags[3];
+    }
+    
+    /** Clears the value of the 'position' field */
+    public avro.examples.baseball.Player.Builder clearPosition() {
+      position = null;
+      fieldSetFlags[3] = false;
+      return this;
+    }
+
+    @Override
+    public Player build() {
+      try {
+        Player record = new Player();
+        record.number = fieldSetFlags[0] ? this.number : (java.lang.Integer) getDefaultValue(fields[0]);
+        record.first_name = fieldSetFlags[1] ? this.first_name : (java.lang.CharSequence) getDefaultValue(fields[1]);
+        record.last_name = fieldSetFlags[2] ? this.last_name : (java.lang.CharSequence) getDefaultValue(fields[2]);
+        record.position = fieldSetFlags[3] ? this.position : (java.util.List<avro.examples.baseball.Position>) getDefaultValue(fields[3]);
+        return record;
+      } catch (Exception e) {
+        throw new org.apache.avro.AvroRuntimeException(e);
+      }
+    }
+  }
 }

Added: avro/trunk/share/test/schemas/social.avdl
URL: http://svn.apache.org/viewvc/avro/trunk/share/test/schemas/social.avdl?rev=1162253&view=auto
==============================================================================
--- avro/trunk/share/test/schemas/social.avdl (added)
+++ avro/trunk/share/test/schemas/social.avdl Fri Aug 26 20:54:50 2011
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@namespace("org.apache.avro.ipc.specific")
+protocol Social {
+  record Person {
+    string name;
+    int year_of_birth;
+    string country = "US";
+    string state;
+    array<Person> friends = [];
+    array<string> languages = [ "English" , "Java" ];
+  }
+} 



Mime
View raw message