List properties = getProperties();
for (Iterator iter = properties.iterator(); iter.hasNext();) {
JProperty property = (JProperty) iter.next();
JAnnotation annotation = property.getAnnotation("openwire:property");
JAnnotationValue size = annotation.getValue("size");
JClass propertyType = property.getType();
String type = propertyType.getSimpleName();
String getter = "info->" + property.getGetter().getSimpleName() + "()";
if( type.equals( "boolean" ) ) {
out.println(" dataOut->writeBoolean( " + getter + " );");
}
else if( type.equals("byte") ) {
out.println(" dataOut->write( " + getter + " );");
}
else if( type.equals("char") ) {
out.println(" dataOut->write( " + getter + " );");
}
else if( type.equals("short") ) {
out.println(" dataOut->writeShort( " + getter + " );");
}
else if( type.equals("int")) {
out.println(" dataOut->writeInt( " + getter + " );");
}
else if( type.equals("long") ) {
out.println(" looseMarshalLong( wireFormat, " + getter + ", dataOut );");
}
else if( type.equals("String") ) {
out.println(" looseMarshalString( " + getter + ", dataOut );");
}
else if( type.equals("byte[]") || type.equals("ByteSequence") ) {
if(size != null) {
out.println(" dataOut->write( (const unsigned char*)(&" + getter + "[0]), (int)" + size.asInt() + " );");
}
else {
out.println(" dataOut->write( " + getter + ".size() != 0 );");
out.println(" if( " + getter + ".size() != 0 ) {");
out.println(" dataOut->writeInt( (int)" + getter + ".size() );");
out.println(" dataOut->write( (const unsigned char*)(&" + getter + "[0]), (int)" + getter + ".size() );");
out.println(" }");
}
}
else if( propertyType.isArrayType() ) {
if (size != null) {
out.println(" looseMarshalObjectArrayConstSize( wireFormat, " + getter + ", dataOut, " + size.asInt() + " );");
}
else {
out.println(" looseMarshalObjectArray( wireFormat, " + getter + ", dataOut );");