1 /** 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.activemq.openwire.tool; 18 19 import java.io.File; 20 import java.io.PrintWriter; 21 import java.util.ArrayList; 22 import java.util.Collections; 23 import java.util.Comparator; 24 import java.util.Iterator; 25 import java.util.List; 26 27 import org.codehaus.jam.JAnnotation; 28 import org.codehaus.jam.JAnnotationValue; 29 import org.codehaus.jam.JClass; 30 import org.codehaus.jam.JProperty; 31 32 /** 33 * @version $Revision: 384390 $ 34 */ 35 public class CSharpMarshallingGenerator extends JavaMarshallingGenerator { 36 37 protected String targetDir = "./src/main/csharp"; 38 39 public Object run() { 40 filePostFix = ".cs"; 41 if (destDir == null) { 42 destDir = new File(targetDir + "/ActiveMQ/OpenWire/V" + getOpenwireVersion()); 43 } 44 return super.run(); 45 } 46 47 // //////////////////////////////////////////////////////////////////////////////////// 48 // This section is for the tight wire format encoding generator 49 // //////////////////////////////////////////////////////////////////////////////////// 50 51 protected void generateTightUnmarshalBodyForProperty(PrintWriter out, JProperty property, JAnnotationValue size) { 52 53 String propertyName = property.getSimpleName(); 54 String type = property.getType().getSimpleName(); 55 56 if (type.equals("boolean")) { 57 out.println(" info." + propertyName + " = bs.ReadBoolean();"); 58 } else if (type.equals("byte")) { 59 out.println(" info." + propertyName + " = dataIn.ReadByte();"); 60 } else if (type.equals("char")) { 61 out.println(" info." + propertyName + " = dataIn.ReadChar();"); 62 } else if (type.equals("short")) { 63 out.println(" info." + propertyName + " = dataIn.ReadInt16();"); 64 } else if (type.equals("int")) { 65 out.println(" info." + propertyName + " = dataIn.ReadInt32();"); 66 } else if (type.equals("long")) { 67 out.println(" info." + propertyName + " = TightUnmarshalLong(wireFormat, dataIn, bs);"); 68 } else if (type.equals("String")) { 69 out.println(" info." + propertyName + " = TightUnmarshalString(dataIn, bs);"); 70 } else if (type.equals("byte[]") || type.equals("ByteSequence")) { 71 if (size != null) { 72 out.println(" info." + propertyName + " = ReadBytes(dataIn, " + size.asInt() + ");"); 73 } else { 74 out.println(" info." + propertyName + " = ReadBytes(dataIn, bs.ReadBoolean());"); 75 } 76 } else if (isThrowable(property.getType())) { 77 out.println(" info." + propertyName + " = TightUnmarshalBrokerError(wireFormat, dataIn, bs);"); 78 } else if (isCachedProperty(property)) { 79 out.println(" info." + propertyName + " = (" + type + ") TightUnmarshalCachedObject(wireFormat, dataIn, bs);"); 80 } else { 81 out.println(" info." + propertyName + " = (" + type + ") TightUnmarshalNestedObject(wireFormat, dataIn, bs);"); 82 } 83 } 84 85 protected void generateTightUnmarshalBodyForArrayProperty(PrintWriter out, JProperty property, JAnnotationValue size) { 86 JClass propertyType = property.getType(); 87 String arrayType = propertyType.getArrayComponentType().getSimpleName(); 88 String propertyName = property.getSimpleName(); 89 out.println(); 90 if (size != null) { 91 out.println(" {"); 92 out.println(" " + arrayType + "[] value = new " + arrayType + "[" + size.asInt() + "];"); 93 out.println(" " + "for( int i=0; i < " + size.asInt() + "; i++ ) {"); 94 out.println(" value[i] = (" + arrayType + ") TightUnmarshalNestedObject(wireFormat,dataIn, bs);"); 95 out.println(" }"); 96 out.println(" info." + propertyName + " = value;"); 97 out.println(" }"); 98 } else { 99 out.println(" if (bs.ReadBoolean()) {"); 100 out.println(" short size = dataIn.ReadInt16();"); 101 out.println(" " + arrayType + "[] value = new " + arrayType + "[size];"); 102 out.println(" for( int i=0; i < size; i++ ) {"); 103 out.println(" value[i] = (" + arrayType + ") TightUnmarshalNestedObject(wireFormat,dataIn, bs);"); 104 out.println(" }"); 105 out.println(" info." + propertyName + " = value;"); 106 out.println(" }"); 107 out.println(" else {"); 108 out.println(" info." + propertyName + " = null;"); 109 out.println(" }"); 110 } 111 } 112 113 protected int generateTightMarshal1Body(PrintWriter out) { 114 List properties = getProperties(); 115 int baseSize = 0; 116 for (Iterator iter = properties.iterator(); iter.hasNext();) { 117 JProperty property = (JProperty)iter.next(); 118 JAnnotation annotation = property.getAnnotation("openwire:property"); 119 JAnnotationValue size = annotation.getValue("size"); 120 JClass propertyType = property.getType(); 121 String type = propertyType.getSimpleName(); 122 String getter = "info." + property.getSimpleName(); 123 124 if (type.equals("boolean")) { 125 out.println(" bs.WriteBoolean(" + getter + ");"); 126 } else if (type.equals("byte")) { 127 baseSize += 1; 128 } else if (type.equals("char")) { 129 baseSize += 2; 130 } else if (type.equals("short")) { 131 baseSize += 2; 132 } else if (type.equals("int")) { 133 baseSize += 4; 134 } else if (type.equals("long")) { 135 out.println(" rc += TightMarshalLong1(wireFormat, " + getter + ", bs);"); 136 } else if (type.equals("String")) { 137 out.print(""); 138 out.println(" rc += TightMarshalString1(" + getter + ", bs);"); 139 } else if (type.equals("byte[]") || type.equals("ByteSequence")) { 140 if (size == null) { 141 out.println(" bs.WriteBoolean(" + getter + "!=null);"); 142 out.println(" rc += " + getter + "==null ? 0 : " + getter + ".Length+4;"); 143 } else { 144 baseSize += size.asInt(); 145 } 146 } else if (propertyType.isArrayType()) { 147 if (size != null) { 148 out.println(" rc += TightMarshalObjectArrayConstSize1(wireFormat, " + getter + ", bs, " + size.asInt() + ");"); 149 } else { 150 out.println(" rc += TightMarshalObjectArray1(wireFormat, " + getter + ", bs);"); 151 } 152 } else if (isThrowable(propertyType)) { 153 out.println(" rc += TightMarshalBrokerError1(wireFormat, " + getter + ", bs);"); 154 } else { 155 if (isCachedProperty(property)) { 156 out.println(" rc += TightMarshalCachedObject1(wireFormat, (DataStructure)" + getter + ", bs);"); 157 } else { 158 out.println(" rc += TightMarshalNestedObject1(wireFormat, (DataStructure)" + getter + ", bs);"); 159 } 160 } 161 } 162 return baseSize; 163 } 164 165 protected void generateTightMarshal2Body(PrintWriter out) { 166 List properties = getProperties(); 167 for (Iterator iter = properties.iterator(); iter.hasNext();) { 168 JProperty property = (JProperty)iter.next(); 169 JAnnotation annotation = property.getAnnotation("openwire:property"); 170 JAnnotationValue size = annotation.getValue("size"); 171 JClass propertyType = property.getType(); 172 String type = propertyType.getSimpleName(); 173 String getter = "info." + property.getSimpleName(); 174 175 if (type.equals("boolean")) { 176 out.println(" bs.ReadBoolean();"); 177 } else if (type.equals("byte")) { 178 out.println(" dataOut.Write(" + getter + ");"); 179 } else if (type.equals("char")) { 180 out.println(" dataOut.Write(" + getter + ");"); 181 } else if (type.equals("short")) { 182 out.println(" dataOut.Write(" + getter + ");"); 183 } else if (type.equals("int")) { 184 out.println(" dataOut.Write(" + getter + ");"); 185 } else if (type.equals("long")) { 186 out.println(" TightMarshalLong2(wireFormat, " + getter + ", dataOut, bs);"); 187 } else if (type.equals("String")) { 188 out.println(" TightMarshalString2(" + getter + ", dataOut, bs);"); 189 } else if (type.equals("byte[]") || type.equals("ByteSequence")) { 190 if (size != null) { 191 out.println(" dataOut.Write(" + getter + ", 0, " + size.asInt() + ");"); 192 } else { 193 out.println(" if(bs.ReadBoolean()) {"); 194 out.println(" dataOut.Write(" + getter + ".Length);"); 195 out.println(" dataOut.Write(" + getter + ");"); 196 out.println(" }"); 197 } 198 } else if (propertyType.isArrayType()) { 199 if (size != null) { 200 out.println(" TightMarshalObjectArrayConstSize2(wireFormat, " + getter + ", dataOut, bs, " + size.asInt() + ");"); 201 } else { 202 out.println(" TightMarshalObjectArray2(wireFormat, " + getter + ", dataOut, bs);"); 203 } 204 } else if (isThrowable(propertyType)) { 205 out.println(" TightMarshalBrokerError2(wireFormat, " + getter + ", dataOut, bs);"); 206 } else { 207 if (isCachedProperty(property)) { 208 out.println(" TightMarshalCachedObject2(wireFormat, (DataStructure)" + getter + ", dataOut, bs);"); 209 } else { 210 out.println(" TightMarshalNestedObject2(wireFormat, (DataStructure)" + getter + ", dataOut, bs);"); 211 } 212 } 213 } 214 } 215 216 // //////////////////////////////////////////////////////////////////////////////////// 217 // This section is for the loose wire format encoding generator 218 // //////////////////////////////////////////////////////////////////////////////////// 219 220 protected void generateLooseUnmarshalBodyForProperty(PrintWriter out, JProperty property, JAnnotationValue size) { 221 222 String propertyName = property.getSimpleName(); 223 String type = property.getType().getSimpleName(); 224 225 if (type.equals("boolean")) { 226 out.println(" info." + propertyName + " = dataIn.ReadBoolean();"); 227 } else if (type.equals("byte")) { 228 out.println(" info." + propertyName + " = dataIn.ReadByte();"); 229 } else if (type.equals("char")) { 230 out.println(" info." + propertyName + " = dataIn.ReadChar();"); 231 } else if (type.equals("short")) { 232 out.println(" info." + propertyName + " = dataIn.ReadInt16();"); 233 } else if (type.equals("int")) { 234 out.println(" info." + propertyName + " = dataIn.ReadInt32();"); 235 } else if (type.equals("long")) { 236 out.println(" info." + propertyName + " = LooseUnmarshalLong(wireFormat, dataIn);"); 237 } else if (type.equals("String")) { 238 out.println(" info." + propertyName + " = LooseUnmarshalString(dataIn);"); 239 } else if (type.equals("byte[]") || type.equals("ByteSequence")) { 240 if (size != null) { 241 out.println(" info." + propertyName + " = ReadBytes(dataIn, " + size.asInt() + ");"); 242 } else { 243 out.println(" info." + propertyName + " = ReadBytes(dataIn, dataIn.ReadBoolean());"); 244 } 245 } else if (isThrowable(property.getType())) { 246 out.println(" info." + propertyName + " = LooseUnmarshalBrokerError(wireFormat, dataIn);"); 247 } else if (isCachedProperty(property)) { 248 out.println(" info." + propertyName + " = (" + type + ") LooseUnmarshalCachedObject(wireFormat, dataIn);"); 249 } else { 250 out.println(" info." + propertyName + " = (" + type + ") LooseUnmarshalNestedObject(wireFormat, dataIn);"); 251 } 252 } 253 254 protected void generateLooseUnmarshalBodyForArrayProperty(PrintWriter out, JProperty property, JAnnotationValue size) { 255 JClass propertyType = property.getType(); 256 String arrayType = propertyType.getArrayComponentType().getSimpleName(); 257 String propertyName = property.getSimpleName(); 258 out.println(); 259 if (size != null) { 260 out.println(" {"); 261 out.println(" " + arrayType + "[] value = new " + arrayType + "[" + size.asInt() + "];"); 262 out.println(" " + "for( int i=0; i < " + size.asInt() + "; i++ ) {"); 263 out.println(" value[i] = (" + arrayType + ") LooseUnmarshalNestedObject(wireFormat,dataIn);"); 264 out.println(" }"); 265 out.println(" info." + propertyName + " = value;"); 266 out.println(" }"); 267 } else { 268 out.println(" if (dataIn.ReadBoolean()) {"); 269 out.println(" short size = dataIn.ReadInt16();"); 270 out.println(" " + arrayType + "[] value = new " + arrayType + "[size];"); 271 out.println(" for( int i=0; i < size; i++ ) {"); 272 out.println(" value[i] = (" + arrayType + ") LooseUnmarshalNestedObject(wireFormat,dataIn);"); 273 out.println(" }"); 274 out.println(" info." + propertyName + " = value;"); 275 out.println(" }"); 276 out.println(" else {"); 277 out.println(" info." + propertyName + " = null;"); 278 out.println(" }"); 279 } 280 } 281 282 protected void generateLooseMarshalBody(PrintWriter out) { 283 List properties = getProperties(); 284 for (Iterator iter = properties.iterator(); iter.hasNext();) { 285 JProperty property = (JProperty)iter.next(); 286 JAnnotation annotation = property.getAnnotation("openwire:property"); 287 JAnnotationValue size = annotation.getValue("size"); 288 JClass propertyType = property.getType(); 289 String type = propertyType.getSimpleName(); 290 String getter = "info." + property.getSimpleName(); 291 292 if (type.equals("boolean")) { 293 out.println(" dataOut.Write(" + getter + ");"); 294 } else if (type.equals("byte")) { 295 out.println(" dataOut.Write(" + getter + ");"); 296 } else if (type.equals("char")) { 297 out.println(" dataOut.Write(" + getter + ");"); 298 } else if (type.equals("short")) { 299 out.println(" dataOut.Write(" + getter + ");"); 300 } else if (type.equals("int")) { 301 out.println(" dataOut.Write(" + getter + ");"); 302 } else if (type.equals("long")) { 303 out.println(" LooseMarshalLong(wireFormat, " + getter + ", dataOut);"); 304 } else if (type.equals("String")) { 305 out.println(" LooseMarshalString(" + getter + ", dataOut);"); 306 } else if (type.equals("byte[]") || type.equals("ByteSequence")) { 307 if (size != null) { 308 out.println(" dataOut.Write(" + getter + ", 0, " + size.asInt() + ");"); 309 } else { 310 out.println(" dataOut.Write(" + getter + "!=null);"); 311 out.println(" if(" + getter + "!=null) {"); 312 out.println(" dataOut.Write(" + getter + ".Length);"); 313 out.println(" dataOut.Write(" + getter + ");"); 314 out.println(" }"); 315 } 316 } else if (propertyType.isArrayType()) { 317 if (size != null) { 318 out.println(" LooseMarshalObjectArrayConstSize(wireFormat, " + getter + ", dataOut, " + size.asInt() + ");"); 319 } else { 320 out.println(" LooseMarshalObjectArray(wireFormat, " + getter + ", dataOut);"); 321 } 322 } else if (isThrowable(propertyType)) { 323 out.println(" LooseMarshalBrokerError(wireFormat, " + getter + ", dataOut);"); 324 } else { 325 if (isCachedProperty(property)) { 326 out.println(" LooseMarshalCachedObject(wireFormat, (DataStructure)" + getter + ", dataOut);"); 327 } else { 328 out.println(" LooseMarshalNestedObject(wireFormat, (DataStructure)" + getter + ", dataOut);"); 329 } 330 } 331 } 332 } 333 334 public String getTargetDir() { 335 return targetDir; 336 } 337 338 public void setTargetDir(String targetDir) { 339 this.targetDir = targetDir; 340 } 341 342 private void generateLicence(PrintWriter out) { 343 out.println("/**"); 344 out.println(" * Licensed to the Apache Software Foundation (ASF) under one or more"); 345 out.println(" * contributor license agreements. See the NOTICE file distributed with"); 346 out.println(" * this work for additional information regarding copyright ownership."); 347 out.println(" * The ASF licenses this file to You under the Apache License, Version 2.0"); 348 out.println(" * (the \"License\"); you may not use this file except in compliance with"); 349 out.println(" * the License. You may obtain a copy of the License at"); 350 out.println(" *"); 351 out.println(" * http://www.apache.org/licenses/LICENSE-2.0"); 352 out.println(" *"); 353 out.println(" * Unless required by applicable law or agreed to in writing, software"); 354 out.println(" * distributed under the License is distributed on an \"AS IS\" BASIS,"); 355 out.println(" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied."); 356 out.println(" * See the License for the specific language governing permissions and"); 357 out.println(" * limitations under the License."); 358 out.println(" */"); 359 } 360 361 protected void generateFile(PrintWriter out) throws Exception { 362 generateLicence(out); 363 out.println(""); 364 out.println("//"); 365 out.println("// NOTE!: This file is autogenerated - do not modify!"); 366 out.println("// if you need to make a change, please see the Groovy scripts in the"); 367 out.println("// activemq-core module"); 368 out.println("//"); 369 out.println(""); 370 out.println("using System;"); 371 out.println("using System.Collections;"); 372 out.println("using System.IO;"); 373 out.println(""); 374 out.println("using ActiveMQ.Commands;"); 375 out.println("using ActiveMQ.OpenWire;"); 376 out.println("using ActiveMQ.OpenWire.V" + getOpenwireVersion() + ";"); 377 out.println(""); 378 out.println("namespace ActiveMQ.OpenWire.V" + getOpenwireVersion() + ""); 379 out.println("{"); 380 out.println(" /// <summary>"); 381 out.println(" /// Marshalling code for Open Wire Format for " + jclass.getSimpleName() + ""); 382 out.println(" /// </summary>"); 383 out.println(" " + getAbstractClassText() + "class " + getClassName() + " : " + getBaseClass() + ""); 384 out.println(" {"); 385 386 if (!isAbstractClass()) { 387 out.println(""); 388 out.println(""); 389 out.println(" public override DataStructure CreateObject() "); 390 out.println(" {"); 391 out.println(" return new " + jclass.getSimpleName() + "();"); 392 out.println(" }"); 393 out.println(""); 394 out.println(" public override byte GetDataStructureType() "); 395 out.println(" {"); 396 out.println(" return " + jclass.getSimpleName() + ".ID_" + jclass.getSimpleName() + ";"); 397 out.println(" }"); 398 } 399 400 /* 401 * Generate the tight encoding marshallers 402 */ 403 out.println(""); 404 out.println(" // "); 405 out.println(" // Un-marshal an object instance from the data input stream"); 406 out.println(" // "); 407 out.println(" public override void TightUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn, BooleanStream bs) "); 408 out.println(" {"); 409 out.println(" base.TightUnmarshal(wireFormat, o, dataIn, bs);"); 410 411 if (!getProperties().isEmpty() || isMarshallerAware()) { 412 out.println(""); 413 out.println(" " + jclass.getSimpleName() + " info = (" + jclass.getSimpleName() + ")o;"); 414 } 415 416 if (isMarshallerAware()) { 417 out.println(""); 418 out.println(" info.BeforeUnmarshall(wireFormat);"); 419 out.println(""); 420 } 421 422 generateTightUnmarshalBody(out); 423 424 if (isMarshallerAware()) { 425 out.println(""); 426 out.println(" info.AfterUnmarshall(wireFormat);"); 427 } 428 429 out.println(""); 430 out.println(" }"); 431 out.println(""); 432 out.println(" //"); 433 out.println(" // Write the booleans that this object uses to a BooleanStream"); 434 out.println(" //"); 435 out.println(" public override int TightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) {"); 436 out.println(" " + jclass.getSimpleName() + " info = (" + jclass.getSimpleName() + ")o;"); 437 438 if (isMarshallerAware()) { 439 out.println(""); 440 out.println(" info.BeforeMarshall(wireFormat);"); 441 } 442 443 out.println(""); 444 out.println(" int rc = base.TightMarshal1(wireFormat, info, bs);"); 445 446 int baseSize = generateTightMarshal1Body(out); 447 448 out.println(""); 449 out.println(" return rc + " + baseSize + ";"); 450 out.println(" }"); 451 out.println(""); 452 out.println(" // "); 453 out.println(" // Write a object instance to data output stream"); 454 out.println(" //"); 455 out.println(" public override void TightMarshal2(OpenWireFormat wireFormat, Object o, BinaryWriter dataOut, BooleanStream bs) {"); 456 out.println(" base.TightMarshal2(wireFormat, o, dataOut, bs);"); 457 458 if (!getProperties().isEmpty() || isMarshallerAware()) { 459 out.println(""); 460 out.println(" " + jclass.getSimpleName() + " info = (" + jclass.getSimpleName() + ")o;"); 461 } 462 463 generateTightMarshal2Body(out); 464 465 if (isMarshallerAware()) { 466 out.println(""); 467 out.println(" info.AfterMarshall(wireFormat);"); 468 } 469 470 out.println(""); 471 out.println(" }"); 472 473 out.println(""); 474 out.println(" // "); 475 out.println(" // Un-marshal an object instance from the data input stream"); 476 out.println(" // "); 477 out.println(" public override void LooseUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn) "); 478 out.println(" {"); 479 out.println(" base.LooseUnmarshal(wireFormat, o, dataIn);"); 480 481 if (!getProperties().isEmpty() || isMarshallerAware()) { 482 out.println(""); 483 out.println(" " + jclass.getSimpleName() + " info = (" + jclass.getSimpleName() + ")o;"); 484 } 485 486 if (isMarshallerAware()) { 487 out.println(""); 488 out.println(" info.BeforeUnmarshall(wireFormat);"); 489 out.println(""); 490 } 491 492 generateLooseUnmarshalBody(out); 493 494 if (isMarshallerAware()) { 495 out.println(""); 496 out.println(" info.AfterUnmarshall(wireFormat);"); 497 } 498 499 out.println(""); 500 out.println(" }"); 501 out.println(""); 502 out.println(" // "); 503 out.println(" // Write a object instance to data output stream"); 504 out.println(" //"); 505 out.println(" public override void LooseMarshal(OpenWireFormat wireFormat, Object o, BinaryWriter dataOut) {"); 506 507 if (!getProperties().isEmpty() || isMarshallerAware()) { 508 out.println(""); 509 out.println(" " + jclass.getSimpleName() + " info = (" + jclass.getSimpleName() + ")o;"); 510 } 511 512 if (isMarshallerAware()) { 513 out.println(""); 514 out.println(" info.BeforeMarshall(wireFormat);"); 515 } 516 517 out.println(""); 518 out.println(" base.LooseMarshal(wireFormat, o, dataOut);"); 519 520 generateLooseMarshalBody(out); 521 522 if (isMarshallerAware()) { 523 out.println(""); 524 out.println(" info.AfterMarshall(wireFormat);"); 525 } 526 out.println(""); 527 out.println(" }"); 528 out.println(" }"); 529 out.println("}"); 530 531 } 532 533 public void generateFactory(PrintWriter out) { 534 generateLicence(out); 535 out.println(""); 536 out.println("//"); 537 out.println("// NOTE!: This file is autogenerated - do not modify!"); 538 out.println("// if you need to make a change, please see the Groovy scripts in the"); 539 out.println("// activemq-core module"); 540 out.println("//"); 541 out.println(""); 542 out.println("using System;"); 543 out.println("using System.Collections;"); 544 out.println("using System.IO;"); 545 out.println(""); 546 out.println("using ActiveMQ.Commands;"); 547 out.println("using ActiveMQ.OpenWire;"); 548 out.println("using ActiveMQ.OpenWire.V" + getOpenwireVersion() + ";"); 549 out.println(""); 550 out.println("namespace ActiveMQ.OpenWire.V" + getOpenwireVersion() + ""); 551 out.println("{"); 552 out.println(" /// <summary>"); 553 out.println(" /// Used to create marshallers for a specific version of the wire protocol"); 554 out.println(" /// </summary>"); 555 out.println(" public class MarshallerFactory : IMarshallerFactory"); 556 out.println(" {"); 557 out.println(" public void configure(OpenWireFormat format) "); 558 out.println(" {"); 559 out.println(" format.clearMarshallers();"); 560 561 List list = new ArrayList(getConcreteClasses()); 562 Collections.sort(list, new Comparator() { 563 public int compare(Object o1, Object o2) { 564 JClass c1 = (JClass)o1; 565 JClass c2 = (JClass)o2; 566 return c1.getSimpleName().compareTo(c2.getSimpleName()); 567 } 568 }); 569 570 for (Iterator iter = list.iterator(); iter.hasNext();) { 571 JClass jclass = (JClass)iter.next(); 572 out.println(" format.addMarshaller(new " + jclass.getSimpleName() + "Marshaller());"); 573 } 574 575 out.println(""); 576 out.println(" }"); 577 out.println(" }"); 578 out.println("}"); 579 580 } 581 }