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 nl; 8 public static synchronized ResourceFactoryClass create(String lineSeparator) 9 { 10 nl = lineSeparator; 11 ResourceFactoryClass result = new ResourceFactoryClass(); 12 nl = null; 13 return result; 14 } 15 16 protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; 17 protected final String TEXT_1 = ""; 18 protected final String TEXT_2 = "/**" + NL + " * <copyright>" + NL + " * </copyright>" + NL + " *" + NL + " * "; 19 protected final String TEXT_3 = "Id"; 20 protected final String TEXT_4 = NL + " */" + NL + "package "; 21 protected final String TEXT_5 = ";" + NL; 22 protected final String 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 TEXT_7 = NL + " * @generated" + NL + " */" + NL + "public class "; 24 protected final String TEXT_8 = " extends "; 25 protected final String TEXT_9 = NL + "{"; 26 protected final String 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 TEXT_11 = " copyright = \""; 28 protected final String TEXT_12 = "\";"; 29 protected final String TEXT_13 = NL; 30 protected final String 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 TEXT_15 = " extendedMetaData;" + NL; 32 protected final String 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 TEXT_17 = " xmlMap = new "; 34 protected final String TEXT_18 = "();" + NL; 35 protected final String 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 TEXT_20 = "()" + NL + "\t{" + NL + "\t\tsuper();"; 37 protected final String TEXT_21 = NL + "\t\textendedMetaData = new "; 38 protected final String TEXT_22 = "(new "; 39 protected final String TEXT_23 = "("; 40 protected final String TEXT_24 = ".Registry.INSTANCE));" + NL + "\t\textendedMetaData.putPackage(null, "; 41 protected final String TEXT_25 = ".eINSTANCE);"; 42 protected final String TEXT_26 = NL + "\t\txmlMap.setNoNamespacePackage("; 43 protected final String TEXT_27 = ".eINSTANCE);"; 44 protected final String 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 TEXT_29 = NL + "\t\t"; 46 protected final String TEXT_30 = " result = new "; 47 protected final String TEXT_31 = "(uri);" + NL + "\t\tresult.getDefaultSaveOptions().put("; 48 protected final String TEXT_32 = ".OPTION_EXTENDED_META_DATA, "; 49 protected final String TEXT_33 = "Boolean.TRUE"; 50 protected final String TEXT_34 = "extendedMetaData"; 51 protected final String TEXT_35 = ");" + NL + "\t\tresult.getDefaultLoadOptions().put("; 52 protected final String TEXT_36 = ".OPTION_EXTENDED_META_DATA, "; 53 protected final String TEXT_37 = "Boolean.TRUE"; 54 protected final String TEXT_38 = "extendedMetaData"; 55 protected final String TEXT_39 = ");" + NL + "" + NL + "\t\tresult.getDefaultSaveOptions().put("; 56 protected final String TEXT_40 = ".OPTION_SCHEMA_LOCATION, Boolean.TRUE);" + NL + "\t\tresult.getDefaultSaveOptions().put("; 57 protected final String TEXT_41 = ".OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);" + NL + "" + NL + "\t\tresult.getDefaultLoadOptions().put("; 58 protected final String TEXT_42 = ".OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);"; 59 protected final String TEXT_43 = NL + "\t\t"; 60 protected final String TEXT_44 = " result = new "; 61 protected final String TEXT_45 = "(uri);" + NL + "\t\tresult.getDefaultSaveOptions().put("; 62 protected final String TEXT_46 = ".OPTION_XML_MAP, xmlMap);" + NL + "\t\tresult.getDefaultLoadOptions().put("; 63 protected final String TEXT_47 = ".OPTION_XML_MAP, xmlMap);"; 64 protected final String TEXT_48 = NL + "\t\tResource result = new "; 65 protected final String TEXT_49 = "(uri);"; 66 protected final String TEXT_50 = NL + "\t\treturn result;"; 67 protected final String TEXT_51 = NL + "\t}" + NL + "" + NL + "} //"; 68 protected final String TEXT_52 = NL; 69 70 public String generate(Object argument) 71 { 72 StringBuffer stringBuffer = new StringBuffer (); 73 74 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 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 |