1 package org.ozoneDB.tools.OPP.srcgen.builder; 9 10 import org.ozoneDB.tools.OPP.srcgen.ClassBuilder; 11 import org.ozoneDB.tools.OPP.srcgen.BuilderException; 12 import org.ozoneDB.tools.OPP.message.MessageWriter; 13 import org.ozoneDB.tools.OPP.message.ForkMessageWriter; 14 15 import java.util.Set ; 16 import java.util.HashSet ; 17 import java.util.Iterator ; 18 19 24 public class CompositeBuilder implements ClassBuilder { 25 private Set builders; 26 27 public void init(MessageWriter msgWriter) { 28 for (Iterator iter = builders.iterator(); iter.hasNext();) { 31 ((ClassBuilder) iter.next()).init(new ForkMessageWriter(msgWriter)); 32 } 33 } 34 35 public void beginClass(int modifier, String fullName, String superClass, String interfaces[]) throws BuilderException { 36 for (Iterator iter = builders.iterator(); iter.hasNext();) { 37 ((ClassBuilder) iter.next()).beginClass(modifier, fullName, superClass, interfaces); 38 } 39 } 40 41 public void makeConstructor(int modifier, ClassBuilder.Parameter parameters[], String exceptions[]) throws BuilderException { 42 for (Iterator iter = builders.iterator(); iter.hasNext();) { 43 ((ClassBuilder) iter.next()).makeConstructor(modifier, parameters, exceptions); 44 } 45 } 46 47 public void makeMethod(int modifier, String name, ClassBuilder.Parameter parameters[], String returnType, String exceptions[], int lockLevel) throws BuilderException { 48 for (Iterator iter = builders.iterator(); iter.hasNext();) { 49 ((ClassBuilder) iter.next()).makeMethod(modifier, name, parameters, returnType, exceptions, lockLevel); 50 } 51 } 52 53 public void endClass() throws BuilderException { 54 for (Iterator iter = builders.iterator(); iter.hasNext();) { 55 ((ClassBuilder) iter.next()).endClass(); 56 } 57 } 58 59 public CompositeBuilder() { 60 this.builders = new HashSet (); 61 } 62 63 67 public void addBuilder(ClassBuilder builder) { 68 builders.add(builder); 69 } 70 71 75 public void removeBuilder(ClassBuilder builder) { 76 builders.remove(builder); 77 } 78 } 79 | Popular Tags |