KickJava   Java API By Example, From Geeks To Geeks.

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


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 FactoryInterface
7 {
8   protected static String JavaDoc nl;
9   public static synchronized FactoryInterface create(String JavaDoc lineSeparator)
10   {
11     nl = lineSeparator;
12     FactoryInterface result = new FactoryInterface();
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 + " * The <b>Factory</b> for the model." + NL + " * It provides a create method for each non-abstract class of the model." + NL + " * <!-- end-user-doc -->" + NL + " * @see ";
24   protected final String JavaDoc TEXT_7 = NL + " * @generated" + NL + " */" + NL + "public interface ";
25   protected final String JavaDoc TEXT_8 = " extends ";
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 + "\t";
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 * The singleton instance of the factory." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\t";
32   protected final String JavaDoc TEXT_15 = " eINSTANCE = new ";
33   protected final String JavaDoc TEXT_16 = "();" + NL;
34   protected final String JavaDoc TEXT_17 = NL + "\t/**" + NL + "\t * Returns a new object of class '<em>";
35   protected final String JavaDoc TEXT_18 = "</em>'." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @return a new object of class '<em>";
36   protected final String JavaDoc TEXT_19 = "</em>'." + NL + "\t * @generated" + NL + "\t */" + NL + "\t";
37   protected final String JavaDoc TEXT_20 = " create";
38   protected final String JavaDoc TEXT_21 = "();" + NL;
39   protected final String JavaDoc TEXT_22 = NL + "\t/**" + NL + "\t * Returns the package supported by this factory." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @return the package supported by this factory." + NL + "\t * @generated" + NL + "\t */" + NL + "\t";
40   protected final String JavaDoc TEXT_23 = " get";
41   protected final String JavaDoc TEXT_24 = "();" + NL + "" + NL + "} //";
42   protected final String JavaDoc TEXT_25 = NL;
43
44   public String JavaDoc generate(Object JavaDoc argument)
45   {
46     StringBuffer JavaDoc stringBuffer = new StringBuffer JavaDoc();
47     
48 /**
49  * <copyright>
50  *
51  * Copyright (c) 2002-2004 IBM Corporation and others.
52  * All rights reserved. This program and the accompanying materials
53  * are made available under the terms of the Eclipse Public License v1.0
54  * which accompanies this distribution, and is available at
55  * http://www.eclipse.org/legal/epl-v10.html
56  *
57  * Contributors:
58  * IBM - Initial API and implementation
59  *
60  * </copyright>
61  */

62
63     GenPackage genPackage = (GenPackage)argument; GenModel genModel=genPackage.getGenModel();
64     stringBuffer.append(TEXT_1);
65     stringBuffer.append(TEXT_2);
66     stringBuffer.append("$");
67     stringBuffer.append(TEXT_3);
68     stringBuffer.append("$");
69     stringBuffer.append(TEXT_4);
70     stringBuffer.append(genPackage.getInterfacePackageName());
71     stringBuffer.append(TEXT_5);
72     genModel.markImportLocation(stringBuffer, genPackage);
73     stringBuffer.append(TEXT_6);
74     stringBuffer.append(genPackage.getQualifiedPackageInterfaceName());
75     stringBuffer.append(TEXT_7);
76     stringBuffer.append(genPackage.getFactoryInterfaceName());
77     stringBuffer.append(TEXT_8);
78     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.EFactory"));
79     stringBuffer.append(TEXT_9);
80     if (genModel.getCopyrightText() != null) {
81     stringBuffer.append(TEXT_10);
82     stringBuffer.append(genModel.getImportedName("java.lang.String"));
83     stringBuffer.append(TEXT_11);
84     stringBuffer.append(genModel.getCopyrightText());
85     stringBuffer.append(TEXT_12);
86     stringBuffer.append(genModel.getNonNLS());
87     stringBuffer.append(TEXT_13);
88     }
89     stringBuffer.append(TEXT_14);
90     stringBuffer.append(genPackage.getFactoryInterfaceName());
91     stringBuffer.append(TEXT_15);
92     stringBuffer.append(genPackage.getQualifiedFactoryClassName());
93     stringBuffer.append(TEXT_16);
94     for (Iterator i=genPackage.getGenClasses().iterator(); i.hasNext();) { GenClass genClass = (GenClass)i.next();
95     if (!genClass.isAbstract() && !genClass.isMapEntry()) {
96     stringBuffer.append(TEXT_17);
97     stringBuffer.append(genClass.getFormattedName());
98     stringBuffer.append(TEXT_18);
99     stringBuffer.append(genClass.getFormattedName());
100     stringBuffer.append(TEXT_19);
101     stringBuffer.append(genClass.getImportedInterfaceName());
102     stringBuffer.append(TEXT_20);
103     stringBuffer.append(genClass.getName());
104     stringBuffer.append(TEXT_21);
105     }
106     }
107     stringBuffer.append(TEXT_22);
108     stringBuffer.append(genPackage.getPackageInterfaceName());
109     stringBuffer.append(TEXT_23);
110     stringBuffer.append(genPackage.getPackageInterfaceName());
111     stringBuffer.append(TEXT_24);
112     stringBuffer.append(genPackage.getFactoryInterfaceName());
113     genModel.emitSortedImports();
114     stringBuffer.append(TEXT_25);
115     return stringBuffer.toString();
116   }
117 }
118
Popular Tags