@@ -159,8 +159,8 @@ def printHeader():
159159 print "import com.rabbitmq.client.impl.ContentHeaderPropertyReader;"
160160 print "import com.rabbitmq.client.impl.LongString;"
161161 print "import com.rabbitmq.client.impl.LongStringHelper;"
162- print
163- print "public interface AMQP {"
162+
163+ def printProtocolClass ():
164164 print
165165 print " public static class PROTOCOL {"
166166 print " public static final int MAJOR = %i;" % spec .major
@@ -234,7 +234,7 @@ def printClassInterfaces():
234234 print " }"
235235 print " }"
236236
237- def printReadProperties (c ):
237+ def printReadPropertiesFrom (c ):
238238 print
239239 print """ public void readPropertiesFrom(ContentHeaderPropertyReader reader)
240240 throws IOException
@@ -246,7 +246,7 @@ def printReadProperties(c):
246246 print " this.%s = %s_present ? reader.read%s() : null;" % (java_field_name (f .name ), java_field_name (f .name ), java_class_name (f .domain ))
247247 print " }"
248248
249- def printWriteProperties (c ):
249+ def printWritePropertiesTo (c ):
250250 print
251251 print """ public void writePropertiesTo(ContentHeaderPropertyWriter writer)
252252 throws IOException
@@ -258,7 +258,7 @@ def printWriteProperties(c):
258258 print " if (this.%s != null) { writer.write%s(this.%s); }" % (java_field_name (f .name ), java_class_name (f .domain ), java_field_name (f .name ))
259259 print " }"
260260
261- def printPropertyDebug (c ):
261+ def printAppendArgumentDebugStringTo (c ):
262262 appendList = [ "%s=\" )\n .append(this.%s)\n .append(\" "
263263 % (f .name , java_field_name (f .name ))
264264 for f in c .fields ]
@@ -267,14 +267,14 @@ def printPropertyDebug(c):
267267 print " acc.append(\" (%s)\" );" % ", " .join (appendList )
268268 print " }"
269269
270- def printClassProperties (c ):
270+ def printPropertiesClass (c ):
271271 print
272272 print " public static class %(className)s extends %(parentClass)s {" % {'className' : java_class_name (c .name ) + 'Properties' , 'parentClass' : 'com.rabbitmq.client.impl.AMQ' + java_class_name (c .name ) + 'Properties' }
273273 #property fields
274274 for f in c .fields :
275275 print " private %s %s;" % (java_property_type (spec , f .domain ),java_field_name (f .name ))
276276
277- #constructor
277+ #explicit constructor
278278 if c .fields :
279279 print
280280 consParmList = [ "%s %s" % (java_property_type (spec ,f .domain ),java_field_name (f .name ))
@@ -286,13 +286,15 @@ def printClassProperties(c):
286286 print " this.%s = %s;" % (java_field_name (f .name ), java_field_name (f .name ))
287287 print " }"
288288
289- #empty constructor
289+ #default constructor
290290 print
291291 print " public %sProperties() {}" % (java_class_name (c .name ))
292+
293+ #class properties
292294 print " public int getClassId() { return %i; }" % (c .index )
293295 print " public String getClassName() { return \" %s\" ; }" % (c .name )
294296
295- #access functions
297+ #accessor methods
296298 print
297299 for f in c .fields :
298300 print """ public %(fieldType)s get%(capFieldName)s() { return %(fieldName)s; }
@@ -301,18 +303,24 @@ def printClassProperties(c):
301303 'capFieldName' : (java_field_name (f .name )[0 ].upper () + java_field_name (f .name )[1 :]), \
302304 'fieldName' : java_field_name (f .name )}
303305
304- printReadProperties (c )
305- printWriteProperties (c )
306- printPropertyDebug (c )
306+ printReadPropertiesFrom (c )
307+ printWritePropertiesTo (c )
308+ printAppendArgumentDebugStringTo (c )
307309 print " }"
308310
311+ def printPropertiesClasses ():
312+ for c in spec .classes :
313+ if c .hasContentProperties :
314+ printPropertiesClass (c )
315+
309316 printHeader ()
317+ print
318+ print "public interface AMQP {"
319+
320+ printProtocolClass ()
310321 printConstants ()
311322 printClassInterfaces ()
312-
313- for c in spec .classes :
314- if c .hasContentProperties :
315- printClassProperties (c )
323+ printPropertiesClasses ()
316324
317325 print "}"
318326
@@ -330,8 +338,6 @@ def printHeader():
330338 print "import com.rabbitmq.client.AMQP;"
331339 print "import com.rabbitmq.client.UnknownClassOrMethodId;"
332340 print "import com.rabbitmq.client.UnexpectedMethodError;"
333- print
334- print "public class AMQImpl implements AMQP {"
335341
336342 def printClassMethods (spec , c ):
337343 print
@@ -452,13 +458,13 @@ def printMethodArgumentReader():
452458 print " return new %s(new MethodArgumentReader(in));" % (fq_name )
453459 print " }"
454460 print " default: break;"
455- print " }"
461+ print " } break; "
456462 print " }"
457463 print
458464 print " throw new UnknownClassOrMethodId(classId, methodId);"
459465 print " }"
460466
461- def printContentHeaderReader (c ):
467+ def printContentHeaderReader ():
462468 print
463469 print " public static AMQContentHeader readContentHeaderFrom(DataInputStream in) throws IOException {"
464470 print " int classId = in.readShort();"
@@ -473,10 +479,15 @@ def printContentHeaderReader(c):
473479 print " }"
474480
475481 printHeader ()
482+ print
483+ print "public class AMQImpl implements AMQP {"
484+
476485 for c in spec .allClasses (): printClassMethods (spec ,c )
486+
477487 printMethodVisitor ()
478488 printMethodArgumentReader ()
479- printContentHeaderReader (c )
489+ printContentHeaderReader ()
490+
480491 print "}"
481492
482493#--------------------------------------------------------------------------------
0 commit comments