avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1646360 - in /avro/trunk: ./ lang/java/avro/src/main/java/org/apache/avro/specific/ lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/ lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/c...
Date Wed, 17 Dec 2014 23:02:33 GMT
Author: cutting
Date: Wed Dec 17 23:02:33 2014
New Revision: 1646360

URL: http://svn.apache.org/r1646360
Log:
AVRO-1614. Java: In generated builder classes, add accessors to field sub-builders, permitting
easier creation of nested, optional structures.  Contributed by Niels Basjes.

Added:
    avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificBuilderTree.java
  (with props)
    avro/trunk/share/test/schemas/http.avdl
    avro/trunk/share/test/schemas/specialtypes.avdl
Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java
    avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java
    avro/trunk/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
    avro/trunk/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java
    avro/trunk/lang/java/tools/src/test/compiler/output/Player.java

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1646360&r1=1646359&r2=1646360&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Wed Dec 17 23:02:33 2014
@@ -32,6 +32,10 @@ Trunk (not yet released)
     AVRO-834. Java: Data File corruption recovery tool.
     (scottcarey and tomwhite)
 
+    AVRO-1614. Java: In generated builder classes, add accessors to
+    field sub-builders, permitting easier creation of nested, optional
+    structures. (Niels Basjes via cutting)
+
   OPTIMIZATIONS
 
   IMPROVEMENTS

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java?rev=1646360&r1=1646359&r2=1646360&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java (original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java Wed
Dec 17 23:02:33 2014
@@ -61,7 +61,10 @@ public class SpecificData extends Generi
   public static final String ELEMENT_PROP = "java-element-class";
 
   /** List of Java reserved words from
-   * http://java.sun.com/docs/books/jls/third_edition/html/lexical.html. */
+   * http://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.9
+   * combined with the boolean and null literals.
+   * combined with the classnames used internally in the generated avro code.
+   */
   public static final Set<String> RESERVED_WORDS = new HashSet<String>
     (Arrays.asList(new String[] {
         "abstract", "assert", "boolean", "break", "byte", "case", "catch",
@@ -71,7 +74,9 @@ public class SpecificData extends Generi
         "interface", "long", "native", "new", "null", "package", "private",
         "protected", "public", "return", "short", "static", "strictfp",
         "super", "switch", "synchronized", "this", "throw", "throws",
-        "transient", "true", "try", "void", "volatile", "while"
+        "transient", "true", "try", "void", "volatile", "while",
+        /* classnames use internally by the avro code generator */
+        "Builder"
       }));
 
   /** Read/write some common builtin classes as strings.  Representing these as

Modified: avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java?rev=1646360&r1=1646359&r2=1646360&view=diff
==============================================================================
--- avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java
(original)
+++ avro/trunk/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java
Wed Dec 17 23:02:33 2014
@@ -605,6 +605,13 @@ public class SpecificCompiler {
   /** Utility for template use.  Adds a dollar sign to reserved words. */
   public static String mangle(String word, Set<String> reservedWords, 
       boolean isMethod) {
+    if (word.contains(".")) {
+      // If the 'word' is really a full path of a class we must mangle just the classname
+      int lastDot = word.lastIndexOf(".");
+      String packageName = word.substring(0, lastDot + 1);
+      String className = word.substring(lastDot + 1);
+      return packageName + mangle(className, reservedWords, isMethod);
+    }
     if (reservedWords.contains(word) || 
         (isMethod && reservedWords.contains(
             Character.toLowerCase(word.charAt(0)) + 
@@ -626,27 +633,27 @@ public class SpecificCompiler {
    * @return the name of the accessor method for the given field.
    */
   public static String generateGetMethod(Schema schema, Field field) {
-    return generateMethodName(schema, field, "get");
+    return generateMethodName(schema, field, "get", "");
   }
   
   /**
    * Generates the name of a field mutator method.
    * @param schema the schema in which the field is defined.
-   * @param field the field for which to generate the accessor name.
+   * @param field the field for which to generate the mutator name.
    * @return the name of the mutator method for the given field.
    */
   public static String generateSetMethod(Schema schema, Field field) {
-    return generateMethodName(schema, field, "set");
+    return generateMethodName(schema, field, "set", "");
   }
   
   /**
    * Generates the name of a field "has" method.
    * @param schema the schema in which the field is defined.
-   * @param field the field for which to generate the accessor name.
+   * @param field the field for which to generate the "has" method name.
    * @return the name of the has method for the given field.
    */
   public static String generateHasMethod(Schema schema, Field field) {
-    return generateMethodName(schema, field, "has");
+    return generateMethodName(schema, field, "has", "");
   }
   
   /**
@@ -656,18 +663,67 @@ public class SpecificCompiler {
    * @return the name of the has method for the given field.
    */
   public static String generateClearMethod(Schema schema, Field field) {
-    return generateMethodName(schema, field, "clear");
+    return generateMethodName(schema, field, "clear", "");
   }
   
+  /** Utility for use by templates. Does this schema have a Builder method? */
+  public static boolean hasBuilder(Schema schema) {
+    switch (schema.getType()) {
+      case RECORD:
+        return true;
+
+      case UNION:
+        List<Schema> types = schema.getTypes(); // elide unions with null
+        if ((types.size() == 2) && types.contains(NULL_SCHEMA)) {
+          return hasBuilder(types.get(types.get(0).equals(NULL_SCHEMA) ? 1 : 0));
+        }
+        return false;
+
+      default:
+        return false;
+    }
+  }
+
+  /**
+   * Generates the name of a field Builder accessor method.
+   * @param schema the schema in which the field is defined.
+   * @param field the field for which to generate the Builder accessor name.
+   * @return the name of the Builder accessor method for the given field.
+   */
+  public static String generateGetBuilderMethod(Schema schema, Field field) {
+    return generateMethodName(schema, field, "get", "Builder");
+  }
+
+  /**
+   * Generates the name of a field Builder mutator method.
+   * @param schema the schema in which the field is defined.
+   * @param field the field for which to generate the Builder mutator name.
+   * @return the name of the Builder mutator method for the given field.
+   */
+  public static String generateSetBuilderMethod(Schema schema, Field field) {
+    return generateMethodName(schema, field, "set", "Builder");
+  }
+
+  /**
+   * Generates the name of a field Builder "has" method.
+   * @param schema the schema in which the field is defined.
+   * @param field the field for which to generate the "has" Builder method name.
+   * @return the name of the "has" Builder method for the given field.
+   */
+  public static String generateHasBuilderMethod(Schema schema, Field field) {
+    return generateMethodName(schema, field, "has", "Builder");
+  }
+
   /**
    * Generates a method name from a field name.
    * @param schema the schema in which the field is defined.
    * @param field the field for which to generate the accessor name.
    * @param prefix method name prefix, e.g. "get" or "set".
+   * @param postfix method name postfix, e.g. "" or "Builder".
    * @return the generated method name.
    */
   private static String generateMethodName(Schema schema, Field field, 
-      String prefix) {
+      String prefix, String postfix) {
 
     // Check for the special case in which the schema defines two fields whose 
     // names are identical except for the case of the first character:
@@ -695,6 +751,7 @@ public class SpecificCompiler {
         methodBuilder.append(fieldName.charAt(ii));
       }
     }
+    methodBuilder.append(postfix);
     
     // If there is a field name conflict append $0 or $1
     if (fieldNameConflict) {

Modified: avro/trunk/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm?rev=1646360&r1=1646359&r2=1646360&view=diff
==============================================================================
--- avro/trunk/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
(original)
+++ avro/trunk/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
Wed Dec 17 23:02:33 2014
@@ -150,6 +150,9 @@ public class ${this.mangle($schema.getNa
 
 #foreach ($field in $schema.getFields())
     private ${this.javaUnbox($field.schema())} ${this.mangle($field.name(), $schema.isError())};
+#if (${this.hasBuilder($field.schema())})
+    private ${this.javaUnbox($field.schema())}.Builder ${this.mangle($field.name(), $schema.isError())}Builder;
+#end
 #end
 
     /** Creates a new Builder */
@@ -165,6 +168,11 @@ public class ${this.mangle($schema.getNa
         this.${this.mangle($field.name(), $schema.isError())} = data().deepCopy(fields()[$field.pos()].schema(),
other.${this.mangle($field.name(), $schema.isError())});
         fieldSetFlags()[$field.pos()] = true;
       }
+#if (${this.hasBuilder($field.schema())})
+      if (other.${this.generateHasBuilderMethod($schema, $field)}()) {
+        this.${this.mangle($field.name(), $schema.isError())}Builder = ${this.javaType($field.schema())}.newBuilder(other.${this.generateGetBuilderMethod($schema,
$field)}());
+      }
+#end
 #end
     }
     
@@ -177,6 +185,9 @@ public class ${this.mangle($schema.getNa
         this.${this.mangle($field.name(), $schema.isError())} = data().deepCopy(fields()[$field.pos()].schema(),
other.${this.mangle($field.name(), $schema.isError())});
         fieldSetFlags()[$field.pos()] = true;
       }
+#if (${this.hasBuilder($field.schema())})
+      this.${this.mangle($field.name(), $schema.isError())}Builder = null;
+#end
 #end
     }
 #if ($schema.isError())
@@ -224,12 +235,15 @@ public class ${this.mangle($schema.getNa
       */
     public #if ($schema.getNamespace())$schema.getNamespace().#end${this.mangle($schema.getName())}.Builder
${this.generateSetMethod($schema, $field)}(${this.javaUnbox($field.schema())} value) {
       validate(fields()[$field.pos()], value);
+#if (${this.hasBuilder($field.schema())})
+      this.${this.mangle($field.name(), $schema.isError())}Builder = null;
+#end
       this.${this.mangle($field.name(), $schema.isError())} = value;
       fieldSetFlags()[$field.pos()] = true;
       return this; 
     }
 
-    /** 
+    /**
       * Checks whether the '${this.mangle($field.name(), $schema.isError())}' field has been
set.
 #if ($field.doc())      * $field.doc()
 #end
@@ -238,6 +252,40 @@ public class ${this.mangle($schema.getNa
       return fieldSetFlags()[$field.pos()];
     }
 
+#if (${this.hasBuilder($field.schema())})
+    /**
+     * Gets the Builder instance for the '${this.mangle($field.name(), $schema.isError())}'
field and creates one if it doesn't exist yet.
+#if ($field.doc())     * $field.doc()
+#end
+     */
+    public ${this.javaType($field.schema())}.Builder ${this.generateGetBuilderMethod($schema,
$field)}() {
+      if (${this.mangle($field.name(), $schema.isError())}Builder == null) {
+        ${this.generateSetBuilderMethod($schema, $field)}(${this.javaType($field.schema())}.newBuilder());
+      }
+      return ${this.mangle($field.name(), $schema.isError())}Builder;
+    }
+
+    /**
+     * Sets the Builder instance for the '${this.mangle($field.name(), $schema.isError())}'
field
+#if ($field.doc())     * $field.doc()
+#end
+     */
+    public #if ($schema.getNamespace())$schema.getNamespace().#end${this.mangle($schema.getName())}.Builder
${this.generateSetBuilderMethod($schema, $field)}(${this.javaUnbox($field.schema())}.Builder
value) {
+      ${this.generateClearMethod($schema, $field)}();
+      ${this.mangle($field.name(), $schema.isError())}Builder = value;
+      return this;
+    }
+
+    /**
+     * Checks whether the '${this.mangle($field.name(), $schema.isError())}' field has an
active Builder instance
+#if ($field.doc())     * $field.doc()
+#end
+     */
+    public boolean ${this.generateHasBuilderMethod($schema, $field)}() {
+      return ${this.mangle($field.name(), $schema.isError())}Builder != null;
+    }
+#end
+
     /**
       * Clears the value of the '${this.mangle($field.name(), $schema.isError())}' field.
 #if ($field.doc())      * $field.doc()
@@ -247,6 +295,9 @@ public class ${this.mangle($schema.getNa
 #if (${this.isUnboxedJavaTypeNullable($field.schema())})
       ${this.mangle($field.name(), $schema.isError())} = null;
 #end
+#if (${this.hasBuilder($field.schema())})
+      ${this.mangle($field.name(), $schema.isError())}Builder = null;
+#end
       fieldSetFlags()[$field.pos()] = false;
       return this;
     }
@@ -257,8 +308,16 @@ public class ${this.mangle($schema.getNa
       try {
         ${this.mangle($schema.getName())} record = new ${this.mangle($schema.getName())}(#if
($schema.isError())getValue(), getCause()#end);
 #foreach ($field in $schema.getFields())
+#if (${this.hasBuilder($field.schema())})
+        if (${this.mangle($field.name(), $schema.isError())}Builder != null) {
+          record.${this.mangle($field.name(), $schema.isError())} = this.${this.mangle($field.name(),
$schema.isError())}Builder.build();
+        } else {
+          record.${this.mangle($field.name(), $schema.isError())} = fieldSetFlags()[$field.pos()]
? this.${this.mangle($field.name(), $schema.isError())} : (${this.javaType($field.schema())})
defaultValue(fields()[$field.pos()]);
+        }
+#else
         record.${this.mangle($field.name(), $schema.isError())} = fieldSetFlags()[$field.pos()]
? this.${this.mangle($field.name(), $schema.isError())} : (${this.javaType($field.schema())})
defaultValue(fields()[$field.pos()]);
 #end
+#end
         return record;
       } catch (Exception e) {
         throw new org.apache.avro.AvroRuntimeException(e);

Added: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificBuilderTree.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificBuilderTree.java?rev=1646360&view=auto
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificBuilderTree.java
(added)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificBuilderTree.java
Wed Dec 17 23:02:33 2014
@@ -0,0 +1,205 @@
+/**
+ * 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.http.*;
+import org.junit.Test;
+
+import java.util.ArrayList;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+public class TestSpecificBuilderTree {
+
+  private Request.Builder createPartialBuilder() {
+    Request.Builder requestBuilder = Request.newBuilder();
+    requestBuilder.setTimestamp(1234567890);
+
+    requestBuilder
+      .getConnectionBuilder()
+        .setNetworkType(NetworkType.IPv4);
+
+    requestBuilder
+      .getHttpRequestBuilder()
+        .getUserAgentBuilder()
+          .setUseragent("Chrome 123")
+          .setId("Foo");
+
+    requestBuilder
+      .getHttpRequestBuilder()
+        .getURIBuilder()
+          .setMethod(HttpMethod.GET)
+          .setPath("/index.html");
+
+    if (!requestBuilder
+           .getHttpRequestBuilder()
+             .getURIBuilder()
+               .hasParameters()) {
+      requestBuilder
+        .getHttpRequestBuilder()
+          .getURIBuilder()
+            .setParameters(new ArrayList<QueryParameter>());
+    }
+
+    requestBuilder
+      .getHttpRequestBuilder()
+        .getURIBuilder()
+          .getParameters()
+            .add(QueryParameter.newBuilder().setName("Foo").setValue("Bar").build());
+
+    return requestBuilder;
+  }
+
+  @Test(expected = org.apache.avro.AvroRuntimeException.class)
+  public void failOnIncompleteTree() {
+    Request.Builder requestBuilder = createPartialBuilder();
+    Request request = requestBuilder.build();
+    fail("Should NEVER get here");
+  }
+
+  @Test
+  public void copyBuilder() {
+    Request.Builder requestBuilder1 = createPartialBuilder();
+
+    Request.Builder requestBuilder2 = Request.newBuilder(requestBuilder1);
+
+    requestBuilder1
+      .getConnectionBuilder()
+        .setNetworkAddress("1.1.1.1");
+
+    requestBuilder2
+      .getConnectionBuilder()
+        .setNetworkAddress("2.2.2.2");
+
+    requestBuilder2
+      .getHttpRequestBuilder()
+        .getUserAgentBuilder()
+          .setId("Bar");
+
+    Request request1 = requestBuilder1.build();
+    Request request2 = requestBuilder2.build();
+
+    assertEquals(NetworkType.IPv4,  request1.getConnection().getNetworkType());
+    assertEquals("1.1.1.1",         request1.getConnection().getNetworkAddress());
+    assertEquals("Chrome 123",      request1.getHttpRequest().getUserAgent().getUseragent());
+    assertEquals("Foo",             request1.getHttpRequest().getUserAgent().getId());
+    assertEquals(HttpMethod.GET,    request1.getHttpRequest().getURI().getMethod());
+    assertEquals("/index.html",     request1.getHttpRequest().getURI().getPath());
+    assertEquals(1,                 request1.getHttpRequest().getURI().getParameters().size());
+    assertEquals("Foo",             request1.getHttpRequest().getURI().getParameters().get(0).getName());
+    assertEquals("Bar",             request1.getHttpRequest().getURI().getParameters().get(0).getValue());
+
+    assertEquals(NetworkType.IPv4,  request2.getConnection().getNetworkType());
+    assertEquals("2.2.2.2",         request2.getConnection().getNetworkAddress());
+    assertEquals("Chrome 123",      request2.getHttpRequest().getUserAgent().getUseragent());
+    assertEquals("Bar",             request2.getHttpRequest().getUserAgent().getId());
+    assertEquals(HttpMethod.GET,    request2.getHttpRequest().getURI().getMethod());
+    assertEquals("/index.html",     request2.getHttpRequest().getURI().getPath());
+    assertEquals(1,                 request2.getHttpRequest().getURI().getParameters().size());
+    assertEquals("Foo",             request2.getHttpRequest().getURI().getParameters().get(0).getName());
+    assertEquals("Bar",             request2.getHttpRequest().getURI().getParameters().get(0).getValue());
+  }
+
+
+  private Request.Builder createLastOneTestsBuilder() {
+    Request.Builder requestBuilder = Request.newBuilder();
+    requestBuilder.setTimestamp(1234567890);
+
+    requestBuilder
+      .getConnectionBuilder()
+        .setNetworkType(NetworkType.IPv4)
+        .setNetworkAddress("1.1.1.1");
+
+    return requestBuilder;
+  }
+
+  @Test
+  public void lastOneWins_Setter() {
+    Request.Builder requestBuilder = createLastOneTestsBuilder();
+
+    requestBuilder
+      .getHttpRequestBuilder()
+        .getURIBuilder()
+          .setMethod(HttpMethod.GET)
+          .setPath("/index.html");
+
+    requestBuilder
+      .getHttpRequestBuilder()
+        .getUserAgentBuilder()
+          .setUseragent("Chrome 123")
+          .setId("Foo");
+
+    HttpRequest httpRequest = HttpRequest.newBuilder()
+            .setUserAgent(new UserAgent("Bar","Firefox 321"))
+            .setURI(HttpURI.newBuilder()
+                    .setMethod(HttpMethod.POST)
+                    .setPath("/login.php")
+                    .build())
+            .build();
+
+    Request request = requestBuilder.setHttpRequest(httpRequest).build();
+
+    assertEquals(NetworkType.IPv4,  request.getConnection().getNetworkType());
+    assertEquals("1.1.1.1",         request.getConnection().getNetworkAddress());
+    assertEquals(0,                 request.getHttpRequest().getURI().getParameters().size());
+
+    assertEquals("Firefox 321",     request.getHttpRequest().getUserAgent().getUseragent());
+    assertEquals("Bar",             request.getHttpRequest().getUserAgent().getId());
+    assertEquals(HttpMethod.POST,   request.getHttpRequest().getURI().getMethod());
+    assertEquals("/login.php",      request.getHttpRequest().getURI().getPath());
+  }
+
+  @Test
+  public void lastOneWins_Builder() {
+    Request.Builder requestBuilder = createLastOneTestsBuilder();
+
+    HttpRequest httpRequest = HttpRequest.newBuilder()
+            .setUserAgent(new UserAgent("Bar", "Firefox 321"))
+            .setURI(HttpURI.newBuilder()
+                    .setMethod(HttpMethod.POST)
+                    .setPath("/login.php")
+                    .build())
+            .build();
+    requestBuilder.setHttpRequest(httpRequest);
+
+    requestBuilder
+      .getHttpRequestBuilder()
+        .getURIBuilder()
+          .setMethod(HttpMethod.GET)
+          .setPath("/index.html");
+
+    requestBuilder
+      .getHttpRequestBuilder()
+        .getUserAgentBuilder()
+          .setUseragent("Chrome 123")
+          .setId("Foo");
+
+    Request request = requestBuilder.build();
+
+    assertEquals(NetworkType.IPv4,  request.getConnection().getNetworkType());
+    assertEquals("1.1.1.1",         request.getConnection().getNetworkAddress());
+    assertEquals("Chrome 123",      request.getHttpRequest().getUserAgent().getUseragent());
+    assertEquals("Foo",             request.getHttpRequest().getUserAgent().getId());
+    assertEquals(0,                 request.getHttpRequest().getURI().getParameters().size());
+
+    assertEquals(HttpMethod.GET,    request.getHttpRequest().getURI().getMethod());
+    assertEquals("/index.html",     request.getHttpRequest().getURI().getPath());
+  }
+
+}

Propchange: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificBuilderTree.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: avro/trunk/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java?rev=1646360&r1=1646359&r2=1646360&view=diff
==============================================================================
--- avro/trunk/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java
(original)
+++ avro/trunk/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java
Wed Dec 17 23:02:33 2014
@@ -212,7 +212,7 @@ public class Player extends org.apache.a
       return this; 
     }
 
-    /** 
+    /**
       * Checks whether the 'number' field has been set.
       * The number of the player
       */
@@ -220,6 +220,7 @@ public class Player extends org.apache.a
       return fieldSetFlags()[0];
     }
 
+
     /**
       * Clears the value of the 'number' field.
       * The number of the player
@@ -247,13 +248,14 @@ public class Player extends org.apache.a
       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.
       */
@@ -281,13 +283,14 @@ public class Player extends org.apache.a
       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.
       */
@@ -315,13 +318,14 @@ public class Player extends org.apache.a
       return this; 
     }
 
-    /** 
+    /**
       * Checks whether the 'position' field has been set.
       */
     public boolean hasPosition() {
       return fieldSetFlags()[3];
     }
 
+
     /**
       * Clears the value of the 'position' field.
       */

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=1646360&r1=1646359&r2=1646360&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 Wed Dec 17 23:02:33 2014
@@ -212,7 +212,7 @@ public class Player extends org.apache.a
       return this; 
     }
 
-    /** 
+    /**
       * Checks whether the 'number' field has been set.
       * The number of the player
       */
@@ -220,6 +220,7 @@ public class Player extends org.apache.a
       return fieldSetFlags()[0];
     }
 
+
     /**
       * Clears the value of the 'number' field.
       * The number of the player
@@ -247,13 +248,14 @@ public class Player extends org.apache.a
       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.
       */
@@ -281,13 +283,14 @@ public class Player extends org.apache.a
       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.
       */
@@ -315,13 +318,14 @@ public class Player extends org.apache.a
       return this; 
     }
 
-    /** 
+    /**
       * Checks whether the 'position' field has been set.
       */
     public boolean hasPosition() {
       return fieldSetFlags()[3];
     }
 
+
     /**
       * Clears the value of the 'position' field.
       */

Added: avro/trunk/share/test/schemas/http.avdl
URL: http://svn.apache.org/viewvc/avro/trunk/share/test/schemas/http.avdl?rev=1646360&view=auto
==============================================================================
--- avro/trunk/share/test/schemas/http.avdl (added)
+++ avro/trunk/share/test/schemas/http.avdl Wed Dec 17 23:02:33 2014
@@ -0,0 +1,66 @@
+/**
+ * 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.
+ */
+
+/** NOTE: This structure was inspired by HTTP and deliberately skewed to get the effects
that needed testing */
+
+@namespace("org.apache.avro.test.http")
+protocol Http {
+
+    enum NetworkType {
+        IPv4,
+        IPv6
+    }
+
+    record NetworkConnection {
+        NetworkType networkType;
+        string      networkAddress;
+    }
+
+    record UserAgent {
+        union { null, string } id = null;
+        string                      useragent;
+    }
+
+    enum HttpMethod {
+        GET,
+        POST
+    }
+
+    record QueryParameter {
+        string                  name;
+        union { null, string }  value; // Sometimes there is no value.
+    }
+
+    record HttpURI {
+        HttpMethod method;
+        string                path;
+        array<QueryParameter> parameters = [];
+    }
+
+    record HttpRequest {
+        UserAgent         userAgent;
+        HttpURI    URI;
+    }
+
+    record Request {
+      long              timestamp;
+      NetworkConnection connection;
+      HttpRequest       httpRequest;
+    }
+
+}

Added: avro/trunk/share/test/schemas/specialtypes.avdl
URL: http://svn.apache.org/viewvc/avro/trunk/share/test/schemas/specialtypes.avdl?rev=1646360&view=auto
==============================================================================
--- avro/trunk/share/test/schemas/specialtypes.avdl (added)
+++ avro/trunk/share/test/schemas/specialtypes.avdl Wed Dec 17 23:02:33 2014
@@ -0,0 +1,98 @@
+/**
+ * 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.
+ */
+
+/** NOTE: This structure is intended to contain names that are likely to cause collisions
with the generated code. */
+
+@namespace("org.apache.avro.test.specialtypes")
+protocol LetsBreakIt {
+
+    enum Enum {
+        builder,
+        Builder,
+        builderBuider,
+        value,
+        this
+    }
+
+    record One {
+        Enum    this;
+    }
+
+    record Two {
+        union { null, string } this = null;
+        string                 String;
+    }
+
+    record Variables {
+        One       this;
+
+        One       Boolean;
+        One       Integer;
+        One       Long;
+        One       Float;
+        One       String;
+    }
+
+    enum Boolean {
+        Yes,
+        No
+    }
+
+    record String {
+        string value;
+    }
+
+    record builder {
+        One      this;
+        Two      builder;
+    }
+
+    record builderBuilder {
+        One      this;
+        Two      that;
+    }
+
+    record Builder {
+        One      this;
+        Two      that;
+    }
+
+    record value {
+        One      this;
+        Two      that;
+    }
+
+    record Types {
+      Boolean one;
+      builder two;
+      Builder three;
+      builderBuilder four;
+      String five;
+      value six;
+    }
+
+    record Names {
+      string Boolean;
+      string builder;
+      string Builder;
+      string builderBuilder;
+      string String;
+      string value;
+    }
+
+}



Mime
View raw message