Revision: 160
Author: mmastrac
Date: Thu Apr 29 14:18:31 2010
Log: Fix for NPEs throws when trying to serialize a list of maps, where one
of the list members is null.
Adding IndentingPrintWriter to replace the insane amount of code required
to deal with indenting properly.
http://code.google.com/p/gwt-rpc-plus/source/detail?r=160
Added:
/trunk/gwt-rpc-plus/codegen/com/dotspots/rpcplus/codegen/thrift/IndentingPrintWriter.java
Modified:
/trunk/gwt-rpc-plus/codegen/com/dotspots/rpcplus/codegen/thrift/ServerCodeGenRpcInterfaceWriter.java
/trunk/gwt-rpc-plus/example/gen-javabean/com/dotspots/rpcplus/example/torturetest/ObjectWithComplexTypes.java
/trunk/gwt-rpc-plus/example/gen-javabean/com/dotspots/rpcplus/example/torturetest/ObjectWithEnum.java
/trunk/gwt-rpc-plus/example/gen-javabean/com/dotspots/rpcplus/example/torturetest/TortureTestApi.java
/trunk/gwt-rpc-plus/example/gen-json-server/com/dotspots/rpcplus/example/torturetest/TortureTestApiJson.java
/trunk/gwt-rpc-plus/example/server-example/com/dotspots/rpcplus/example/jsonrpc/thrift/ExampleService.java
/trunk/gwt-rpc-plus/example/torturetest.thrift
/trunk/gwt-rpc-plus/test/server-test/com/dotspots/rpcplus/test/server/TestJSONNativeProtocol.java
=======================================
--- /dev/null
+++
/trunk/gwt-rpc-plus/codegen/com/dotspots/rpcplus/codegen/thrift/IndentingPrintWriter.java
Thu Apr 29 14:18:31 2010
@@ -0,0 +1,52 @@
+package com.dotspots.rpcplus.codegen.thrift;
+
+import java.io.PrintWriter;
+import java.util.Stack;
+
+/**
+ * A simple {@link PrintWriter} wrapper that supports automatic indenting.
+ */
+public class IndentingPrintWriter {
+ private static final String INDENT = " ";
+
+ private final PrintWriter printWriter;
+ private String indent = "";
+
+ private Stack<String> indentCheckpoint = new Stack<String>();
+
+ public IndentingPrintWriter(PrintWriter printWriter) {
+ this.printWriter = printWriter;
+ }
+
+ public void println(String string) {
+ printWriter.println(indent + string);
+ }
+
+ public void println() {
+ // Don't need to indent blank lines
+ printWriter.println();
+ }
+
+ public void indent() {
+ indent += INDENT;
+ }
+
+ public void unindent() {
+ if (indent.length() == 0) {
+ assert false : "Unbalanced unindent";
+ return;
+ }
+
+ indent = indent.substring(0, indent.length() - INDENT.length());
+ }
+
+ public void startBlock() {
+ indentCheckpoint.add(indent);
+ }
+
+ public void endBlock() {
+ if (!indent.equals(indentCheckpoint.pop())) {
+ assert false : "Indent state unbalanced";
+ }
+ }
+}
=======================================
---
/trunk/gwt-rpc-plus/codegen/com/dotspots/rpcplus/codegen/thrift/ServerCodeGenRpcInterfaceWriter.java
Thu Nov 5 09:53:20 2009
+++
/trunk/gwt-rpc-plus/codegen/com/dotspots/rpcplus/codegen/thrift/ServerCodeGenRpcInterfaceWriter.java
Thu Apr 29 14:18:31 2010
@@ -8,54 +8,67 @@
import java.util.List;
final class ServerCodeGenRpcInterfaceWriter implements RpcInterfaceWriter {
- private final PrintWriter printWriter;
+ private final IndentingPrintWriter printWriter;
ServerCodeGenRpcInterfaceWriter(PrintWriter printWriter) {
- this.printWriter = printWriter;
+ this.printWriter = new IndentingPrintWriter(printWriter);
}
public void endClass(RpcInterface iface) {
+ printWriter.unindent();
printWriter.println("}");
+ printWriter.endBlock();
}
public void startClass(RpcInterface iface) {
+ printWriter.startBlock();
+
printWriter.println("@SuppressWarnings(\"unused\")");
printWriter.println("public final class " + iface.getClassName() + "Json
implements JSONServlet {");
- printWriter.println(" " + iface.getFullyQualifiedClassName()
+ ".Iface service;");
+ printWriter.indent();
+ printWriter.println(iface.getFullyQualifiedClassName() + ".Iface
service;");
printWriter.println();
- printWriter.println(" public void processRequest(TBaseJSONProtocol
in, TJSONProtocolWriter out) throws TException {");
- printWriter.println(" in.readListBegin();");
- printWriter.println(" in.hasNext();");
- printWriter.println(" int version = in.readI32();");
- printWriter.println(" in.hasNext();");
- printWriter.println(" String call = in.readString();");
- printWriter.println(" in.hasNext();");
+ printWriter.println("public void processRequest(TBaseJSONProtocol in,
TJSONProtocolWriter out) throws TException {");
+ printWriter.indent();
+ printWriter.println("in.readListBegin();");
+ printWriter.println("in.hasNext();");
+ printWriter.println("int version = in.readI32();");
+ printWriter.println("in.hasNext();");
+ printWriter.println("String call = in.readString();");
+ printWriter.println("in.hasNext();");
if (iface.getRequestContext() == null) {
- printWriter.println(" // No context");
- printWriter.println(" in.readString();");
- printWriter.println(" in.hasNext();");
+ printWriter.println("// No context");
+ printWriter.println("in.readString();");
+ printWriter.println("in.hasNext();");
} else {
- printWriter.println(" // Read request context");
- printWriter.println(" service.__setContext(read" +
iface.getRequestContext().getClassName() + "(in));");
- printWriter.println(" in.hasNext();");
+ printWriter.println("// Read request context");
+ printWriter.println("service.__setContext(read" +
iface.getRequestContext().getClassName() + "(in));");
+ printWriter.println("in.hasNext();");
}
for (RpcMethod method : iface.getMethods()) {
- printWriter.println(" if (call.equals(\"" + method.getName()
+ "\")) {");
- printWriter.println(" " + method.getName() + "(in, out);");
- printWriter.println(" return;");
- printWriter.println(" }");
+ printWriter.println("if (call.equals(\"" + method.getName() + "\")) {");
+ printWriter.indent();
+ printWriter.println(method.getName() + "(in, out);");
+ printWriter.println("return;");
+ printWriter.unindent();
+ printWriter.println("}");
}
- printWriter.println(" }");
+ printWriter.unindent();
+ printWriter.println("}");
printWriter.println();
- printWriter.println(" public void setService(" +
iface.getFullyQualifiedClassName() + ".Iface service) {");
- printWriter.println(" this.service = service;");
- printWriter.println(" }");
+ printWriter.println("public void setService(" +
iface.getFullyQualifiedClassName() + ".Iface service) {");
+ printWriter.indent();
+ printWriter.println("this.service = service;");
+ printWriter.unindent();
+ printWriter.println("}");
printWriter.println();
}
public void writePackage(String packageName) {
+ printWriter.startBlock();
+
printWriter.println("package " + packageName + ";");
printWriter.println();
printWriter.println("import java.util.ArrayList;");
@@ -74,125 +87,164 @@
printWriter.println();
printWriter.println("import com.dotspots.rpcplus.jsonrpc.thrift.*;");
printWriter.println();
+
+ printWriter.endBlock();
}
public void writeMethod(RpcInterface iface, RpcMethod method) {
+ printWriter.startBlock();
+
List<String> args = new ArrayList<String>();
for (RpcField field : method.getArgsInDeclaredOrder()) {
args.add("args." + field.getGetterName() + "()");
}
- printWriter.println(" private final void " + method.getName()
+ printWriter.println("private final void " + method.getName()
+ "(TBaseJSONProtocol in, TJSONProtocolWriter out) throws TException
{");
- printWriter.println(" " + iface.getClassName() + "." +
method.getName() + "_args args = read" + iface.getClassName() + "_"
+ printWriter.indent();
+ printWriter.println(iface.getClassName() + "." + method.getName()
+ "_args args = read" + iface.getClassName() + "_"
+ method.getName() + "_args(in);");
- printWriter.println(" " + iface.getClassName() + "." +
method.getName() + "_result result = new " + iface.getClassName()
- + "." + method.getName() + "_result();");
- printWriter.println(" try {");
+ printWriter.println(iface.getClassName() + "." + method.getName()
+ "_result result = new " + iface.getClassName() + "."
+ + method.getName() + "_result();");
+ printWriter.println("try {");
+ printWriter.indent();
if (method.getResult().getTypeKey() == RpcTypeKey.VOID) {
- printWriter.println(" service." + method.getName() + "(" +
StringUtils.join(args, ", ") + ");");
+ printWriter.println("service." + method.getName() + "(" +
StringUtils.join(args, ", ") + ");");
} else {
- printWriter.println(" " + getType(method.getResult(), false)
+ " methodResult = service." + method.getName() + "("
+ printWriter.println(getType(method.getResult(), false) + " methodResult
= service." + method.getName() + "("
+ StringUtils.join(args, ", ") + ");");
- printWriter.println(" result.setSuccess(methodResult);");
- }
- printWriter.println(" out.writeListBegin(null);");
- printWriter.println(" out.writeI32(0); // Version");
- printWriter.println(" out.writeI32(0); // Success");
- printWriter.println(" write" + iface.getClassName() + "_" +
method.getName() + "_result(out, result);");
+ printWriter.println("result.setSuccess(methodResult);");
+ }
+ printWriter.println("out.writeListBegin(null);");
+ printWriter.println("out.writeI32(0); // Version");
+ printWriter.println("out.writeI32(0); // Success");
+ printWriter.println("write" + iface.getClassName() + "_" +
method.getName() + "_result(out, result);");
writeResponseContext(iface);
- printWriter.println(" out.writeListEnd();");
+ printWriter.println("out.writeListEnd();");
int index = 1;
for (RpcStruct type : method.getExceptionTypes()) {
- printWriter.println(" } catch (" +
type.getFullyQualifiedClassName() + " e) {");
- printWriter.println(" out.writeListBegin(null);");
- printWriter.println(" out.writeI32(0); // Version");
- printWriter.println(" out.writeI32(" + index + "); //
Failure");
- printWriter.println(" result.setFieldValue(" + index + ",
e);");
- printWriter.println(" write" + iface.getClassName() + "_" +
method.getName() + "_result(out, result);");
+ printWriter.unindent();
+ printWriter.println("} catch (" + type.getFullyQualifiedClassName() + "
e) {");
+ printWriter.indent();
+ printWriter.println("out.writeListBegin(null);");
+ printWriter.println("out.writeI32(0); // Version");
+ printWriter.println("out.writeI32(" + index + "); // Failure");
+ printWriter.println("result.setFieldValue(" + index + ", e);");
+ printWriter.println("write" + iface.getClassName() + "_" +
method.getName() + "_result(out, result);");
writeResponseContext(iface);
- printWriter.println(" out.writeListEnd();");
+ printWriter.println("out.writeListEnd();");
index++;
}
- printWriter.println(" } catch (Throwable t) {");
- printWriter.println(" // Log unexpected exceptions");
- printWriter.println(" java.util.logging.Logger.getLogger(\""
+ iface.getFullyQualifiedClassName()
+ printWriter.unindent();
+ printWriter.println("} catch (Throwable t) {");
+ printWriter.indent();
+ printWriter.println("// Log unexpected exceptions");
+ printWriter.println("java.util.logging.Logger.getLogger(\"" +
iface.getFullyQualifiedClassName()
+ "\").log(java.util.logging.Level.SEVERE, \"Unexpected error\", t);");
- printWriter.println(" }");
- printWriter.println(" };");
+ printWriter.unindent();
+ printWriter.println("}");
+ printWriter.unindent();
+ printWriter.println("};");
printWriter.println();
+
+ printWriter.endBlock();
}
private void writeResponseContext(RpcInterface iface) {
+ printWriter.startBlock();
+
if (iface.getResponseContext() != null) {
- printWriter.println(" " +
iface.getResponseContext().getClassName() + " responseContext =
service.__getContext();");
- printWriter.println(" if (responseContext != null) {");
- printWriter.println(" write" +
iface.getResponseContext().getClassName() + "(out, responseContext);");
- printWriter.println(" }");
- }
+ printWriter.println(iface.getResponseContext().getClassName() + "
responseContext = service.__getContext();");
+ printWriter.println("if (responseContext != null) {");
+ printWriter.indent();
+ printWriter.println("write" + iface.getResponseContext().getClassName()
+ "(out, responseContext);");
+ printWriter.unindent();
+ printWriter.println("}");
+ }
+
+ printWriter.endBlock();
}
public void writeType(RpcStruct type) {
- printWriter.println(" public static final " + type.getPackageName()
+ "." + type.getClassName(true) + " read"
+ printWriter.startBlock();
+
+ printWriter.println("public static final " + type.getPackageName() + "."
+ type.getClassName(true) + " read"
+ type.getClassName(false) + "(TBaseJSONProtocol protocol) throws
TException {");
- printWriter.println(" " + type.getPackageName() + "." +
type.getClassName(true) + " obj = new " + type.getPackageName()
- + "." + type.getClassName(true) + "();");
- printWriter.println(" if (protocol.readStructBegin()) {");
- printWriter.println(" int fieldId;");
- printWriter.println(" while(protocol.hasNext()) {");
- printWriter.println(" switch (protocol.readI32()) {");
+ printWriter.indent();
+ printWriter.println(type.getPackageName() + "." +
type.getClassName(true) + " obj = new " + type.getPackageName() + "."
+ + type.getClassName(true) + "();");
+ printWriter.println("if (protocol.readStructBegin()) {");
+ printWriter.indent();
+ printWriter.println("int fieldId;");
+ printWriter.println("while(protocol.hasNext()) {");
+ printWriter.indent();
+ printWriter.println("switch (protocol.readI32()) {");
+ printWriter.indent();
for (RpcField field : type.getOrderedFields()) {
- printWriter.println(" case " + field.getKey() + ": {");
+ printWriter.println("case " + field.getKey() + ": {");
+ printWriter.indent();
writeReader(type.getTypeFactory(), field.getType(), "value", 0);
- printWriter.println(" obj." + field.getSetterName()
+ "(value0);");
- printWriter.println(" break;");
- printWriter.println(" }");
+ printWriter.println("obj." + field.getSetterName() + "(value0);");
+ printWriter.println("break;");
+ printWriter.unindent();
+ printWriter.println("}");
}
- printWriter.println(" default:");
- printWriter.println(" protocol.skip();");
-
- printWriter.println(" }");
- printWriter.println(" }");
- printWriter.println(" }");
- printWriter.println(" return obj;");
- printWriter.println(" }");
+ printWriter.println("default:");
+ printWriter.indent();
+ printWriter.println("protocol.skip();");
+ printWriter.unindent();
+
+ printWriter.unindent();
+ printWriter.println("}");
+ printWriter.unindent();
+ printWriter.println("}");
+ printWriter.unindent();
+ printWriter.println("}");
+ printWriter.println("return obj;");
+ printWriter.unindent();
+ printWriter.println("}");
printWriter.println();
- printWriter.println(" private static final void write" +
type.getClassName(false) + "(TJSONProtocolWriter protocol, "
+ printWriter.println("private static final void write" +
type.getClassName(false) + "(TJSONProtocolWriter protocol, "
+ type.getPackageName() + "." + type.getClassName(true) + " obj)
throws TException {");
- printWriter.println(" if (obj == null) {");
- printWriter.println(" protocol.writeNull();");
- printWriter.println(" return;");
- printWriter.println(" }");
-
- printWriter.println(" protocol.writeStructBegin(null);");
+ printWriter.indent();
+ printWriter.println("if (obj == null) {");
+ printWriter.indent();
+ printWriter.println("protocol.writeNull();");
+ printWriter.println("return;");
+ printWriter.unindent();
+ printWriter.println("}");
+
+ printWriter.println("protocol.writeStructBegin(null);");
for (RpcField field : type.getOrderedFields()) {
- printWriter.println(" if (obj." + field.getIsSetName() + "())
{");
- printWriter.println(" protocol.writeI32(" + field.getKey()
+ ");");
- printWriter.println(" " + getType(field.getType(), false)
+ " value0 = obj." + field.getGetterName() + "();");
+ printWriter.println("if (obj." + field.getIsSetName() + "()) {");
+ printWriter.indent();
+ printWriter.println("protocol.writeI32(" + field.getKey() + ");");
+ printWriter.println(getType(field.getType(), false) + " value0 = obj."
+ field.getGetterName() + "();");
writeWriter(type.getTypeFactory(), field.getType(), "value", 0);
- printWriter.println(" }");
- }
- printWriter.println(" protocol.writeStructEnd();");
- printWriter.println(" }");
+ printWriter.unindent();
+ printWriter.println("}");
+ }
+ printWriter.println("protocol.writeStructEnd();");
+ printWriter.unindent();
+ printWriter.println("}");
printWriter.println();
+
+ printWriter.endBlock();
}
private void writeReader(RpcTypeFactory typeFactory, RpcTypeBase
fieldType, String name, int level) {
- String indent = " ";
- for (int i = 0; i < level; i++) {
- indent += " ";
- }
-
- final String declaration = indent + getType(fieldType, false) + " " +
name + level + " = ";
- final String assignment = indent + " " + name + level + " = ";
+ printWriter.startBlock();
+
+ final String declaration = getType(fieldType, false) + " " + name +
level + " = ";
+ final String assignment = name + level + " = ";
switch (fieldType.getTypeKey()) {
case STRUCT:
@@ -202,96 +254,137 @@
case SET:
printWriter.println(declaration + "null;");
- printWriter.println(indent + "if (protocol.readSetBegin()) {");
+ printWriter.println("if (protocol.readSetBegin()) {");
+ printWriter.indent();
printWriter.println(assignment + "new Hash" + getType(fieldType, true)
+ "();");
RpcTypeSet setMetaData = (RpcTypeSet) fieldType;
- printWriter.println(indent + " while (protocol.hasNext()) {");
+ printWriter.println("while (protocol.hasNext()) {");
+ printWriter.indent();
writeReader(typeFactory, setMetaData.getElementType(), name, level + 1);
- printWriter.println(indent + " " + name + level + ".add(" + name
+ (level + 1) + ");");
- printWriter.println(indent + " }");
- printWriter.println(indent + "}");
+ printWriter.println(name + level + ".add(" + name + (level + 1) + ");");
+ printWriter.unindent();
+ printWriter.println("}");
+ printWriter.unindent();
+ printWriter.println("}");
break;
case MAP:
printWriter.println(declaration + "null;");
- printWriter.println(indent + "if (protocol.readMapBegin()) {");
+ printWriter.println("if (protocol.readMapBegin()) {");
+ printWriter.indent();
printWriter.println(assignment + "new Hash" + getType(fieldType, true)
+ "();");
RpcTypeMap mapMetaData = (RpcTypeMap) fieldType;
- printWriter.println(indent + " while (protocol.hasNext()) {");
+ printWriter.println("while (protocol.hasNext()) {");
+ printWriter.indent();
writeReader(typeFactory, mapMetaData.getKeyType(), "key", level + 1);
writeReader(typeFactory, mapMetaData.getValueType(), "value", level +
1);
- printWriter.println(indent + " " + name + level + ".put(key" +
(level + 1) + ", value" + (level + 1) + ");");
- printWriter.println(indent + " }");
- printWriter.println(indent + "}");
+ printWriter.println(name + level + ".put(key" + (level + 1) + ", value"
+ (level + 1) + ");");
+ printWriter.unindent();
+ printWriter.println("}");
+ printWriter.unindent();
+ printWriter.println("}");
break;
case LIST:
printWriter.println(declaration + "null;");
- printWriter.println(indent + "if (protocol.readListBegin()) {");
+ printWriter.println("if (protocol.readListBegin()) {");
+ printWriter.indent();
printWriter.println(assignment + "new Array" + getType(fieldType, true)
+ "();");
RpcTypeList listMetaData = (RpcTypeList) fieldType;
- printWriter.println(indent + " while (protocol.hasNext()) {");
+ printWriter.println("while (protocol.hasNext()) {");
+ printWriter.indent();
writeReader(typeFactory, listMetaData.getElementType(), name, level +
1);
- printWriter.println(indent + " " + name + level + ".add(" + name
+ (level + 1) + ");");
- printWriter.println(indent + " }");
- printWriter.println(indent + "}");
+ printWriter.println(name + level + ".add(" + name + (level + 1) + ");");
+ printWriter.unindent();
+ printWriter.println("}");
+ printWriter.unindent();
+ printWriter.println("}");
break;
default:
printWriter.println(declaration + "protocol.read" +
fieldType.getTypeKey().getThriftTypeString() + "();");
}
+
+ printWriter.endBlock();
}
private void writeWriter(RpcTypeFactory typeFactory, RpcTypeBase
fieldType, String name, int level) {
- String indent = " ";
- for (int i = 0; i < level; i++) {
- indent += " ";
- }
+ printWriter.startBlock();
switch (fieldType.getTypeKey()) {
case STRUCT:
RpcStruct structType = ((RpcTypeStruct) fieldType).getStruct();
- printWriter.println(indent + "write" + structType.getClassName(false)
+ "(protocol, " + name + level + ");");
+ printWriter.println("write" + structType.getClassName(false)
+ "(protocol, " + name + level + ");");
break;
case SET:
RpcTypeSet setMetaData = (RpcTypeSet) fieldType;
- printWriter.println(indent + "protocol.writeSetBegin(null);");
- printWriter.println(indent + "for (" +
getType(setMetaData.getElementType(), false) + " " + name + (level + 1)
+ " : " + name
- + level + ") {");
+ printWriter.println("if (" + name + level + " == null) {");
+ printWriter.indent();
+ printWriter.println("protocol.writeNull();");
+ printWriter.unindent();
+ printWriter.println("} else {");
+ printWriter.indent();
+ printWriter.println("protocol.writeSetBegin(null);");
+ printWriter.println("for (" + getType(setMetaData.getElementType(),
false) + " " + name + (level + 1) + " : " + name + level
+ + ") {");
+ printWriter.indent();
writeWriter(typeFactory, setMetaData.getElementType(), name, level + 1);
- printWriter.println(indent + "}");
- printWriter.println(indent + "protocol.writeSetEnd();");
+ printWriter.unindent();
+ printWriter.println("}");
+ printWriter.println("protocol.writeSetEnd();");
+ printWriter.unindent();
+ printWriter.println("}");
break;
case MAP:
RpcTypeMap mapMetaData = (RpcTypeMap) fieldType;
- printWriter.println(indent + "protocol.writeMapBegin(null);");
- printWriter.println(indent + "for (Map.Entry<" +
getType(mapMetaData.getKeyType(), true) + ", "
+ printWriter.println("if (" + name + level + " == null) {");
+ printWriter.indent();
+ printWriter.println("protocol.writeNull();");
+ printWriter.unindent();
+ printWriter.println("} else {");
+ printWriter.indent();
+ printWriter.println("protocol.writeMapBegin(null);");
+ printWriter.println("for (Map.Entry<" +
getType(mapMetaData.getKeyType(), true) + ", "
+ getType(mapMetaData.getValueType(), true) + "> entry" + level
+ " : " + name + level + ".entrySet()) {");
- printWriter.println(indent + " " + getType(mapMetaData.getKeyType(),
false) + " key" + (level + 1) + " = entry" + level
- + ".getKey();");
- printWriter.println(indent + " " +
getType(mapMetaData.getValueType(), false) + " value" + (level + 1) + " =
entry" + level
- + ".getValue();");
+ printWriter.indent();
+ printWriter.println(getType(mapMetaData.getKeyType(), false) + " key" +
(level + 1) + " = entry" + level + ".getKey();");
+ printWriter.println(getType(mapMetaData.getValueType(), false) + "
value" + (level + 1) + " = entry" + level + ".getValue();");
writeWriter(typeFactory, mapMetaData.getKeyType(), "key", level + 1);
writeWriter(typeFactory, mapMetaData.getValueType(), "value", level +
1);
- printWriter.println(indent + "}");
- printWriter.println(indent + "protocol.writeMapEnd();");
+ printWriter.unindent();
+ printWriter.println("}");
+ printWriter.println("protocol.writeMapEnd();");
+ printWriter.unindent();
+ printWriter.println("}");
break;
case LIST:
RpcTypeList listMetaData = (RpcTypeList) fieldType;
- printWriter.println(indent + "protocol.writeListBegin(null);");
- printWriter.println(indent + "for (" +
getType(listMetaData.getElementType(), false) + " " + name + (level + 1)
+ " : " + name
- + level + ") {");
+ printWriter.println("if (" + name + level + " == null) {");
+ printWriter.indent();
+ printWriter.println("protocol.writeNull();");
+ printWriter.unindent();
+ printWriter.println("} else {");
+ printWriter.indent();
+ printWriter.println("protocol.writeListBegin(null);");
+ printWriter.println("for (" + getType(listMetaData.getElementType(),
false) + " " + name + (level + 1) + " : " + name + level
+ + ") {");
+ printWriter.indent();
writeWriter(typeFactory, listMetaData.getElementType(), name, level +
1);
- printWriter.println(indent + "}");
- printWriter.println(indent + "protocol.writeListEnd();");
+ printWriter.unindent();
+ printWriter.println("}");
+ printWriter.println("protocol.writeListEnd();");
+ printWriter.unindent();
+ printWriter.println("}");
break;
default:
- printWriter.println(indent + "protocol.write" +
fieldType.getTypeKey().getThriftTypeString() + "(" + name + level + ");");
- }
+ printWriter.println("protocol.write" +
fieldType.getTypeKey().getThriftTypeString() + "(" + name + level + ");");
+ }
+
+ printWriter.endBlock();
}
private String getType(RpcTypeBase valueMetaData, boolean boxed) {
=======================================
---
/trunk/gwt-rpc-plus/example/gen-javabean/com/dotspots/rpcplus/example/torturetest/ObjectWithComplexTypes.java
Wed Apr 28 15:56:15 2010
+++
/trunk/gwt-rpc-plus/example/gen-javabean/com/dotspots/rpcplus/example/torturetest/ObjectWithComplexTypes.java
Thu Apr 29 14:18:31 2010
@@ -29,6 +29,7 @@
private static final TField LIST_OF_MAP_STRING_TO_I32_FIELD_DESC = new
TField("listOfMapStringToI32", TType.LIST, (short)7);
private static final TField MAP_OF_MAP_I32_TO_I32_FIELD_DESC = new
TField("mapOfMapI32ToI32", TType.MAP, (short)8);
private static final TField MAP_OF_MAP_STRING_TO_STRING_FIELD_DESC = new
TField("mapOfMapStringToString", TType.MAP, (short)9);
+ private static final TField LIST_OF_OBJECTS_FIELD_DESC = new
TField("listOfObjects", TType.LIST, (short)10);
private Map<String,String> mapStringToString;
public static final int MAPSTRINGTOSTRING = 1;
@@ -48,6 +49,8 @@
public static final int MAPOFMAPI32TOI32 = 8;
private Map<String,Map<String,String>> mapOfMapStringToString;
public static final int MAPOFMAPSTRINGTOSTRING = 9;
+ private List<SimpleObjectWithFieldIds> listOfObjects;
+ public static final int LISTOFOBJECTS = 10;
private final Isset __isset = new Isset();
private static final class Isset implements java.io.Serializable {
@@ -95,6 +98,9 @@
new MapMetaData(TType.MAP,
new FieldValueMetaData(TType.STRING),
new FieldValueMetaData(TType.STRING)))));
+ put(LISTOFOBJECTS, new FieldMetaData("listOfObjects",
TFieldRequirementType.DEFAULT,
+ new ListMetaData(TType.LIST,
+ new StructMetaData(TType.STRUCT,
SimpleObjectWithFieldIds.class))));
}});
static {
@@ -113,7 +119,8 @@
List<Map<Integer,String>> listOfMapI32ToString,
List<Map<String,Integer>> listOfMapStringToI32,
Map<String,Map<Integer,Integer>> mapOfMapI32ToI32,
- Map<String,Map<String,String>> mapOfMapStringToString)
+ Map<String,Map<String,String>> mapOfMapStringToString,
+ List<SimpleObjectWithFieldIds> listOfObjects)
{
this();
this.mapStringToString = mapStringToString;
@@ -125,6 +132,7 @@
this.listOfMapStringToI32 = listOfMapStringToI32;
this.mapOfMapI32ToI32 = mapOfMapI32ToI32;
this.mapOfMapStringToString = mapOfMapStringToString;
+ this.listOfObjects = listOfObjects;
}
/**
@@ -284,6 +292,13 @@
}
this.mapOfMapStringToString = __this__mapOfMapStringToString;
}
+ if (other.isSetListOfObjects()) {
+ List<SimpleObjectWithFieldIds> __this__listOfObjects = new
ArrayList<SimpleObjectWithFieldIds>();
+ for (SimpleObjectWithFieldIds other_element : other.listOfObjects) {
+ __this__listOfObjects.add(new
SimpleObjectWithFieldIds(other_element));
+ }
+ this.listOfObjects = __this__listOfObjects;
+ }
}
@Override
@@ -562,6 +577,38 @@
public boolean isSetMapOfMapStringToString() {
return this.mapOfMapStringToString != null;
}
+
+ public int getListOfObjectsSize() {
+ return (this.listOfObjects == null) ? 0 : this.listOfObjects.size();
+ }
+
+ public java.util.Iterator<SimpleObjectWithFieldIds>
getListOfObjectsIterator() {
+ return (this.listOfObjects == null) ? null :
this.listOfObjects.iterator();
+ }
+
+ public void addToListOfObjects(SimpleObjectWithFieldIds elem) {
+ if (this.listOfObjects == null) {
+ this.listOfObjects = new ArrayList<SimpleObjectWithFieldIds>();
+ }
+ this.listOfObjects.add(elem);
+ }
+
+ public List<SimpleObjectWithFieldIds> getListOfObjects() {
+ return this.listOfObjects;
+ }
+
+ public void setListOfObjects(List<SimpleObjectWithFieldIds>
listOfObjects) {
+ this.listOfObjects = listOfObjects;
+ }
+
+ public void unsetListOfObjects() {
+ this.listOfObjects = null;
+ }
+
+ // Returns true if field listOfObjects is set (has been asigned a value)
and false otherwise
+ public boolean isSetListOfObjects() {
+ return this.listOfObjects != null;
+ }
public void setFieldValue(int fieldID, Object value) {
switch (fieldID) {
@@ -637,6 +684,14 @@
}
break;
+ case LISTOFOBJECTS:
+ if (value == null) {
+ unsetListOfObjects();
+ } else {
+ setListOfObjects((List<SimpleObjectWithFieldIds>)value);
+ }
+ break;
+
default:
throw new IllegalArgumentException("Field " + fieldID + " doesn't
exist!");
}
@@ -671,6 +726,9 @@
case MAPOFMAPSTRINGTOSTRING:
return getMapOfMapStringToString();
+ case LISTOFOBJECTS:
+ return getListOfObjects();
+
default:
throw new IllegalArgumentException("Field " + fieldID + " doesn't
exist!");
}
@@ -697,6 +755,8 @@
return isSetMapOfMapI32ToI32();
case MAPOFMAPSTRINGTOSTRING:
return isSetMapOfMapStringToString();
+ case LISTOFOBJECTS:
+ return isSetListOfObjects();
default:
throw new IllegalArgumentException("Field " + fieldID + " doesn't
exist!");
}
@@ -795,6 +855,15 @@
if (!this.mapOfMapStringToString.equals(that.mapOfMapStringToString))
return false;
}
+
+ boolean this_present_listOfObjects = true && this.isSetListOfObjects();
+ boolean that_present_listOfObjects = true && that.isSetListOfObjects();
+ if (this_present_listOfObjects || that_present_listOfObjects) {
+ if (!(this_present_listOfObjects && that_present_listOfObjects))
+ return false;
+ if (!this.listOfObjects.equals(that.listOfObjects))
+ return false;
+ }
return true;
}
@@ -1032,6 +1101,24 @@
}
iprot.readMapEnd();
}
+ } else {
+ TProtocolUtil.skip(iprot, field.type);
+ }
+ break;
+ case LISTOFOBJECTS:
+ if (field.type == TType.LIST) {
+ {
+ TList _list51 = iprot.readListBegin();
+ this.listOfObjects = new
ArrayList<SimpleObjectWithFieldIds>(_list51.size);
+ for (int _i52 = 0; _i52 < _list51.size; ++_i52)
+ {
+ SimpleObjectWithFieldIds _elem53;
+ _elem53 = new SimpleObjectWithFieldIds();
+ _elem53.read(iprot);
+ this.listOfObjects.add(_elem53);
+ }
+ iprot.readListEnd();
+ }
} else {
TProtocolUtil.skip(iprot, field.type);
}
@@ -1055,9 +1142,9 @@
oprot.writeFieldBegin(MAP_STRING_TO_STRING_FIELD_DESC);
{
oprot.writeMapBegin(new TMap(TType.STRING, TType.STRING,
this.mapStringToString.size()));
- for (Map.Entry<String, String> _iter51 :
this.mapStringToString.entrySet()) {
- oprot.writeString(_iter51.getKey());
- oprot.writeString(_iter51.getValue());
+ for (Map.Entry<String, String> _iter54 :
this.mapStringToString.entrySet()) {
+ oprot.writeString(_iter54.getKey());
+ oprot.writeString(_iter54.getValue());
}
oprot.writeMapEnd();
}
@@ -1067,8 +1154,8 @@
oprot.writeFieldBegin(SET_OF_STRINGS_FIELD_DESC);
{
oprot.writeSetBegin(new TSet(TType.STRING,
this.setOfStrings.size()));
- for (String _iter52 : this.setOfStrings) {
- oprot.writeString(_iter52);
+ for (String _iter55 : this.setOfStrings) {
+ oprot.writeString(_iter55);
}
oprot.writeSetEnd();
}
@@ -1078,8 +1165,8 @@
oprot.writeFieldBegin(LIST_OF_STRINGS_FIELD_DESC);
{
oprot.writeListBegin(new TList(TType.STRING,
this.listOfStrings.size()));
- for (String _iter53 : this.listOfStrings) {
- oprot.writeString(_iter53);
+ for (String _iter56 : this.listOfStrings) {
+ oprot.writeString(_iter56);
}
oprot.writeListEnd();
}
@@ -1089,9 +1176,9 @@
oprot.writeFieldBegin(MAP_OF_INT_TO_INT_FIELD_DESC);
{
oprot.writeMapBegin(new TMap(TType.I32, TType.I32,
this.mapOfIntToInt.size()));
- for (Map.Entry<Integer, Integer> _iter54 :
this.mapOfIntToInt.entrySet()) {
- oprot.writeI32(_iter54.getKey());
- oprot.writeI32(_iter54.getValue());
+ for (Map.Entry<Integer, Integer> _iter57 :
this.mapOfIntToInt.entrySet()) {
+ oprot.writeI32(_iter57.getKey());
+ oprot.writeI32(_iter57.getValue());
}
oprot.writeMapEnd();
}
@@ -1101,12 +1188,12 @@
oprot.writeFieldBegin(LIST_OF_MAP_STRING_TO_STRING_FIELD_DESC);
{
oprot.writeListBegin(new TList(TType.MAP,
this.listOfMapStringToString.size()));
- for (Map<String,String> _iter55 :
this.listOfMapStringToString) {
- {
- oprot.writeMapBegin(new TMap(TType.STRING, TType.STRING,
_iter55.size()));
- for (Map.Entry<String, String> _iter56 :
_iter55.entrySet()) {
- oprot.writeString(_iter56.getKey());
- oprot.writeString(_iter56.getValue());
+ for (Map<String,String> _iter58 :
this.listOfMapStringToString) {
+ {
+ oprot.writeMapBegin(new TMap(TType.STRING, TType.STRING,
_iter58.size()));
+ for (Map.Entry<String, String> _iter59 :
_iter58.entrySet()) {
+ oprot.writeString(_iter59.getKey());
+ oprot.writeString(_iter59.getValue());
}
oprot.writeMapEnd();
}
@@ -1119,12 +1206,12 @@
oprot.writeFieldBegin(LIST_OF_MAP_I32_TO_STRING_FIELD_DESC);
{
oprot.writeListBegin(new TList(TType.MAP,
this.listOfMapI32ToString.size()));
- for (Map<Integer,String> _iter57 :
this.listOfMapI32ToString) {
- {
- oprot.writeMapBegin(new TMap(TType.I32, TType.STRING,
_iter57.size()));
- for (Map.Entry<Integer, String> _iter58 :
_iter57.entrySet()) {
- oprot.writeI32(_iter58.getKey());
- oprot.writeString(_iter58.getValue());
+ for (Map<Integer,String> _iter60 :
this.listOfMapI32ToString) {
+ {
+ oprot.writeMapBegin(new TMap(TType.I32, TType.STRING,
_iter60.size()));
+ for (Map.Entry<Integer, String> _iter61 :
_iter60.entrySet()) {
+ oprot.writeI32(_iter61.getKey());
+ oprot.writeString(_iter61.getValue());
}
oprot.writeMapEnd();
}
@@ -1137,12 +1224,12 @@
oprot.writeFieldBegin(LIST_OF_MAP_STRING_TO_I32_FIELD_DESC);
{
oprot.writeListBegin(new TList(TType.MAP,
this.listOfMapStringToI32.size()));
- for (Map<String,Integer> _iter59 :
this.listOfMapStringToI32) {
- {
- oprot.writeMapBegin(new TMap(TType.STRING, TType.I32,
_iter59.size()));
- for (Map.Entry<String, Integer> _iter60 :
_iter59.entrySet()) {
- oprot.writeString(_iter60.getKey());
- oprot.writeI32(_iter60.getValue());
+ for (Map<String,Integer> _iter62 :
this.listOfMapStringToI32) {
+ {
+ oprot.writeMapBegin(new TMap(TType.STRING, TType.I32,
_iter62.size()));
+ for (Map.Entry<String, Integer> _iter63 :
_iter62.entrySet()) {
+ oprot.writeString(_iter63.getKey());
+ oprot.writeI32(_iter63.getValue());
}
oprot.writeMapEnd();
}
@@ -1155,13 +1242,13 @@
oprot.writeFieldBegin(MAP_OF_MAP_I32_TO_I32_FIELD_DESC);
{
oprot.writeMapBegin(new TMap(TType.STRING, TType.MAP,
this.mapOfMapI32ToI32.size()));
- for (Map.Entry<String, Map<Integer,Integer>> _iter61 :
this.mapOfMapI32ToI32.entrySet()) {
- oprot.writeString(_iter61.getKey());
- {
- oprot.writeMapBegin(new TMap(TType.I32, TType.I32,
_iter61.getValue().size()));
- for (Map.Entry<Integer, Integer> _iter62 :
_iter61.getValue().entrySet()) {
- oprot.writeI32(_iter62.getKey());
- oprot.writeI32(_iter62.getValue());
+ for (Map.Entry<String, Map<Integer,Integer>> _iter64 :
this.mapOfMapI32ToI32.entrySet()) {
+ oprot.writeString(_iter64.getKey());
+ {
+ oprot.writeMapBegin(new TMap(TType.I32, TType.I32,
_iter64.getValue().size()));
+ for (Map.Entry<Integer, Integer> _iter65 :
_iter64.getValue().entrySet()) {
+ oprot.writeI32(_iter65.getKey());
+ oprot.writeI32(_iter65.getValue());
}
oprot.writeMapEnd();
}
@@ -1174,13 +1261,13 @@
oprot.writeFieldBegin(MAP_OF_MAP_STRING_TO_STRING_FIELD_DESC);
{
oprot.writeMapBegin(new TMap(TType.STRING, TType.MAP,
this.mapOfMapStringToString.size()));
- for (Map.Entry<String, Map<String,String>> _iter63 :
this.mapOfMapStringToString.entrySet()) {
- oprot.writeString(_iter63.getKey());
- {
- oprot.writeMapBegin(new TMap(TType.STRING, TType.STRING,
_iter63.getValue().size()));
- for (Map.Entry<String, String> _iter64 :
_iter63.getValue().entrySet()) {
- oprot.writeString(_iter64.getKey());
- oprot.writeString(_iter64.getValue());
+ for (Map.Entry<String, Map<String,String>> _iter66 :
this.mapOfMapStringToString.entrySet()) {
+ oprot.writeString(_iter66.getKey());
+ {
+ oprot.writeMapBegin(new TMap(TType.STRING, TType.STRING,
_iter66.getValue().size()));
+ for (Map.Entry<String, String> _iter67 :
_iter66.getValue().entrySet()) {
+ oprot.writeString(_iter67.getKey());
+ oprot.writeString(_iter67.getValue());
}
oprot.writeMapEnd();
}
@@ -1189,6 +1276,17 @@
}
oprot.writeFieldEnd();
}
+ if (this.listOfObjects != null) {
+ oprot.writeFieldBegin(LIST_OF_OBJECTS_FIELD_DESC);
+ {
+ oprot.writeListBegin(new TList(TType.STRUCT,
this.listOfObjects.size()));
+ for (SimpleObjectWithFieldIds _iter68 : this.listOfObjects)
{
+ _iter68.write(oprot);
+ }
+ oprot.writeListEnd();
+ }
+ oprot.writeFieldEnd();
+ }
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@@ -1268,6 +1366,14 @@
} else {
sb.append(this.mapOfMapStringToString);
}
+ first = false;
+ if (!first) sb.append(", ");
+ sb.append("listOfObjects:");
+ if (this.listOfObjects == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.listOfObjects);
+ }
first = false;
sb.append(")");
return sb.toString();
=======================================
---
/trunk/gwt-rpc-plus/example/gen-javabean/com/dotspots/rpcplus/example/torturetest/ObjectWithEnum.java
Wed Apr 28 15:56:15 2010
+++
/trunk/gwt-rpc-plus/example/gen-javabean/com/dotspots/rpcplus/example/torturetest/ObjectWithEnum.java
Thu Apr 29 14:18:31 2010
@@ -380,13 +380,13 @@
case ENUMSET:
if (field.type == TType.SET) {
{
- TSet _set65 = iprot.readSetBegin();
- this.enumSet = new HashSet<Integer>(2*_set65.size);
- for (int _i66 = 0; _i66 < _set65.size; ++_i66)
- {
- int _elem67;
- _elem67 = iprot.readI32();
- this.enumSet.add(_elem67);
+ TSet _set69 = iprot.readSetBegin();
+ this.enumSet = new HashSet<Integer>(2*_set69.size);
+ for (int _i70 = 0; _i70 < _set69.size; ++_i70)
+ {
+ int _elem71;
+ _elem71 = iprot.readI32();
+ this.enumSet.add(_elem71);
}
iprot.readSetEnd();
}
@@ -397,15 +397,15 @@
case ENUMMAP:
if (field.type == TType.MAP) {
{
- TMap _map68 = iprot.readMapBegin();
- this.enumMap = new HashMap<Integer,Integer>(2*_map68.size);
- for (int _i69 = 0; _i69 < _map68.size; ++_i69)
- {
- int _key70;
- int _val71;
- _key70 = iprot.readI32();
- _val71 = iprot.readI32();
- this.enumMap.put(_key70, _val71);
+ TMap _map72 = iprot.readMapBegin();
+ this.enumMap = new HashMap<Integer,Integer>(2*_map72.size);
+ for (int _i73 = 0; _i73 < _map72.size; ++_i73)
+ {
+ int _key74;
+ int _val75;
+ _key74 = iprot.readI32();
+ _val75 = iprot.readI32();
+ this.enumMap.put(_key74, _val75);
}
iprot.readMapEnd();
}
@@ -416,13 +416,13 @@
case ENUMLIST:
if (field.type == TType.LIST) {
{
- TList _list72 = iprot.readListBegin();
- this.enumList = new ArrayList<Integer>(_list72.size);
- for (int _i73 = 0; _i73 < _list72.size; ++_i73)
- {
- int _elem74;
- _elem74 = iprot.readI32();
- this.enumList.add(_elem74);
+ TList _list76 = iprot.readListBegin();
+ this.enumList = new ArrayList<Integer>(_list76.size);
+ for (int _i77 = 0; _i77 < _list76.size; ++_i77)
+ {
+ int _elem78;
+ _elem78 = iprot.readI32();
+ this.enumList.add(_elem78);
}
iprot.readListEnd();
}
@@ -452,8 +452,8 @@
oprot.writeFieldBegin(ENUM_SET_FIELD_DESC);
{
oprot.writeSetBegin(new TSet(TType.I32, this.enumSet.size()));
- for (int _iter75 : this.enumSet) {
- oprot.writeI32(_iter75);
+ for (int _iter79 : this.enumSet) {
+ oprot.writeI32(_iter79);
}
oprot.writeSetEnd();
}
@@ -463,9 +463,9 @@
oprot.writeFieldBegin(ENUM_MAP_FIELD_DESC);
{
oprot.writeMapBegin(new TMap(TType.I32, TType.I32,
this.enumMap.size()));
- for (Map.Entry<Integer, Integer> _iter76 :
this.enumMap.entrySet()) {
- oprot.writeI32(_iter76.getKey());
- oprot.writeI32(_iter76.getValue());
+ for (Map.Entry<Integer, Integer> _iter80 :
this.enumMap.entrySet()) {
+ oprot.writeI32(_iter80.getKey());
+ oprot.writeI32(_iter80.getValue());
}
oprot.writeMapEnd();
}
@@ -475,8 +475,8 @@
oprot.writeFieldBegin(ENUM_LIST_FIELD_DESC);
{
oprot.writeListBegin(new TList(TType.I32, this.enumList.size()));
- for (int _iter77 : this.enumList) {
- oprot.writeI32(_iter77);
+ for (int _iter81 : this.enumList) {
+ oprot.writeI32(_iter81);
}
oprot.writeListEnd();
}
=======================================
---
/trunk/gwt-rpc-plus/example/gen-javabean/com/dotspots/rpcplus/example/torturetest/TortureTestApi.java
Wed Apr 28 15:56:15 2010
+++
/trunk/gwt-rpc-plus/example/gen-javabean/com/dotspots/rpcplus/example/torturetest/TortureTestApi.java
Thu Apr 29 14:18:31 2010
@@ -4157,13 +4157,13 @@
case SUCCESS:
if (field.type == TType.SET) {
{
- TSet _set78 = iprot.readSetBegin();
- this.success = new HashSet<String>(2*_set78.size);
- for (int _i79 = 0; _i79 < _set78.size; ++_i79)
- {
- String _elem80;
- _elem80 = iprot.readString();
- this.success.add(_elem80);
+ TSet _set82 = iprot.readSetBegin();
+ this.success = new HashSet<String>(2*_set82.size);
+ for (int _i83 = 0; _i83 < _set82.size; ++_i83)
+ {
+ String _elem84;
+ _elem84 = iprot.readString();
+ this.success.add(_elem84);
}
iprot.readSetEnd();
}
@@ -4189,8 +4189,8 @@
oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
{
oprot.writeSetBegin(new TSet(TType.STRING, this.success.size()));
- for (String _iter81 : this.success) {
- oprot.writeString(_iter81);
+ for (String _iter85 : this.success) {
+ oprot.writeString(_iter85);
}
oprot.writeSetEnd();
}
@@ -4496,13 +4496,13 @@
case SUCCESS:
if (field.type == TType.SET) {
{
- TSet _set82 = iprot.readSetBegin();
- this.success = new HashSet<Integer>(2*_set82.size);
- for (int _i83 = 0; _i83 < _set82.size; ++_i83)
- {
- int _elem84;
- _elem84 = iprot.readI32();
- this.success.add(_elem84);
+ TSet _set86 = iprot.readSetBegin();
+ this.success = new HashSet<Integer>(2*_set86.size);
+ for (int _i87 = 0; _i87 < _set86.size; ++_i87)
+ {
+ int _elem88;
+ _elem88 = iprot.readI32();
+ this.success.add(_elem88);
}
iprot.readSetEnd();
}
@@ -4528,8 +4528,8 @@
oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
{
oprot.writeSetBegin(new TSet(TType.I32, this.success.size()));
- for (int _iter85 : this.success) {
- oprot.writeI32(_iter85);
+ for (int _iter89 : this.success) {
+ oprot.writeI32(_iter89);
}
oprot.writeSetEnd();
}
@@ -4840,15 +4840,15 @@
case SUCCESS:
if (field.type == TType.MAP) {
{
- TMap _map86 = iprot.readMapBegin();
- this.success = new HashMap<String,String>(2*_map86.size);
- for (int _i87 = 0; _i87 < _map86.size; ++_i87)
- {
- String _key88;
- String _val89;
- _key88 = iprot.readString();
- _val89 = iprot.readString();
- this.success.put(_key88, _val89);
+ TMap _map90 = iprot.readMapBegin();
+ this.success = new HashMap<String,String>(2*_map90.size);
+ for (int _i91 = 0; _i91 < _map90.size; ++_i91)
+ {
+ String _key92;
+ String _val93;
+ _key92 = iprot.readString();
+ _val93 = iprot.readString();
+ this.success.put(_key92, _val93);
}
iprot.readMapEnd();
}
@@ -4874,9 +4874,9 @@
oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
{
oprot.writeMapBegin(new TMap(TType.STRING, TType.STRING,
this.success.size()));
- for (Map.Entry<String, String> _iter90 :
this.success.entrySet()) {
- oprot.writeString(_iter90.getKey());
- oprot.writeString(_iter90.getValue());
+ for (Map.Entry<String, String> _iter94 :
this.success.entrySet()) {
+ oprot.writeString(_iter94.getKey());
+ oprot.writeString(_iter94.getValue());
}
oprot.writeMapEnd();
}
=======================================
---
/trunk/gwt-rpc-plus/example/gen-json-server/com/dotspots/rpcplus/example/torturetest/TortureTestApiJson.java
Wed Apr 28 15:56:15 2010
+++
/trunk/gwt-rpc-plus/example/gen-json-server/com/dotspots/rpcplus/example/torturetest/TortureTestApiJson.java
Thu Apr 29 14:18:31 2010
@@ -492,27 +492,27 @@
};
public static final com.dotspots.rpcplus.example.torturetest.ContextIn
readContextIn(TBaseJSONProtocol protocol) throws TException {
- com.dotspots.rpcplus.example.torturetest.ContextIn obj = new
com.dotspots.rpcplus.example.torturetest.ContextIn();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- case 0: {
- String value0 = protocol.readString();
- obj.setToken(value0);
- break;
- }
- case 1: {
- String value0 = protocol.readString();
- obj.setData(value0);
- break;
- }
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+ com.dotspots.rpcplus.example.torturetest.ContextIn obj = new
com.dotspots.rpcplus.example.torturetest.ContextIn();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ case 0: {
+ String value0 = protocol.readString();
+ obj.setToken(value0);
+ break;
+ }
+ case 1: {
+ String value0 = protocol.readString();
+ obj.setData(value0);
+ break;
+ }
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void writeContextIn(TJSONProtocolWriter protocol,
com.dotspots.rpcplus.example.torturetest.ContextIn obj) throws TException {
@@ -535,27 +535,27 @@
}
public static final
com.dotspots.rpcplus.example.torturetest.MoreComplexException
readMoreComplexException(TBaseJSONProtocol protocol) throws TException {
- com.dotspots.rpcplus.example.torturetest.MoreComplexException obj
= new com.dotspots.rpcplus.example.torturetest.MoreComplexException();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- case 0: {
- String value0 = protocol.readString();
- obj.setMessage(value0);
- break;
- }
- case 1: {
-
com.dotspots.rpcplus.example.torturetest.ObjectWithComplexTypes value0 =
readObjectWithComplexTypes(protocol);
- obj.setData(value0);
- break;
- }
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+ com.dotspots.rpcplus.example.torturetest.MoreComplexException obj
= new com.dotspots.rpcplus.example.torturetest.MoreComplexException();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ case 0: {
+ String value0 = protocol.readString();
+ obj.setMessage(value0);
+ break;
+ }
+ case 1: {
+
com.dotspots.rpcplus.example.torturetest.ObjectWithComplexTypes value0 =
readObjectWithComplexTypes(protocol);
+ obj.setData(value0);
+ break;
+ }
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void
writeMoreComplexException(TJSONProtocolWriter protocol,
com.dotspots.rpcplus.example.torturetest.MoreComplexException obj) throws
TException {
@@ -578,22 +578,22 @@
}
public static final
com.dotspots.rpcplus.example.torturetest.ObjectThatIsReferenced
readObjectThatIsReferenced(TBaseJSONProtocol protocol) throws TException {
- com.dotspots.rpcplus.example.torturetest.ObjectThatIsReferenced
obj = new com.dotspots.rpcplus.example.torturetest.ObjectThatIsReferenced();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- case 0: {
- int value0 = protocol.readI32();
- obj.setId(value0);
- break;
- }
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+ com.dotspots.rpcplus.example.torturetest.ObjectThatIsReferenced
obj = new com.dotspots.rpcplus.example.torturetest.ObjectThatIsReferenced();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ case 0: {
+ int value0 = protocol.readI32();
+ obj.setId(value0);
+ break;
+ }
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void
writeObjectThatIsReferenced(TJSONProtocolWriter protocol,
com.dotspots.rpcplus.example.torturetest.ObjectThatIsReferenced obj) throws
TException {
@@ -611,27 +611,27 @@
}
public static final
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsAnUnpositionedException_result
readTortureTestApi_testThrowsAnUnpositionedException_result(TBaseJSONProtocol
protocol) throws TException {
-
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsAnUnpositionedException_result
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsAnUnpositionedException_result();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- case -1: {
-
com.dotspots.rpcplus.example.torturetest.SimpleException value0 =
readSimpleException(protocol);
- obj.setEx(value0);
- break;
- }
- case 0: {
- String value0 = protocol.readString();
- obj.setSuccess(value0);
- break;
- }
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsAnUnpositionedException_result
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsAnUnpositionedException_result();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ case -1: {
+
com.dotspots.rpcplus.example.torturetest.SimpleException value0 =
readSimpleException(protocol);
+ obj.setEx(value0);
+ break;
+ }
+ case 0: {
+ String value0 = protocol.readString();
+ obj.setSuccess(value0);
+ break;
+ }
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void
writeTortureTestApi_testThrowsAnUnpositionedException_result(TJSONProtocolWriter
protocol,
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsAnUnpositionedException_result
obj) throws TException {
@@ -654,22 +654,22 @@
}
public static final
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testExceptionPassthru_args
readTortureTestApi_testExceptionPassthru_args(TBaseJSONProtocol protocol)
throws TException {
-
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testExceptionPassthru_args
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testExceptionPassthru_args();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- case 0: {
-
com.dotspots.rpcplus.example.torturetest.SimpleException value0 =
readSimpleException(protocol);
- obj.setEx(value0);
- break;
- }
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testExceptionPassthru_args
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testExceptionPassthru_args();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ case 0: {
+
com.dotspots.rpcplus.example.torturetest.SimpleException value0 =
readSimpleException(protocol);
+ obj.setEx(value0);
+ break;
+ }
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void
writeTortureTestApi_testExceptionPassthru_args(TJSONProtocolWriter
protocol,
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testExceptionPassthru_args
obj) throws TException {
@@ -687,29 +687,29 @@
}
public static final
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testSetString_result
readTortureTestApi_testSetString_result(TBaseJSONProtocol protocol) throws
TException {
-
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testSetString_result
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testSetString_result();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- case 0: {
- Set<String> value0 = null;
- if (protocol.readSetBegin()) {
- value0 = new HashSet<String>();
- while (protocol.hasNext()) {
- String value1 = protocol.readString();
- value0.add(value1);
- }
- }
- obj.setSuccess(value0);
- break;
- }
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testSetString_result
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testSetString_result();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ case 0: {
+ Set<String> value0 = null;
+ if (protocol.readSetBegin()) {
+ value0 = new HashSet<String>();
+ while (protocol.hasNext()) {
+ String value1 = protocol.readString();
+ value0.add(value1);
+ }
+ }
+ obj.setSuccess(value0);
+ break;
+ }
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void
writeTortureTestApi_testSetString_result(TJSONProtocolWriter protocol,
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testSetString_result
obj) throws TException {
@@ -721,27 +721,31 @@
if (obj.isSetSuccess()) {
protocol.writeI32(0);
Set<String> value0 = obj.getSuccess();
- protocol.writeSetBegin(null);
- for (String value1 : value0) {
- protocol.writeString(value1);
- }
- protocol.writeSetEnd();
+ if (value0 == null) {
+ protocol.writeNull();
+ } else {
+ protocol.writeSetBegin(null);
+ for (String value1 : value0) {
+ protocol.writeString(value1);
+ }
+ protocol.writeSetEnd();
+ }
}
protocol.writeStructEnd();
}
public static final
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testMapStringString_args
readTortureTestApi_testMapStringString_args(TBaseJSONProtocol protocol)
throws TException {
-
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testMapStringString_args
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testMapStringString_args();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testMapStringString_args
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testMapStringString_args();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void
writeTortureTestApi_testMapStringString_args(TJSONProtocolWriter protocol,
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testMapStringString_args
obj) throws TException {
@@ -754,22 +758,22 @@
}
public static final
com.dotspots.rpcplus.example.torturetest.ObjectThatReferencesAnother
readObjectThatReferencesAnother(TBaseJSONProtocol protocol) throws
TException {
-
com.dotspots.rpcplus.example.torturetest.ObjectThatReferencesAnother obj =
new com.dotspots.rpcplus.example.torturetest.ObjectThatReferencesAnother();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- case 0: {
-
com.dotspots.rpcplus.example.torturetest.ObjectThatIsReferenced value0 =
readObjectThatIsReferenced(protocol);
- obj.setReference(value0);
- break;
- }
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+
com.dotspots.rpcplus.example.torturetest.ObjectThatReferencesAnother obj =
new com.dotspots.rpcplus.example.torturetest.ObjectThatReferencesAnother();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ case 0: {
+
com.dotspots.rpcplus.example.torturetest.ObjectThatIsReferenced value0 =
readObjectThatIsReferenced(protocol);
+ obj.setReference(value0);
+ break;
+ }
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void
writeObjectThatReferencesAnother(TJSONProtocolWriter protocol,
com.dotspots.rpcplus.example.torturetest.ObjectThatReferencesAnother obj)
throws TException {
@@ -786,26 +790,26 @@
protocol.writeStructEnd();
}
- public static final
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testExceptionPassthru_result
readTortureTestApi_testExceptionPassthru_result(TBaseJSONProtocol protocol)
throws TException {
-
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testExceptionPassthru_result
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testExceptionPassthru_result();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- case 0: {
-
com.dotspots.rpcplus.example.torturetest.SimpleException value0 =
readSimpleException(protocol);
- obj.setSuccess(value0);
- break;
- }
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+ public static final
com.dotspots.rpcplus.example.torturetest.TortureTestApi.methodReturningAnObject_result
readTortureTestApi_methodReturningAnObject_result(TBaseJSONProtocol
protocol) throws TException {
+
com.dotspots.rpcplus.example.torturetest.TortureTestApi.methodReturningAnObject_result
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.methodReturningAnObject_result();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ case 0: {
+
com.dotspots.rpcplus.example.torturetest.ObjectThatReferencesAnother value0
= readObjectThatReferencesAnother(protocol);
+ obj.setSuccess(value0);
+ break;
+ }
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
- private static final void
writeTortureTestApi_testExceptionPassthru_result(TJSONProtocolWriter
protocol,
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testExceptionPassthru_result
obj) throws TException {
+ private static final void
writeTortureTestApi_methodReturningAnObject_result(TJSONProtocolWriter
protocol,
com.dotspots.rpcplus.example.torturetest.TortureTestApi.methodReturningAnObject_result
obj) throws TException {
if (obj == null) {
protocol.writeNull();
return;
@@ -813,32 +817,32 @@
protocol.writeStructBegin(null);
if (obj.isSetSuccess()) {
protocol.writeI32(0);
- com.dotspots.rpcplus.example.torturetest.SimpleException
value0 = obj.getSuccess();
- writeSimpleException(protocol, value0);
+
com.dotspots.rpcplus.example.torturetest.ObjectThatReferencesAnother value0
= obj.getSuccess();
+ writeObjectThatReferencesAnother(protocol, value0);
}
protocol.writeStructEnd();
}
- public static final
com.dotspots.rpcplus.example.torturetest.TortureTestApi.methodReturningAnObject_result
readTortureTestApi_methodReturningAnObject_result(TBaseJSONProtocol
protocol) throws TException {
-
com.dotspots.rpcplus.example.torturetest.TortureTestApi.methodReturningAnObject_result
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.methodReturningAnObject_result();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- case 0: {
-
com.dotspots.rpcplus.example.torturetest.ObjectThatReferencesAnother value0
= readObjectThatReferencesAnother(protocol);
- obj.setSuccess(value0);
- break;
- }
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+ public static final
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testExceptionPassthru_result
readTortureTestApi_testExceptionPassthru_result(TBaseJSONProtocol protocol)
throws TException {
+
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testExceptionPassthru_result
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testExceptionPassthru_result();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ case 0: {
+
com.dotspots.rpcplus.example.torturetest.SimpleException value0 =
readSimpleException(protocol);
+ obj.setSuccess(value0);
+ break;
+ }
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
- private static final void
writeTortureTestApi_methodReturningAnObject_result(TJSONProtocolWriter
protocol,
com.dotspots.rpcplus.example.torturetest.TortureTestApi.methodReturningAnObject_result
obj) throws TException {
+ private static final void
writeTortureTestApi_testExceptionPassthru_result(TJSONProtocolWriter
protocol,
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testExceptionPassthru_result
obj) throws TException {
if (obj == null) {
protocol.writeNull();
return;
@@ -846,29 +850,29 @@
protocol.writeStructBegin(null);
if (obj.isSetSuccess()) {
protocol.writeI32(0);
-
com.dotspots.rpcplus.example.torturetest.ObjectThatReferencesAnother value0
= obj.getSuccess();
- writeObjectThatReferencesAnother(protocol, value0);
+ com.dotspots.rpcplus.example.torturetest.SimpleException
value0 = obj.getSuccess();
+ writeSimpleException(protocol, value0);
}
protocol.writeStructEnd();
}
public static final
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsTwoExceptions_args
readTortureTestApi_testThrowsTwoExceptions_args(TBaseJSONProtocol protocol)
throws TException {
-
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsTwoExceptions_args
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsTwoExceptions_args();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- case -1: {
- int value0 = protocol.readI32();
- obj.setWhich(value0);
- break;
- }
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsTwoExceptions_args
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsTwoExceptions_args();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ case -1: {
+ int value0 = protocol.readI32();
+ obj.setWhich(value0);
+ break;
+ }
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void
writeTortureTestApi_testThrowsTwoExceptions_args(TJSONProtocolWriter
protocol,
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsTwoExceptions_args
obj) throws TException {
@@ -886,17 +890,17 @@
}
public static final
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsAnUnpositionedException_args
readTortureTestApi_testThrowsAnUnpositionedException_args(TBaseJSONProtocol
protocol) throws TException {
-
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsAnUnpositionedException_args
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsAnUnpositionedException_args();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsAnUnpositionedException_args
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsAnUnpositionedException_args();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void
writeTortureTestApi_testThrowsAnUnpositionedException_args(TJSONProtocolWriter
protocol,
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsAnUnpositionedException_args
obj) throws TException {
@@ -909,22 +913,22 @@
}
public static final
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testPassthru_result
readTortureTestApi_testPassthru_result(TBaseJSONProtocol protocol) throws
TException {
-
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testPassthru_result
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testPassthru_result();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- case 0: {
- String value0 = protocol.readString();
- obj.setSuccess(value0);
- break;
- }
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testPassthru_result
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testPassthru_result();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ case 0: {
+ String value0 = protocol.readString();
+ obj.setSuccess(value0);
+ break;
+ }
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void
writeTortureTestApi_testPassthru_result(TJSONProtocolWriter protocol,
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testPassthru_result
obj) throws TException {
@@ -942,22 +946,22 @@
}
public static final
com.dotspots.rpcplus.example.torturetest.TortureTestApi.methodReturningAnObject5_args
readTortureTestApi_methodReturningAnObject5_args(TBaseJSONProtocol
protocol) throws TException {
-
com.dotspots.rpcplus.example.torturetest.TortureTestApi.methodReturningAnObject5_args
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.methodReturningAnObject5_args();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- case 0: {
-
com.dotspots.rpcplus.example.torturetest.ObjectWithEnum value0 =
readObjectWithEnum(protocol);
- obj.setArg(value0);
- break;
- }
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+
com.dotspots.rpcplus.example.torturetest.TortureTestApi.methodReturningAnObject5_args
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.methodReturningAnObject5_args();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ case 0: {
+
com.dotspots.rpcplus.example.torturetest.ObjectWithEnum value0 =
readObjectWithEnum(protocol);
+ obj.setArg(value0);
+ break;
+ }
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void
writeTortureTestApi_methodReturningAnObject5_args(TJSONProtocolWriter
protocol,
com.dotspots.rpcplus.example.torturetest.TortureTestApi.methodReturningAnObject5_args
obj) throws TException {
@@ -975,17 +979,17 @@
}
public static final
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testSetInt_args
readTortureTestApi_testSetInt_args(TBaseJSONProtocol protocol) throws
TException {
-
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testSetInt_args obj
= new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testSetInt_args();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testSetInt_args obj
= new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testSetInt_args();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void
writeTortureTestApi_testSetInt_args(TJSONProtocolWriter protocol,
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testSetInt_args
obj) throws TException {
@@ -998,27 +1002,27 @@
}
public static final
com.dotspots.rpcplus.example.torturetest.SimpleObjectWithNoFieldIds
readSimpleObjectWithNoFieldIds(TBaseJSONProtocol protocol) throws
TException {
-
com.dotspots.rpcplus.example.torturetest.SimpleObjectWithNoFieldIds obj =
new com.dotspots.rpcplus.example.torturetest.SimpleObjectWithNoFieldIds();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- case -2: {
- int value0 = protocol.readI32();
- obj.setUserId(value0);
- break;
- }
- case -1: {
- String value0 = protocol.readString();
- obj.setToken(value0);
- break;
- }
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+
com.dotspots.rpcplus.example.torturetest.SimpleObjectWithNoFieldIds obj =
new com.dotspots.rpcplus.example.torturetest.SimpleObjectWithNoFieldIds();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ case -2: {
+ int value0 = protocol.readI32();
+ obj.setUserId(value0);
+ break;
+ }
+ case -1: {
+ String value0 = protocol.readString();
+ obj.setToken(value0);
+ break;
+ }
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void
writeSimpleObjectWithNoFieldIds(TJSONProtocolWriter protocol,
com.dotspots.rpcplus.example.torturetest.SimpleObjectWithNoFieldIds obj)
throws TException {
@@ -1041,17 +1045,17 @@
}
public static final
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsAnException_args
readTortureTestApi_testThrowsAnException_args(TBaseJSONProtocol protocol)
throws TException {
-
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsAnException_args
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsAnException_args();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsAnException_args
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsAnException_args();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void
writeTortureTestApi_testThrowsAnException_args(TJSONProtocolWriter
protocol,
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testThrowsAnException_args
obj) throws TException {
@@ -1064,30 +1068,30 @@
}
public static final
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testMapStringString_result
readTortureTestApi_testMapStringString_result(TBaseJSONProtocol protocol)
throws TException {
-
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testMapStringString_result
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testMapStringString_result();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- case 0: {
- Map<String, String> value0 = null;
- if (protocol.readMapBegin()) {
- value0 = new HashMap<String, String>();
- while (protocol.hasNext()) {
- String key1 = protocol.readString();
- String value1 = protocol.readString();
- value0.put(key1, value1);
- }
- }
- obj.setSuccess(value0);
- break;
- }
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testMapStringString_result
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testMapStringString_result();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ case 0: {
+ Map<String, String> value0 = null;
+ if (protocol.readMapBegin()) {
+ value0 = new HashMap<String, String>();
+ while (protocol.hasNext()) {
+ String key1 = protocol.readString();
+ String value1 = protocol.readString();
+ value0.put(key1, value1);
+ }
+ }
+ obj.setSuccess(value0);
+ break;
+ }
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void
writeTortureTestApi_testMapStringString_result(TJSONProtocolWriter
protocol,
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testMapStringString_result
obj) throws TException {
@@ -1099,40 +1103,44 @@
if (obj.isSetSuccess()) {
protocol.writeI32(0);
Map<String, String> value0 = obj.getSuccess();
- protocol.writeMapBegin(null);
- for (Map.Entry<String, String> entry0 : value0.entrySet()) {
- String key1 = entry0.getKey();
- String value1 = entry0.getValue();
- protocol.writeString(key1);
- protocol.writeString(value1);
- }
- protocol.writeMapEnd();
+ if (value0 == null) {
+ protocol.writeNull();
+ } else {
+ protocol.writeMapBegin(null);
+ for (Map.Entry<String, String> entry0 : value0.entrySet())
{
+ String key1 = entry0.getKey();
+ String value1 = entry0.getValue();
+ protocol.writeString(key1);
+ protocol.writeString(value1);
+ }
+ protocol.writeMapEnd();
+ }
}
protocol.writeStructEnd();
}
public static final
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testPositionalArguments_args
readTortureTestApi_testPositionalArguments_args(TBaseJSONProtocol protocol)
throws TException {
-
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testPositionalArguments_args
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testPositionalArguments_args();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- case 0: {
- int value0 = protocol.readI32();
- obj.setInt32(value0);
- break;
- }
- case 1: {
- String value0 = protocol.readString();
- obj.setStr(value0);
- break;
- }
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testPositionalArguments_args
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testPositionalArguments_args();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ case 0: {
+ int value0 = protocol.readI32();
+ obj.setInt32(value0);
+ break;
+ }
+ case 1: {
+ String value0 = protocol.readString();
+ obj.setStr(value0);
+ break;
+ }
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void
writeTortureTestApi_testPositionalArguments_args(TJSONProtocolWriter
protocol,
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testPositionalArguments_args
obj) throws TException {
@@ -1155,22 +1163,22 @@
}
public static final
com.dotspots.rpcplus.example.torturetest.SimpleException
readSimpleException(TBaseJSONProtocol protocol) throws TException {
- com.dotspots.rpcplus.example.torturetest.SimpleException obj =
new com.dotspots.rpcplus.example.torturetest.SimpleException();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- case 0: {
- String value0 = protocol.readString();
- obj.setMessage(value0);
- break;
- }
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+ com.dotspots.rpcplus.example.torturetest.SimpleException obj = new
com.dotspots.rpcplus.example.torturetest.SimpleException();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ case 0: {
+ String value0 = protocol.readString();
+ obj.setMessage(value0);
+ break;
+ }
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void writeSimpleException(TJSONProtocolWriter
protocol, com.dotspots.rpcplus.example.torturetest.SimpleException obj)
throws TException {
@@ -1188,27 +1196,27 @@
}
public static final
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testDeclaresAnException_result
readTortureTestApi_testDeclaresAnException_result(TBaseJSONProtocol
protocol) throws TException {
-
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testDeclaresAnException_result
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testDeclaresAnException_result();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- case 0: {
- String value0 = protocol.readString();
- obj.setSuccess(value0);
- break;
- }
- case 1: {
-
com.dotspots.rpcplus.example.torturetest.SimpleException value0 =
readSimpleException(protocol);
- obj.setEx(value0);
- break;
- }
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testDeclaresAnException_result
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testDeclaresAnException_result();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ case 0: {
+ String value0 = protocol.readString();
+ obj.setSuccess(value0);
+ break;
+ }
+ case 1: {
+
com.dotspots.rpcplus.example.torturetest.SimpleException value0 =
readSimpleException(protocol);
+ obj.setEx(value0);
+ break;
+ }
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void
writeTortureTestApi_testDeclaresAnException_result(TJSONProtocolWriter
protocol,
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testDeclaresAnException_result
obj) throws TException {
@@ -1231,22 +1239,22 @@
}
public static final
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testBinary_args
readTortureTestApi_testBinary_args(TBaseJSONProtocol protocol) throws
TException {
-
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testBinary_args obj
= new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testBinary_args();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- case 0: {
- byte[] value0 = protocol.readBinary();
- obj.setBinaryValue(value0);
- break;
- }
- default:
- protocol.skip();
- }
- }
- }
- return obj;
+
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testBinary_args obj
= new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testBinary_args();
+ if (protocol.readStructBegin()) {
+ int fieldId;
+ while(protocol.hasNext()) {
+ switch (protocol.readI32()) {
+ case 0: {
+ byte[] value0 = protocol.readBinary();
+ obj.setBinaryValue(value0);
+ break;
+ }
+ default:
+ protocol.skip();
+ }
+ }
+ }
+ return obj;
}
private static final void
writeTortureTestApi_testBinary_args(TJSONProtocolWriter protocol,
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testBinary_args
obj) throws TException {
@@ -1264,22 +1272,22 @@
}
public static final
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testPositionalArguments_result
readTortureTestApi_testPositionalArguments_result(TBaseJSONProtocol
protocol) throws TException {
-
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testPositionalArguments_result
obj = new
com.dotspots.rpcplus.example.torturetest.TortureTestApi.testPositionalArguments_result();
- if (protocol.readStructBegin()) {
- int fieldId;
- while(protocol.hasNext()) {
- switch (protocol.readI32()) {
- case 0: {
- String value0 = protocol.readString();
- obj.setSuccess(value0);
- break;
- }
- default:
- protocol.skip();
- }
- }
***The diff for this file has been truncated for email.***
=======================================
---
/trunk/gwt-rpc-plus/example/server-example/com/dotspots/rpcplus/example/jsonrpc/thrift/ExampleService.java
Wed Apr 28 15:56:15 2010
+++
/trunk/gwt-rpc-plus/example/server-example/com/dotspots/rpcplus/example/jsonrpc/thrift/ExampleService.java
Thu Apr 29 14:18:31 2010
@@ -121,7 +121,7 @@
set.add("hi" + i);
}
- throw new MoreComplexException("Message!", new
ObjectWithComplexTypes(null, set, null, null, null, null, null, null,
null));
+ throw new MoreComplexException("Message!", new
ObjectWithComplexTypes(null, set, null, null, null, null, null, null, null,
null));
}
public ContextOut __getContext() throws TException {
=======================================
--- /trunk/gwt-rpc-plus/example/torturetest.thrift Wed Apr 28 15:56:15 2010
+++ /trunk/gwt-rpc-plus/example/torturetest.thrift Thu Apr 29 14:18:31 2010
@@ -20,6 +20,7 @@
7: list<map<string, i32>> listOfMapStringToI32;
8: map<string, map<i32, i32>> mapOfMapI32ToI32;
9: map<string, map<string, string>> mapOfMapStringToString;
+ 10: list<SimpleObjectWithFieldIds> listOfObjects;
}
struct ObjectThatIsReferenced {
=======================================
---
/trunk/gwt-rpc-plus/test/server-test/com/dotspots/rpcplus/test/server/TestJSONNativeProtocol.java
Mon Oct 26 20:52:25 2009
+++
/trunk/gwt-rpc-plus/test/server-test/com/dotspots/rpcplus/test/server/TestJSONNativeProtocol.java
Thu Apr 29 14:18:31 2010
@@ -3,6 +3,7 @@
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -72,6 +73,28 @@
roundTrip("{\"0\":{\"_c\":null,\"_a\":null},\"2\":[null,null]}", obj);
}
+
+ @Test
+ public void testObjectWithComplexTypesNull2() throws Exception {
+ ObjectWithComplexTypes obj = new ObjectWithComplexTypes();
+
+ List<Map<String, String>> list = new ArrayList<Map<String, String>>();
+ list.add(null);
+ obj.setListOfMapStringToString(list);
+
+ roundTrip("{\"4\":[null]}", obj);
+ }
+
+ @Test
+ public void testObjectWithComplexTypesNull3() throws Exception {
+ ObjectWithComplexTypes obj = new ObjectWithComplexTypes();
+
+ List<SimpleObjectWithFieldIds> list = new
ArrayList<SimpleObjectWithFieldIds>();
+ list.add(null);
+ obj.setListOfObjects(list);
+
+ roundTrip("{\"9\":[null]}", obj);
+ }
@Test
public void testObjectWithComplexTypesEmpty() throws Exception {