KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > codegen > ecore > templates > model > FactoryClass


1 package org.eclipse.emf.codegen.ecore.templates.model;
2
3 import java.util.*;
4 import org.eclipse.emf.codegen.ecore.genmodel.*;
5
6 public class FactoryClass
7 {
8   protected static String JavaDoc nl;
9   public static synchronized FactoryClass create(String JavaDoc lineSeparator)
10   {
11     nl = lineSeparator;
12     FactoryClass result = new FactoryClass();
13     nl = null;
14     return result;
15   }
16
17   protected final String JavaDoc NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
18   protected final String JavaDoc TEXT_1 = "";
19   protected final String JavaDoc TEXT_2 = "/**" + NL + " * <copyright>" + NL + " * </copyright>" + NL + " *" + NL + " * ";
20   protected final String JavaDoc TEXT_3 = "Id";
21   protected final String JavaDoc TEXT_4 = NL + " */" + NL + "package ";
22   protected final String JavaDoc TEXT_5 = ";" + NL;
23   protected final String JavaDoc TEXT_6 = NL + NL + "/**" + NL + " * <!-- begin-user-doc -->" + NL + " * An implementation of the model <b>Factory</b>." + NL + " * <!-- end-user-doc -->" + NL + " * @generated" + NL + " */" + NL + "public class ";
24   protected final String JavaDoc TEXT_7 = " extends ";
25   protected final String JavaDoc TEXT_8 = " implements ";
26   protected final String JavaDoc TEXT_9 = NL + "{";
27   protected final String JavaDoc TEXT_10 = NL + "\t/**" + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static final ";
28   protected final String JavaDoc TEXT_11 = " copyright = \"";
29   protected final String JavaDoc TEXT_12 = "\";";
30   protected final String JavaDoc TEXT_13 = NL;
31   protected final String JavaDoc TEXT_14 = NL + "\t/**" + NL + "\t * Creates an instance of the factory." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
32   protected final String JavaDoc TEXT_15 = "()" + NL + "\t{" + NL + "\t\tsuper();" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic EObject create(EClass eClass)" + NL + "\t{" + NL + "\t\tswitch (eClass.getClassifierID())" + NL + "\t\t{";
33   protected final String JavaDoc TEXT_16 = NL + "\t\t\tcase ";
34   protected final String JavaDoc TEXT_17 = ".";
35   protected final String JavaDoc TEXT_18 = ": return ";
36   protected final String JavaDoc TEXT_19 = "create";
37   protected final String JavaDoc TEXT_20 = "();";
38   protected final String JavaDoc TEXT_21 = NL + "\t\t\tdefault:" + NL + "\t\t\t\tthrow new IllegalArgumentException(\"The class '\" + eClass.getName() + \"' is not a valid classifier\");";
39   protected final String JavaDoc TEXT_22 = NL + "\t\t}" + NL + "\t}";
40   protected final String JavaDoc TEXT_23 = NL + NL + "\t/**" + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic Object createFromString(";
41   protected final String JavaDoc TEXT_24 = " eDataType, String initialValue)" + NL + "\t{" + NL + "\t\tswitch (eDataType.getClassifierID())" + NL + "\t\t{";
42   protected final String JavaDoc TEXT_25 = NL + "\t\t\tcase ";
43   protected final String JavaDoc TEXT_26 = ".";
44   protected final String JavaDoc TEXT_27 = ":";
45   protected final String JavaDoc TEXT_28 = NL + "\t\t\t{" + NL + "\t\t\t\t";
46   protected final String JavaDoc TEXT_29 = " result = ";
47   protected final String JavaDoc TEXT_30 = ".get(initialValue);" + NL + "\t\t\t\tif (result == null) throw new IllegalArgumentException(\"The value '\" + initialValue + \"' is not a valid enumerator of '\" + eDataType.getName() + \"'\");";
48   protected final String JavaDoc TEXT_31 = NL + "\t\t\t\treturn result;" + NL + "\t\t\t}";
49   protected final String JavaDoc TEXT_32 = NL + "\t\t\t\treturn create";
50   protected final String JavaDoc TEXT_33 = "FromString(eDataType, initialValue);";
51   protected final String JavaDoc TEXT_34 = NL + "\t\t\tdefault:" + NL + "\t\t\t\tthrow new IllegalArgumentException(\"The datatype '\" + eDataType.getName() + \"' is not a valid classifier\");";
52   protected final String JavaDoc TEXT_35 = NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic String convertToString(";
53   protected final String JavaDoc TEXT_36 = " eDataType, Object instanceValue)" + NL + "\t{" + NL + "\t\tswitch (eDataType.getClassifierID())" + NL + "\t\t{";
54   protected final String JavaDoc TEXT_37 = NL + "\t\t\tcase ";
55   protected final String JavaDoc TEXT_38 = ".";
56   protected final String JavaDoc TEXT_39 = ":";
57   protected final String JavaDoc TEXT_40 = NL + "\t\t\t\treturn instanceValue == null ? null : instanceValue.toString();";
58   protected final String JavaDoc TEXT_41 = NL + "\t\t\t\treturn convert";
59   protected final String JavaDoc TEXT_42 = "ToString(eDataType, instanceValue);";
60   protected final String JavaDoc TEXT_43 = NL + "\t\t\tdefault:" + NL + "\t\t\t\tthrow new IllegalArgumentException(\"The datatype '\" + eDataType.getName() + \"' is not a valid classifier\");";
61   protected final String JavaDoc TEXT_44 = NL + "\t\t}" + NL + "\t}";
62   protected final String JavaDoc TEXT_45 = NL + NL + "\t/**" + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
63   protected final String JavaDoc TEXT_46 = " create";
64   protected final String JavaDoc TEXT_47 = "()" + NL + "\t{" + NL + "\t\t";
65   protected final String JavaDoc TEXT_48 = " ";
66   protected final String JavaDoc TEXT_49 = " = new ";
67   protected final String JavaDoc TEXT_50 = "();" + NL + "\t\treturn ";
68   protected final String JavaDoc TEXT_51 = ";" + NL + "\t}";
69   protected final String JavaDoc TEXT_52 = NL + NL + "\t/**" + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
70   protected final String JavaDoc TEXT_53 = " create";
71   protected final String JavaDoc TEXT_54 = "FromString(";
72   protected final String JavaDoc TEXT_55 = " eDataType, String initialValue)" + NL + "\t{";
73   protected final String JavaDoc TEXT_56 = NL + "\t\t// TODO: implement this method" + NL + "\t\t// Ensure that you remove @generated or mark it @generated NOT" + NL + "\t\tthrow new ";
74   protected final String JavaDoc TEXT_57 = "();";
75   protected final String JavaDoc TEXT_58 = NL + "\t\treturn (";
76   protected final String JavaDoc TEXT_59 = ")";
77   protected final String JavaDoc TEXT_60 = ".eINSTANCE.createFromString(";
78   protected final String JavaDoc TEXT_61 = ".eINSTANCE.get";
79   protected final String JavaDoc TEXT_62 = "(), initialValue);";
80   protected final String JavaDoc TEXT_63 = NL + "\t\tif (initialValue == null) return null;" + NL + "\t\t";
81   protected final String JavaDoc TEXT_64 = " result = new ";
82   protected final String JavaDoc TEXT_65 = "();" + NL + "\t\tfor (";
83   protected final String JavaDoc TEXT_66 = " stringTokenizer = new ";
84   protected final String JavaDoc TEXT_67 = "(initialValue); stringTokenizer.hasMoreTokens(); )" + NL + "\t\t{" + NL + "\t\t\tString item = stringTokenizer.nextToken();" + NL + "\t\t\tresult.add(";
85   protected final String JavaDoc TEXT_68 = ".eINSTANCE.createFromString(";
86   protected final String JavaDoc TEXT_69 = ".eINSTANCE.get";
87   protected final String JavaDoc TEXT_70 = "(), item));" + NL + "\t\t}" + NL + "\t\treturn result;";
88   protected final String JavaDoc TEXT_71 = NL + "\t\ttry" + NL + "\t\t{" + NL + "\t\t\t";
89   protected final String JavaDoc TEXT_72 = " result = (";
90   protected final String JavaDoc TEXT_73 = ")";
91   protected final String JavaDoc TEXT_74 = ".eINSTANCE.createFromString(";
92   protected final String JavaDoc TEXT_75 = ".eINSTANCE.get";
93   protected final String JavaDoc TEXT_76 = "(), initialValue);" + NL + "\t\t\tif (result != null)" + NL + "\t\t\t{" + NL + "\t\t\t\treturn result;" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t\tcatch (RuntimeException exception)" + NL + "\t\t{" + NL + "\t\t}";
94   protected final String JavaDoc TEXT_77 = NL + "\t\treturn (";
95   protected final String JavaDoc TEXT_78 = ")";
96   protected final String JavaDoc TEXT_79 = ".eINSTANCE.createFromString(";
97   protected final String JavaDoc TEXT_80 = ".eINSTANCE.get";
98   protected final String JavaDoc TEXT_81 = "(), initialValue);";
99   protected final String JavaDoc TEXT_82 = NL + "\t\treturn (";
100   protected final String JavaDoc TEXT_83 = ")super.createFromString(eDataType, initialValue);";
101   protected final String JavaDoc TEXT_84 = NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic String convert";
102   protected final String JavaDoc TEXT_85 = "ToString(";
103   protected final String JavaDoc TEXT_86 = " eDataType, Object instanceValue)" + NL + "\t{";
104   protected final String JavaDoc TEXT_87 = NL + "\t\t// TODO: implement this method" + NL + "\t\t// Ensure that you remove @generated or mark it @generated NOT" + NL + "\t\tthrow new ";
105   protected final String JavaDoc TEXT_88 = "();";
106   protected final String JavaDoc TEXT_89 = NL + "\t\treturn ";
107   protected final String JavaDoc TEXT_90 = ".eINSTANCE.convertToString(";
108   protected final String JavaDoc TEXT_91 = ".eINSTANCE.get";
109   protected final String JavaDoc TEXT_92 = "(), instanceValue);";
110   protected final String JavaDoc TEXT_93 = NL + "\t\tif (instanceValue == null) return null;" + NL + "\t\t";
111   protected final String JavaDoc TEXT_94 = " list = (";
112   protected final String JavaDoc TEXT_95 = ")instanceValue;" + NL + "\t\tif (list.isEmpty()) return \"\";" + NL + "\t\t";
113   protected final String JavaDoc TEXT_96 = " result = new ";
114   protected final String JavaDoc TEXT_97 = "();" + NL + "\t\tfor (";
115   protected final String JavaDoc TEXT_98 = " i = list.iterator(); i.hasNext(); )" + NL + "\t\t{" + NL + "\t\t\tresult.append(";
116   protected final String JavaDoc TEXT_99 = ".eINSTANCE.convertToString(";
117   protected final String JavaDoc TEXT_100 = ".eINSTANCE.get";
118   protected final String JavaDoc TEXT_101 = "(), i.next()));" + NL + "\t\t\tresult.append(' ');" + NL + "\t\t}" + NL + "\t\treturn result.substring(0, result.length() - 1);";
119   protected final String JavaDoc TEXT_102 = NL + "\t\tif (";
120   protected final String JavaDoc TEXT_103 = ".eINSTANCE.get";
121   protected final String JavaDoc TEXT_104 = "().isInstance(instanceValue))" + NL + "\t\t{" + NL + "\t\t\ttry" + NL + "\t\t\t{" + NL + "\t\t\t\tString value = ";
122   protected final String JavaDoc TEXT_105 = ".eINSTANCE.convertToString(";
123   protected final String JavaDoc TEXT_106 = ".eINSTANCE.get";
124   protected final String JavaDoc TEXT_107 = "(), instanceValue);" + NL + "\t\t\t\tif (value != null) return value;" + NL + "\t\t\t}" + NL + "\t\t\tcatch (Exception e)" + NL + "\t\t\t{" + NL + "\t\t\t}" + NL + "\t\t}";
125   protected final String JavaDoc TEXT_108 = NL + "\t\tthrow new IllegalArgumentException(\"Invalid value: '\"+instanceValue+\"' for datatype :\"+eDataType.getName());";
126   protected final String JavaDoc TEXT_109 = NL + "\t\treturn super.convertToString(eDataType, instanceValue);";
127   protected final String JavaDoc TEXT_110 = NL + "\t}";
128   protected final String JavaDoc TEXT_111 = NL + NL + "\t/**" + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
129   protected final String JavaDoc TEXT_112 = " get";
130   protected final String JavaDoc TEXT_113 = "()" + NL + "\t{" + NL + "\t\treturn (";
131   protected final String JavaDoc TEXT_114 = ")getEPackage();" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @deprecated" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static ";
132   protected final String JavaDoc TEXT_115 = " getPackage()" + NL + "\t{" + NL + "\t\treturn ";
133   protected final String JavaDoc TEXT_116 = ".eINSTANCE;" + NL + "\t}" + NL + "" + NL + "} //";
134   protected final String JavaDoc TEXT_117 = NL;
135
136   public String JavaDoc generate(Object JavaDoc argument)
137   {
138     StringBuffer JavaDoc stringBuffer = new StringBuffer JavaDoc();
139     
140 /**
141  * <copyright>
142  *
143  * Copyright (c) 2002-2005 IBM Corporation and others.
144  * All rights reserved. This program and the accompanying materials
145  * are made available under the terms of the Eclipse Public License v1.0
146  * which accompanies this distribution, and is available at
147  * http://www.eclipse.org/legal/epl-v10.html
148  *
149  * Contributors:
150  * IBM - Initial API and implementation
151  *
152  * </copyright>
153  */

154
155     GenPackage genPackage = (GenPackage)argument; GenModel genModel=genPackage.getGenModel();
156     stringBuffer.append(TEXT_1);
157     stringBuffer.append(TEXT_2);
158     stringBuffer.append("$");
159     stringBuffer.append(TEXT_3);
160     stringBuffer.append("$");
161     stringBuffer.append(TEXT_4);
162     stringBuffer.append(genPackage.getClassPackageName());
163     stringBuffer.append(TEXT_5);
164     genModel.addImport("org.eclipse.emf.ecore.EClass");
165     genModel.addImport("org.eclipse.emf.ecore.EObject");
166     if (!genPackage.hasJavaLangConflict() && !genPackage.hasInterfaceImplConflict() && !genPackage.getClassPackageName().equals(genPackage.getInterfacePackageName())) genModel.addImport(genPackage.getInterfacePackageName() + ".*");
167     genModel.markImportLocation(stringBuffer);
168     stringBuffer.append(TEXT_6);
169     stringBuffer.append(genPackage.getFactoryClassName());
170     stringBuffer.append(TEXT_7);
171     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.impl.EFactoryImpl"));
172     stringBuffer.append(TEXT_8);
173     stringBuffer.append(genPackage.getImportedFactoryInterfaceName());
174     stringBuffer.append(TEXT_9);
175     if (genModel.getCopyrightText() != null) {
176     stringBuffer.append(TEXT_10);
177     stringBuffer.append(genModel.getImportedName("java.lang.String"));
178     stringBuffer.append(TEXT_11);
179     stringBuffer.append(genModel.getCopyrightText());
180     stringBuffer.append(TEXT_12);
181     stringBuffer.append(genModel.getNonNLS());
182     stringBuffer.append(TEXT_13);
183     }
184     stringBuffer.append(TEXT_14);
185     stringBuffer.append(genPackage.getFactoryClassName());
186     stringBuffer.append(TEXT_15);
187     for (Iterator i=genPackage.getGenClasses().iterator(); i.hasNext();) { GenClass genClass = (GenClass)i.next();
188     if (!genClass.isAbstract()) {
189     stringBuffer.append(TEXT_16);
190     stringBuffer.append(genPackage.getImportedPackageInterfaceName());
191     stringBuffer.append(TEXT_17);
192     stringBuffer.append(genClass.getClassifierID());
193     stringBuffer.append(TEXT_18);
194     stringBuffer.append(!genClass.isEObjectExtension() ? "(EObject)" : "" );
195     stringBuffer.append(TEXT_19);
196     stringBuffer.append(genClass.getName());
197     stringBuffer.append(TEXT_20);
198     }
199     }
200     stringBuffer.append(TEXT_21);
201     stringBuffer.append(genModel.getNonNLS());
202     stringBuffer.append(genModel.getNonNLS(2));
203     stringBuffer.append(TEXT_22);
204     if (!genPackage.getAllGenDataTypes().isEmpty()) {
205     stringBuffer.append(TEXT_23);
206     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.EDataType"));
207     stringBuffer.append(TEXT_24);
208     for (Iterator i=genPackage.getAllGenDataTypes().iterator(); i.hasNext();) { GenDataType genDataType = (GenDataType)i.next();
209     if (genDataType.isSerializable()) {
210     stringBuffer.append(TEXT_25);
211     stringBuffer.append(genPackage.getImportedPackageInterfaceName());
212     stringBuffer.append(TEXT_26);
213     stringBuffer.append(genDataType.getClassifierID());
214     stringBuffer.append(TEXT_27);
215     if (genDataType instanceof GenEnum) {
216     stringBuffer.append(TEXT_28);
217     stringBuffer.append(((GenEnum)genDataType).getImportedName());
218     stringBuffer.append(TEXT_29);
219     stringBuffer.append(((GenEnum)genDataType).getImportedName());
220     stringBuffer.append(TEXT_30);
221     stringBuffer.append(genModel.getNonNLS());
222     stringBuffer.append(genModel.getNonNLS(2));
223     stringBuffer.append(genModel.getNonNLS(3));
224     stringBuffer.append(TEXT_31);
225     } else {
226     stringBuffer.append(TEXT_32);
227     stringBuffer.append(genDataType.getName());
228     stringBuffer.append(TEXT_33);
229     }
230     }
231     }
232     stringBuffer.append(TEXT_34);
233     stringBuffer.append(genModel.getNonNLS());
234     stringBuffer.append(genModel.getNonNLS(2));
235     stringBuffer.append(TEXT_35);
236     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.EDataType"));
237     stringBuffer.append(TEXT_36);
238     for (Iterator i=genPackage.getAllGenDataTypes().iterator(); i.hasNext();) { GenDataType genDataType = (GenDataType)i.next();
239     if (genDataType.isSerializable()) {
240     stringBuffer.append(TEXT_37);
241     stringBuffer.append(genPackage.getImportedPackageInterfaceName());
242     stringBuffer.append(TEXT_38);
243     stringBuffer.append(genDataType.getClassifierID());
244     stringBuffer.append(TEXT_39);
245     if (genDataType instanceof GenEnum) {
246     stringBuffer.append(TEXT_40);
247     } else {
248     stringBuffer.append(TEXT_41);
249     stringBuffer.append(genDataType.getName());
250     stringBuffer.append(TEXT_42);
251     }
252     }
253     }
254     stringBuffer.append(TEXT_43);
255     stringBuffer.append(genModel.getNonNLS());
256     stringBuffer.append(genModel.getNonNLS(2));
257     stringBuffer.append(TEXT_44);
258     }
259     for (Iterator i=genPackage.getGenClasses().iterator(); i.hasNext();) { GenClass genClass = (GenClass)i.next();
260     if (!genClass.isAbstract()) {
261     stringBuffer.append(TEXT_45);
262     stringBuffer.append(genClass.getImportedInterfaceName());
263     stringBuffer.append(TEXT_46);
264     stringBuffer.append(genClass.getName());
265     stringBuffer.append(TEXT_47);
266     stringBuffer.append(genClass.getImportedClassName());
267     stringBuffer.append(TEXT_48);
268     stringBuffer.append(genClass.getSafeUncapName());
269     stringBuffer.append(TEXT_49);
270     stringBuffer.append(genClass.getImportedClassName());
271     stringBuffer.append(TEXT_50);
272     stringBuffer.append(genClass.getSafeUncapName());
273     stringBuffer.append(TEXT_51);
274     }
275     }
276     for (Iterator i=genPackage.getAllGenDataTypes().iterator(); i.hasNext();) { GenDataType genDataType = (GenDataType)i.next();
277     if (!(genDataType instanceof GenEnum) && genDataType.isSerializable()) {
278     stringBuffer.append(TEXT_52);
279     stringBuffer.append(genDataType.getObjectInstanceClassName());
280     stringBuffer.append(TEXT_53);
281     stringBuffer.append(genDataType.getName());
282     stringBuffer.append(TEXT_54);
283     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.EDataType"));
284     stringBuffer.append(TEXT_55);
285     if (genDataType.isArrayType()) {
286     stringBuffer.append(TEXT_56);
287     stringBuffer.append(genModel.getImportedName("java.lang.UnsupportedOperationException"));
288     stringBuffer.append(TEXT_57);
289     } else if (genDataType.getBaseType() != null) { GenDataType genBaseType = genDataType.getBaseType();
290     stringBuffer.append(TEXT_58);
291     stringBuffer.append(genDataType.getObjectInstanceClassName());
292     stringBuffer.append(TEXT_59);
293     stringBuffer.append(genBaseType.getGenPackage().getImportedFactoryInterfaceName());
294     stringBuffer.append(TEXT_60);
295     stringBuffer.append(genBaseType.getGenPackage().getImportedPackageInterfaceName());
296     stringBuffer.append(TEXT_61);
297     stringBuffer.append(genBaseType.getClassifierAccessorName());
298     stringBuffer.append(TEXT_62);
299     } else if (genDataType.getItemType() != null) { GenDataType genItemType = genDataType.getItemType();
300     stringBuffer.append(TEXT_63);
301     stringBuffer.append(genModel.getImportedName("java.util.List"));
302     stringBuffer.append(TEXT_64);
303     stringBuffer.append(genModel.getImportedName("java.util.ArrayList"));
304     stringBuffer.append(TEXT_65);
305     stringBuffer.append(genModel.getImportedName("java.util.StringTokenizer"));
306     stringBuffer.append(TEXT_66);
307     stringBuffer.append(genModel.getImportedName("java.util.StringTokenizer"));
308     stringBuffer.append(TEXT_67);
309     stringBuffer.append(genItemType.getGenPackage().getImportedFactoryInterfaceName());
310     stringBuffer.append(TEXT_68);
311     stringBuffer.append(genItemType.getGenPackage().getImportedPackageInterfaceName());
312     stringBuffer.append(TEXT_69);
313     stringBuffer.append(genItemType.getClassifierAccessorName());
314     stringBuffer.append(TEXT_70);
315     } else if (!genDataType.getMemberTypes().isEmpty()) {
316     for (Iterator j = genDataType.getMemberTypes().iterator(); j.hasNext(); ) { GenDataType genMemberType = (GenDataType)j.next();
317     if (j.hasNext()) {
318     stringBuffer.append(TEXT_71);
319     stringBuffer.append(genDataType.getObjectInstanceClassName());
320     stringBuffer.append(TEXT_72);
321     stringBuffer.append(genDataType.getObjectInstanceClassName());
322     stringBuffer.append(TEXT_73);
323     stringBuffer.append(genMemberType.getGenPackage().getImportedFactoryInterfaceName());
324     stringBuffer.append(TEXT_74);
325     stringBuffer.append(genMemberType.getGenPackage().getImportedPackageInterfaceName());
326     stringBuffer.append(TEXT_75);
327     stringBuffer.append(genMemberType.getClassifierAccessorName());
328     stringBuffer.append(TEXT_76);
329     } else {
330     stringBuffer.append(TEXT_77);
331     stringBuffer.append(genDataType.getObjectInstanceClassName());
332     stringBuffer.append(TEXT_78);
333     stringBuffer.append(genMemberType.getGenPackage().getImportedFactoryInterfaceName());
334     stringBuffer.append(TEXT_79);
335     stringBuffer.append(genMemberType.getGenPackage().getImportedPackageInterfaceName());
336     stringBuffer.append(TEXT_80);
337     stringBuffer.append(genMemberType.getClassifierAccessorName());
338     stringBuffer.append(TEXT_81);
339     }
340     }
341     } else {
342     stringBuffer.append(TEXT_82);
343     stringBuffer.append(genDataType.getObjectInstanceClassName());
344     stringBuffer.append(TEXT_83);
345     }
346     stringBuffer.append(TEXT_84);
347     stringBuffer.append(genDataType.getName());
348     stringBuffer.append(TEXT_85);
349     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.EDataType"));
350     stringBuffer.append(TEXT_86);
351     if (genDataType.isArrayType()) {
352     stringBuffer.append(TEXT_87);
353     stringBuffer.append(genModel.getImportedName("java.lang.UnsupportedOperationException"));
354     stringBuffer.append(TEXT_88);
355     } else if (genDataType.getBaseType() != null) { GenDataType genBaseType = genDataType.getBaseType();
356     stringBuffer.append(TEXT_89);
357     stringBuffer.append(genBaseType.getGenPackage().getImportedFactoryInterfaceName());
358     stringBuffer.append(TEXT_90);
359     stringBuffer.append(genBaseType.getGenPackage().getImportedPackageInterfaceName());
360     stringBuffer.append(TEXT_91);
361     stringBuffer.append(genBaseType.getClassifierAccessorName());
362     stringBuffer.append(TEXT_92);
363     } else if (genDataType.getItemType() != null) { GenDataType genItemType = genDataType.getItemType();
364     stringBuffer.append(TEXT_93);
365     stringBuffer.append(genModel.getImportedName("java.util.List"));
366     stringBuffer.append(TEXT_94);
367     stringBuffer.append(genModel.getImportedName("java.util.List"));
368     stringBuffer.append(TEXT_95);
369     stringBuffer.append(genModel.getImportedName("java.lang.StringBuffer"));
370     stringBuffer.append(TEXT_96);
371     stringBuffer.append(genModel.getImportedName("java.lang.StringBuffer"));
372     stringBuffer.append(TEXT_97);
373     stringBuffer.append(genModel.getImportedName("java.util.Iterator"));
374     stringBuffer.append(TEXT_98);
375     stringBuffer.append(genItemType.getGenPackage().getImportedFactoryInterfaceName());
376     stringBuffer.append(TEXT_99);
377     stringBuffer.append(genItemType.getGenPackage().getImportedPackageInterfaceName());
378     stringBuffer.append(TEXT_100);
379     stringBuffer.append(genItemType.getClassifierAccessorName());
380     stringBuffer.append(TEXT_101);
381     } else if (!genDataType.getMemberTypes().isEmpty()) {
382     for (Iterator j = genDataType.getMemberTypes().iterator(); j.hasNext(); ) { GenDataType genMemberType = (GenDataType)j.next();
383     stringBuffer.append(TEXT_102);
384     stringBuffer.append(genMemberType.getGenPackage().getImportedPackageInterfaceName());
385     stringBuffer.append(TEXT_103);
386     stringBuffer.append(genMemberType.getClassifierAccessorName());
387     stringBuffer.append(TEXT_104);
388     stringBuffer.append(genMemberType.getGenPackage().getImportedFactoryInterfaceName());
389     stringBuffer.append(TEXT_105);
390     stringBuffer.append(genMemberType.getGenPackage().getImportedPackageInterfaceName());
391     stringBuffer.append(TEXT_106);
392     stringBuffer.append(genMemberType.getClassifierAccessorName());
393     stringBuffer.append(TEXT_107);
394     }
395     stringBuffer.append(TEXT_108);
396     } else {
397     stringBuffer.append(TEXT_109);
398     }
399     stringBuffer.append(TEXT_110);
400     }
401     }
402     stringBuffer.append(TEXT_111);
403     stringBuffer.append(genPackage.getImportedPackageInterfaceName());
404     stringBuffer.append(TEXT_112);
405     stringBuffer.append(genPackage.getPackageInterfaceName());
406     stringBuffer.append(TEXT_113);
407     stringBuffer.append(genPackage.getImportedPackageInterfaceName());
408     stringBuffer.append(TEXT_114);
409     stringBuffer.append(genPackage.getImportedPackageInterfaceName());
410     stringBuffer.append(TEXT_115);
411     stringBuffer.append(genPackage.getImportedPackageInterfaceName());
412     stringBuffer.append(TEXT_116);
413     stringBuffer.append(genPackage.getFactoryClassName());
414     genModel.emitSortedImports();
415     stringBuffer.append(TEXT_117);
416     return stringBuffer.toString();
417   }
418 }
419
Popular Tags