in activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/marshallers/AmqCppMarshallingClassesGenerator.java [302:376]
protected void generateTightMarshal2Body(PrintWriter out) {
int count = 0;
for ( JProperty property : getProperties() ) {
JAnnotation annotation = property.getAnnotation("openwire:property");
JAnnotationValue version = annotation.getValue("version");
JAnnotationValue size = annotation.getValue("size");
JClass propertyType = property.getType();
String type = propertyType.getSimpleName();
String getter = "info->" + property.getGetter().getSimpleName() + "()";
String indent = " ";
count++;
if( version.asInt() > 1 ) {
indent = indent + " ";
out.println(" if (wireVersion >= " + version.asInt() + ") {");
}
if (type.equals("boolean")) {
out.println(indent + "bs->readBoolean();");
}
else if (type.equals("byte")) {
out.println(indent + "dataOut->write(" + getter + ");");
}
else if (type.equals("char")) {
out.println(indent + "dataOut->write(" + getter + ");");
}
else if (type.equals("short")) {
out.println(indent + "dataOut->writeShort(" + getter + ");");
}
else if (type.equals("int")) {
out.println(indent + "dataOut->writeInt(" + getter + ");");
}
else if (type.equals("long")) {
out.println(indent + "tightMarshalLong2(wireFormat, " + getter + ", dataOut, bs);");
}
else if (type.equals("String")) {
out.println(indent + "tightMarshalString2(" + getter + ", dataOut, bs);");
}
else if (type.equals("byte[]") || type.equals("ByteSequence")) {
if (size != null) {
out.println(indent + "dataOut->write((const unsigned char*)(&" + getter + "[0]), " + size.asInt() + ", 0, " + size.asInt() + ");");
}
else {
out.println(indent + "if (bs->readBoolean()) {");
out.println(indent + " dataOut->writeInt((int)" + getter + ".size() );");
out.println(indent + " dataOut->write((const unsigned char*)(&" + getter + "[0]), (int)" + getter + ".size(), 0, (int)" + getter + ".size());");
out.println(indent + "}");
}
}
else if (propertyType.isArrayType()) {
if (size != null) {
out.println(indent + "tightMarshalObjectArrayConstSize2(wireFormat, " + getter + ", dataOut, bs, " + size.asInt() + ");");
}
else {
out.println(indent + "tightMarshalObjectArray2(wireFormat, " + getter + ", dataOut, bs);");
}
} else if( isThrowable(propertyType) ) {
out.println(indent + "tightMarshalBrokerError2(wireFormat, " + getter + ".get(), dataOut, bs);");
} else {
if( isCachedProperty(property) ) {
out.println(indent + "tightMarshalCachedObject2(wireFormat, "+getter+".get(), dataOut, bs);");
}
else {
out.println(indent + "tightMarshalNestedObject2(wireFormat, "+getter+".get(), dataOut, bs);");
}
}
if( version.asInt() > 1 ) {
out.println(" }");
}
}
}