KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.eclipse.emf.codegen.ecore.templates.model;
2
3 import org.eclipse.emf.codegen.ecore.genmodel.*;
4
5 public class ResourceFactoryClass
6 {
7   protected static String JavaDoc nl;
8   public static synchronized ResourceFactoryClass create(String JavaDoc lineSeparator)
9   {
10     nl = lineSeparator;
11     ResourceFactoryClass result = new ResourceFactoryClass();
12     nl = null;
13     return result;
14   }
15
16   protected final String JavaDoc NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
17   protected final String JavaDoc TEXT_1 = "";
18   protected final String JavaDoc TEXT_2 = "/**" + NL + " * <copyright>" + NL + " * </copyright>" + NL + " *" + NL + " * ";
19   protected final String JavaDoc TEXT_3 = "Id";
20   protected final String JavaDoc TEXT_4 = NL + " */" + NL + "package ";
21   protected final String JavaDoc TEXT_5 = ";" + NL;
22   protected final String JavaDoc TEXT_6 = NL + NL + "/**" + NL + " * <!-- begin-user-doc -->" + NL + " * The <b>Resource Factory</b> associated with the package." + NL + " * <!-- end-user-doc -->" + NL + " * @see ";
23   protected final String JavaDoc TEXT_7 = NL + " * @generated" + NL + " */" + NL + "public class ";
24   protected final String JavaDoc TEXT_8 = " extends ";
25   protected final String JavaDoc TEXT_9 = NL + "{";
26   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 ";
27   protected final String JavaDoc TEXT_11 = " copyright = \"";
28   protected final String JavaDoc TEXT_12 = "\";";
29   protected final String JavaDoc TEXT_13 = NL;
30   protected final String JavaDoc TEXT_14 = NL + "\t/**" + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ";
31   protected final String JavaDoc TEXT_15 = " extendedMetaData;" + NL;
32   protected final String JavaDoc TEXT_16 = NL + "\t/**" + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected ";
33   protected final String JavaDoc TEXT_17 = " xmlMap = new ";
34   protected final String JavaDoc TEXT_18 = "();" + NL;
35   protected final String JavaDoc TEXT_19 = NL + "\t/**" + NL + "\t * Creates an instance of the resource factory." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
36   protected final String JavaDoc TEXT_20 = "()" + NL + "\t{" + NL + "\t\tsuper();";
37   protected final String JavaDoc TEXT_21 = NL + "\t\textendedMetaData = new ";
38   protected final String JavaDoc TEXT_22 = "(new ";
39   protected final String JavaDoc TEXT_23 = "(";
40   protected final String JavaDoc TEXT_24 = ".Registry.INSTANCE));" + NL + "\t\textendedMetaData.putPackage(null, ";
41   protected final String JavaDoc TEXT_25 = ".eINSTANCE);";
42   protected final String JavaDoc TEXT_26 = NL + "\t\txmlMap.setNoNamespacePackage(";
43   protected final String JavaDoc TEXT_27 = ".eINSTANCE);";
44   protected final String JavaDoc TEXT_28 = NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * Creates an instance of the resource." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic Resource createResource(URI uri)" + NL + "\t{";
45   protected final String JavaDoc TEXT_29 = NL + "\t\t";
46   protected final String JavaDoc TEXT_30 = " result = new ";
47   protected final String JavaDoc TEXT_31 = "(uri);" + NL + "\t\tresult.getDefaultSaveOptions().put(";
48   protected final String JavaDoc TEXT_32 = ".OPTION_EXTENDED_META_DATA, ";
49   protected final String JavaDoc TEXT_33 = "Boolean.TRUE";
50   protected final String JavaDoc TEXT_34 = "extendedMetaData";
51   protected final String JavaDoc TEXT_35 = ");" + NL + "\t\tresult.getDefaultLoadOptions().put(";
52   protected final String JavaDoc TEXT_36 = ".OPTION_EXTENDED_META_DATA, ";
53   protected final String JavaDoc TEXT_37 = "Boolean.TRUE";
54   protected final String JavaDoc TEXT_38 = "extendedMetaData";
55   protected final String JavaDoc TEXT_39 = ");" + NL + "" + NL + "\t\tresult.getDefaultSaveOptions().put(";
56   protected final String JavaDoc TEXT_40 = ".OPTION_SCHEMA_LOCATION, Boolean.TRUE);" + NL + "\t\tresult.getDefaultSaveOptions().put(";
57   protected final String JavaDoc TEXT_41 = ".OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);" + NL + "" + NL + "\t\tresult.getDefaultLoadOptions().put(";
58   protected final String JavaDoc TEXT_42 = ".OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);";
59   protected final String JavaDoc TEXT_43 = NL + "\t\t";
60   protected final String JavaDoc TEXT_44 = " result = new ";
61   protected final String JavaDoc TEXT_45 = "(uri);" + NL + "\t\tresult.getDefaultSaveOptions().put(";
62   protected final String JavaDoc TEXT_46 = ".OPTION_XML_MAP, xmlMap);" + NL + "\t\tresult.getDefaultLoadOptions().put(";
63   protected final String JavaDoc TEXT_47 = ".OPTION_XML_MAP, xmlMap);";
64   protected final String JavaDoc TEXT_48 = NL + "\t\tResource result = new ";
65   protected final String JavaDoc TEXT_49 = "(uri);";
66   protected final String JavaDoc TEXT_50 = NL + "\t\treturn result;";
67   protected final String JavaDoc TEXT_51 = NL + "\t}" + NL + "" + NL + "} //";
68   protected final String JavaDoc TEXT_52 = NL;
69
70   public String JavaDoc generate(Object JavaDoc argument)
71   {
72     StringBuffer JavaDoc stringBuffer = new StringBuffer JavaDoc();
73     
74 /**
75  * <copyright>
76  *
77  * Copyright (c) 2002-2004 IBM Corporation and others.
78  * All rights reserved. This program and the accompanying materials
79  * are made available under the terms of the Eclipse Public License v1.0
80  * which accompanies this distribution, and is available at
81  * http://www.eclipse.org/legal/epl-v10.html
82  *
83  * Contributors:
84  * IBM - Initial API and implementation
85  *
86  * </copyright>
87  */

88
89     GenPackage genPackage = (GenPackage)argument; GenModel genModel=genPackage.getGenModel();
90     stringBuffer.append(TEXT_1);
91     stringBuffer.append(TEXT_2);
92     stringBuffer.append("$");
93     stringBuffer.append(TEXT_3);
94     stringBuffer.append("$");
95     stringBuffer.append(TEXT_4);
96     stringBuffer.append(genPackage.getUtilitiesPackageName());
97     stringBuffer.append(TEXT_5);
98     genModel.getImportedName("org.eclipse.emf.common.util.URI");
99     genModel.getImportedName("org.eclipse.emf.ecore.resource.Resource");
100     genModel.markImportLocation(stringBuffer);
101     stringBuffer.append(TEXT_6);
102     stringBuffer.append(genPackage.getQualifiedResourceClassName());
103     stringBuffer.append(TEXT_7);
104     stringBuffer.append(genPackage.getResourceFactoryClassName());
105     stringBuffer.append(TEXT_8);
106     stringBuffer.append(genPackage.getImportedResourceFactoryBaseClassName());
107     stringBuffer.append(TEXT_9);
108     if (genModel.getCopyrightText() != null) {
109     stringBuffer.append(TEXT_10);
110     stringBuffer.append(genModel.getImportedName("java.lang.String"));
111     stringBuffer.append(TEXT_11);
112     stringBuffer.append(genModel.getCopyrightText());
113     stringBuffer.append(TEXT_12);
114     stringBuffer.append(genModel.getNonNLS());
115     stringBuffer.append(TEXT_13);
116     }
117     if (genPackage.hasExtendedMetaData() && !genPackage.hasTargetNamespace()) {
118     stringBuffer.append(TEXT_14);
119     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.util.ExtendedMetaData"));
120     stringBuffer.append(TEXT_15);
121     } else if (genPackage.hasXMLMap()) {
122     stringBuffer.append(TEXT_16);
123     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.xmi.XMLResource$XMLMap"));
124     stringBuffer.append(TEXT_17);
125     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.xmi.impl.XMLMapImpl"));
126     stringBuffer.append(TEXT_18);
127     }
128     stringBuffer.append(TEXT_19);
129     stringBuffer.append(genPackage.getResourceFactoryClassName());
130     stringBuffer.append(TEXT_20);
131     if (genPackage.hasExtendedMetaData() && !genPackage.hasTargetNamespace()) {
132     stringBuffer.append(TEXT_21);
133     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.util.BasicExtendedMetaData"));
134     stringBuffer.append(TEXT_22);
135     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.impl.EPackageRegistryImpl"));
136     stringBuffer.append(TEXT_23);
137     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.EPackage"));
138     stringBuffer.append(TEXT_24);
139     stringBuffer.append(genPackage.getImportedPackageInterfaceName());
140     stringBuffer.append(TEXT_25);
141     } else if (genPackage.hasXMLMap() && !genPackage.hasTargetNamespace()) {
142     stringBuffer.append(TEXT_26);
143     stringBuffer.append(genPackage.getImportedPackageInterfaceName());
144     stringBuffer.append(TEXT_27);
145     }
146     stringBuffer.append(TEXT_28);
147     if (genPackage.hasExtendedMetaData()) {
148     stringBuffer.append(TEXT_29);
149     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.xmi.XMLResource"));
150     stringBuffer.append(TEXT_30);
151     stringBuffer.append(genPackage.getResourceClassName());
152     stringBuffer.append(TEXT_31);
153     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.xmi.XMLResource"));
154     stringBuffer.append(TEXT_32);
155     if (genPackage.hasTargetNamespace()){
156     stringBuffer.append(TEXT_33);
157     }else{
158     stringBuffer.append(TEXT_34);
159     }
160     stringBuffer.append(TEXT_35);
161     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.xmi.XMLResource"));
162     stringBuffer.append(TEXT_36);
163     if (genPackage.hasTargetNamespace()){
164     stringBuffer.append(TEXT_37);
165     }else{
166     stringBuffer.append(TEXT_38);
167     }
168     stringBuffer.append(TEXT_39);
169     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.xmi.XMLResource"));
170     stringBuffer.append(TEXT_40);
171     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.xmi.XMLResource"));
172     stringBuffer.append(TEXT_41);
173     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.xmi.XMLResource"));
174     stringBuffer.append(TEXT_42);
175     } else if (genPackage.hasXMLMap()) {
176     stringBuffer.append(TEXT_43);
177     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.xmi.XMLResource"));
178     stringBuffer.append(TEXT_44);
179     stringBuffer.append(genPackage.getResourceClassName());
180     stringBuffer.append(TEXT_45);
181     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.xmi.XMLResource"));
182     stringBuffer.append(TEXT_46);
183     stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.xmi.XMLResource"));
184     stringBuffer.append(TEXT_47);
185     } else {
186     stringBuffer.append(TEXT_48);
187     stringBuffer.append(genPackage.getResourceClassName());
188     stringBuffer.append(TEXT_49);
189     }
190     stringBuffer.append(TEXT_50);
191     //ResourceFactoryClass/createResource.override.javajetinc
192
stringBuffer.append(TEXT_51);
193     stringBuffer.append(genPackage.getResourceFactoryClassName());
194     genModel.emitSortedImports();
195     stringBuffer.append(TEXT_52);
196     return stringBuffer.toString();
197   }
198 }
199
Popular Tags