in activemq-cpp-openwire-generator/src/main/java/org/apache/activemq/openwire/tool/marshallers/AmqCppMarshallingClassesGenerator.java [490:564]
protected void generateLooseMarshalBody(PrintWriter out) {
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 = " ";
if( version.asInt() > 1 ) {
indent = indent + " ";
out.println(" if (wireVersion >= " + version.asInt() + ") {");
}
if( type.equals( "boolean" ) ) {
out.println(indent + "dataOut->writeBoolean(" + getter + ");");
}
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 + "looseMarshalLong(wireFormat, " + getter + ", dataOut);");
}
else if( type.equals("String") ) {
out.println(indent + "looseMarshalString(" + getter + ", dataOut);");
}
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 + "dataOut->write( " + getter + ".size() != 0 );");
out.println(indent + "if( " + getter + ".size() != 0 ) {");
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 + "looseMarshalObjectArrayConstSize(wireFormat, " + getter + ", dataOut, " + size.asInt() + ");");
}
else {
out.println(indent + "looseMarshalObjectArray(wireFormat, " + getter + ", dataOut);");
}
}
else if( isThrowable( propertyType ) ) {
out.println(indent + "looseMarshalBrokerError(wireFormat, " + getter + ".get(), dataOut);");
}
else {
if( isCachedProperty( property ) ) {
out.println(indent + "looseMarshalCachedObject(wireFormat, "+getter+".get(), dataOut);");
}
else {
out.println(indent + "looseMarshalNestedObject(wireFormat, "+getter+".get(), dataOut);");
}
}
if( version.asInt() > 1 ) {
out.println(" }");
}
}
}