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 PackageInterface 7 { 8 protected static String nl; 9 public static synchronized PackageInterface create(String lineSeparator) 10 { 11 nl = lineSeparator; 12 PackageInterface result = new PackageInterface(); 13 nl = null; 14 return result; 15 } 16 17 protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; 18 protected final String TEXT_1 = ""; 19 protected final String TEXT_2 = "/**" + NL + " * <copyright>" + NL + " * </copyright>" + NL + " *" + NL + " * "; 20 protected final String TEXT_3 = "Id"; 21 protected final String TEXT_4 = NL + " */" + NL + "package "; 22 protected final String TEXT_5 = ";" + NL; 23 protected final String TEXT_6 = NL + NL + "/**" + NL + " * <!-- begin-user-doc -->" + NL + " * The <b>Package</b> for the model." + NL + " * It contains accessors for the meta objects to represent" + NL + " * <ul>" + NL + " * <li>each class,</li>" + NL + " * <li>each feature of each class,</li>" + NL + " * <li>each enum,</li>" + NL + " * <li>and each data type</li>" + NL + " * </ul>" + NL + " * <!-- end-user-doc -->"; 24 protected final String TEXT_7 = NL + " * <!-- begin-model-doc -->" + NL + " * "; 25 protected final String TEXT_8 = NL + " * <!-- end-model-doc -->"; 26 protected final String TEXT_9 = NL + " * @see "; 27 protected final String TEXT_10 = NL + " * @model "; 28 protected final String TEXT_11 = NL + " * "; 29 protected final String TEXT_12 = NL + " * @model"; 30 protected final String TEXT_13 = NL + " * @generated" + NL + " */" + NL + "public interface "; 31 protected final String TEXT_14 = " extends "; 32 protected final String TEXT_15 = NL + "{"; 33 protected final String TEXT_16 = NL + "\t/**" + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\t"; 34 protected final String TEXT_17 = " copyright = \""; 35 protected final String TEXT_18 = "\";"; 36 protected final String TEXT_19 = NL; 37 protected final String TEXT_20 = NL + "\t/**" + NL + "\t * The package name." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\t"; 38 protected final String TEXT_21 = " eNAME = \""; 39 protected final String TEXT_22 = "\";"; 40 protected final String TEXT_23 = NL + NL + "\t/**" + NL + "\t * The package namespace URI." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\t"; 41 protected final String TEXT_24 = " eNS_URI = \""; 42 protected final String TEXT_25 = "\";"; 43 protected final String TEXT_26 = NL + NL + "\t/**" + NL + "\t * The package namespace name." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\t"; 44 protected final String TEXT_27 = " eNS_PREFIX = \""; 45 protected final String TEXT_28 = "\";"; 46 protected final String TEXT_29 = NL + NL + "\t/**" + NL + "\t * The singleton instance of the package." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t */" + NL + "\t"; 47 protected final String TEXT_30 = " eINSTANCE = "; 48 protected final String TEXT_31 = ".init();" + NL; 49 protected final String TEXT_32 = NL + "\t/**"; 50 protected final String TEXT_33 = NL + "\t * The meta object id for the '{@link "; 51 protected final String TEXT_34 = " <em>"; 52 protected final String TEXT_35 = "</em>}' class." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @see "; 53 protected final String TEXT_36 = NL + "\t * The meta object id for the '{@link "; 54 protected final String TEXT_37 = " <em>"; 55 protected final String TEXT_38 = "</em>}' class." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @see "; 56 protected final String TEXT_39 = NL + "\t * The meta object id for the '{@link "; 57 protected final String TEXT_40 = " <em>"; 58 protected final String TEXT_41 = "</em>}' enum." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @see "; 59 protected final String TEXT_42 = NL + "\t * The meta object id for the '<em>"; 60 protected final String TEXT_43 = "</em>' data type." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->"; 61 protected final String TEXT_44 = NL + "\t * @see "; 62 protected final String TEXT_45 = NL + "\t * @see "; 63 protected final String TEXT_46 = "#get"; 64 protected final String TEXT_47 = "()" + NL + "\t * @generated" + NL + "\t */" + NL + "\tint "; 65 protected final String TEXT_48 = " = "; 66 protected final String TEXT_49 = ";" + NL; 67 protected final String TEXT_50 = NL + "\t/**" + NL + "\t * The feature id for the '<em><b>"; 68 protected final String TEXT_51 = "</b></em>' "; 69 protected final String TEXT_52 = "." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t * @ordered" + NL + "\t */" + NL + "\tint "; 70 protected final String TEXT_53 = " = "; 71 protected final String TEXT_54 = ";" + NL; 72 protected final String TEXT_55 = NL + "\t/**" + NL + "\t * The number of structural features of the the '<em>"; 73 protected final String TEXT_56 = "</em>' class." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @generated" + NL + "\t * @ordered" + NL + "\t */" + NL + "\tint "; 74 protected final String TEXT_57 = " = "; 75 protected final String TEXT_58 = ";" + NL; 76 protected final String TEXT_59 = NL; 77 protected final String TEXT_60 = NL + "\t/**"; 78 protected final String TEXT_61 = NL + "\t * Returns the meta object for class '{@link "; 79 protected final String TEXT_62 = " <em>"; 80 protected final String TEXT_63 = "</em>}'." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @return the meta object for class '<em>"; 81 protected final String TEXT_64 = "</em>'." + NL + "\t * @see "; 82 protected final String TEXT_65 = NL + "\t * @model "; 83 protected final String TEXT_66 = NL + "\t * "; 84 protected final String TEXT_67 = NL + "\t * @model"; 85 protected final String TEXT_68 = NL + "\t * Returns the meta object for enum '{@link "; 86 protected final String TEXT_69 = " <em>"; 87 protected final String TEXT_70 = "</em>}'." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @return the meta object for enum '<em>"; 88 protected final String TEXT_71 = "</em>'." + NL + "\t * @see "; 89 protected final String TEXT_72 = NL + "\t * Returns the meta object for data type '<em>"; 90 protected final String TEXT_73 = "</em>'."; 91 protected final String TEXT_74 = NL + "\t * Returns the meta object for data type '{@link "; 92 protected final String TEXT_75 = " <em>"; 93 protected final String TEXT_76 = "</em>}'."; 94 protected final String TEXT_77 = NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @return the meta object for data type '<em>"; 95 protected final String TEXT_78 = "</em>'."; 96 protected final String TEXT_79 = NL + "\t * @see "; 97 protected final String TEXT_80 = NL + "\t * @model "; 98 protected final String TEXT_81 = NL + "\t * "; 99 protected final String TEXT_82 = NL + "\t * @model"; 100 protected final String TEXT_83 = NL + "\t * @generated" + NL + "\t */" + NL + "\t"; 101 protected final String TEXT_84 = " get"; 102 protected final String TEXT_85 = "();" + NL; 103 protected final String TEXT_86 = NL + "\t/**" + NL + "\t * Returns the meta object for the "; 104 protected final String TEXT_87 = " '{@link "; 105 protected final String TEXT_88 = "#"; 106 protected final String TEXT_89 = " <em>"; 107 protected final String TEXT_90 = "</em>}'." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @return the meta object for the "; 108 protected final String TEXT_91 = " '<em>"; 109 protected final String TEXT_92 = "</em>'." + NL + "\t * @see "; 110 protected final String TEXT_93 = "#"; 111 protected final String TEXT_94 = "()"; 112 protected final String TEXT_95 = NL + "\t * @see #get"; 113 protected final String TEXT_96 = "()" + NL + "\t * @generated" + NL + "\t */" + NL + "\t"; 114 protected final String TEXT_97 = " get"; 115 protected final String TEXT_98 = "();" + NL; 116 protected final String TEXT_99 = NL + "\t/**" + NL + "\t * Returns the factory that creates the instances of the model." + NL + "\t * <!-- begin-user-doc -->" + NL + "\t * <!-- end-user-doc -->" + NL + "\t * @return the factory that creates the instances of the model." + NL + "\t * @generated" + NL + "\t */" + NL + "\t"; 117 protected final String TEXT_100 = " get"; 118 protected final String TEXT_101 = "();" + NL + "" + NL + "} //"; 119 protected final String TEXT_102 = NL; 120 121 public String generate(Object argument) 122 { 123 StringBuffer stringBuffer = new StringBuffer (); 124 125 139 140 GenPackage genPackage = (GenPackage)argument; GenModel genModel=genPackage.getGenModel(); 141 stringBuffer.append(TEXT_1); 142 stringBuffer.append(TEXT_2); 143 stringBuffer.append("$"); 144 stringBuffer.append(TEXT_3); 145 stringBuffer.append("$"); 146 stringBuffer.append(TEXT_4); 147 stringBuffer.append(genPackage.getInterfacePackageName()); 148 stringBuffer.append(TEXT_5); 149 genModel.markImportLocation(stringBuffer, genPackage); 150 stringBuffer.append(TEXT_6); 151 if (genPackage.hasDocumentation()) { 152 stringBuffer.append(TEXT_7); 153 stringBuffer.append(genPackage.getDocumentation(genModel.getIndentation(stringBuffer))); 154 stringBuffer.append(TEXT_8); 155 } 156 stringBuffer.append(TEXT_9); 157 stringBuffer.append(genPackage.getQualifiedFactoryInterfaceName()); 158 {boolean first = true; for (StringTokenizer stringTokenizer = new StringTokenizer(genPackage.getModelInfo(), "\n\r"); stringTokenizer.hasMoreTokens(); ) { String modelInfo = stringTokenizer.nextToken(); if (first) { first = false; 159 stringBuffer.append(TEXT_10); 160 stringBuffer.append(modelInfo); 161 } else { 162 stringBuffer.append(TEXT_11); 163 stringBuffer.append(modelInfo); 164 }} if (first) { 165 stringBuffer.append(TEXT_12); 166 }} 167 stringBuffer.append(TEXT_13); 168 stringBuffer.append(genPackage.getPackageInterfaceName()); 169 stringBuffer.append(TEXT_14); 170 stringBuffer.append(genModel.getImportedName("org.eclipse.emf.ecore.EPackage")); 171 stringBuffer.append(TEXT_15); 172 if (genModel.getCopyrightText() != null) { 173 stringBuffer.append(TEXT_16); 174 stringBuffer.append(genModel.getImportedName("java.lang.String")); 175 stringBuffer.append(TEXT_17); 176 stringBuffer.append(genModel.getCopyrightText()); 177 stringBuffer.append(TEXT_18); 178 stringBuffer.append(genModel.getNonNLS()); 179 stringBuffer.append(TEXT_19); 180 } 181 stringBuffer.append(TEXT_20); 182 stringBuffer.append(genModel.getImportedName("java.lang.String")); 183 stringBuffer.append(TEXT_21); 184 stringBuffer.append(genPackage.getPackageName()); 185 stringBuffer.append(TEXT_22); 186 stringBuffer.append(genModel.getNonNLS()); 187 stringBuffer.append(TEXT_23); 188 stringBuffer.append(genModel.getImportedName("java.lang.String")); 189 stringBuffer.append(TEXT_24); 190 stringBuffer.append(genPackage.getNSURI()); 191 stringBuffer.append(TEXT_25); 192 stringBuffer.append(genModel.getNonNLS()); 193 stringBuffer.append(TEXT_26); 194 stringBuffer.append(genModel.getImportedName("java.lang.String")); 195 stringBuffer.append(TEXT_27); 196 stringBuffer.append(genPackage.getNSName()); 197 stringBuffer.append(TEXT_28); 198 stringBuffer.append(genModel.getNonNLS()); 199 stringBuffer.append(TEXT_29); 200 stringBuffer.append(genPackage.getPackageInterfaceName()); 201 stringBuffer.append(TEXT_30); 202 stringBuffer.append(genPackage.getQualifiedPackageClassName()); 203 stringBuffer.append(TEXT_31); 204 for (Iterator i=genPackage.getOrderedGenClassifiers().iterator(); i.hasNext();) { GenClassifier genClassifier = (GenClassifier)i.next(); 205 stringBuffer.append(TEXT_32); 206 if (genClassifier instanceof GenClass) { GenClass genClass = (GenClass)genClassifier; 207 if (!genClass.isInterface()) { 208 stringBuffer.append(TEXT_33); 209 stringBuffer.append(genClass.getQualifiedClassName()); 210 stringBuffer.append(TEXT_34); 211 stringBuffer.append(genClass.getFormattedName()); 212 stringBuffer.append(TEXT_35); 213 stringBuffer.append(genClass.getQualifiedClassName()); 214 } else { 215 stringBuffer.append(TEXT_36); 216 stringBuffer.append(genClass.getQualifiedInterfaceName()); 217 stringBuffer.append(TEXT_37); 218 stringBuffer.append(genClass.getFormattedName()); 219 stringBuffer.append(TEXT_38); 220 stringBuffer.append(genClass.getQualifiedInterfaceName()); 221 } 222 } else if (genClassifier instanceof GenEnum) { GenEnum genEnum = (GenEnum)genClassifier; 223 stringBuffer.append(TEXT_39); 224 stringBuffer.append(genEnum.getQualifiedName()); 225 stringBuffer.append(TEXT_40); 226 stringBuffer.append(genEnum.getFormattedName()); 227 stringBuffer.append(TEXT_41); 228 stringBuffer.append(genEnum.getQualifiedName()); 229 } else if (genClassifier instanceof GenDataType) { GenDataType genDataType = (GenDataType)genClassifier; 230 stringBuffer.append(TEXT_42); 231 stringBuffer.append(genDataType.getFormattedName()); 232 stringBuffer.append(TEXT_43); 233 if (!genDataType.isPrimitiveType() && !genDataType.isArrayType()) { 234 stringBuffer.append(TEXT_44); 235 stringBuffer.append(genDataType.getQualifiedInstanceClassName()); 236 } 237 } 238 stringBuffer.append(TEXT_45); 239 stringBuffer.append(genPackage.getQualifiedPackageClassName()); 240 stringBuffer.append(TEXT_46); 241 stringBuffer.append(genClassifier.getClassifierAccessorName()); 242 stringBuffer.append(TEXT_47); 243 stringBuffer.append(genPackage.getClassifierID(genClassifier)); 244 stringBuffer.append(TEXT_48); 245 stringBuffer.append(genPackage.getClassifierValue(genClassifier)); 246 stringBuffer.append(TEXT_49); 247 if (genClassifier instanceof GenClass) { GenClass genClass = (GenClass)genClassifier; 248 for (Iterator f=genClass.getAllGenFeatures().iterator(); f.hasNext();) { GenFeature genFeature = (GenFeature)f.next(); 249 stringBuffer.append(TEXT_50); 250 stringBuffer.append(genFeature.getFormattedName()); 251 stringBuffer.append(TEXT_51); 252 stringBuffer.append(genFeature.getFeatureKind()); 253 stringBuffer.append(TEXT_52); 254 stringBuffer.append(genClass.getFeatureID(genFeature)); 255 stringBuffer.append(TEXT_53); 256 stringBuffer.append(genClass.getFeatureValue(genFeature)); 257 stringBuffer.append(TEXT_54); 258 } 259 stringBuffer.append(TEXT_55); 260 stringBuffer.append(genClass.getFormattedName()); 261 stringBuffer.append(TEXT_56); 262 stringBuffer.append(genClass.getFeatureCountID()); 263 stringBuffer.append(TEXT_57); 264 stringBuffer.append(genClass.getFeatureCountValue()); 265 stringBuffer.append(TEXT_58); 266 } 267 } 268 stringBuffer.append(TEXT_59); 269 for (Iterator i=genPackage.getGenClassifiers().iterator(); i.hasNext();) { GenClassifier genClassifier = (GenClassifier)i.next(); 270 stringBuffer.append(TEXT_60); 271 if (genClassifier instanceof GenClass) { GenClass genClass = (GenClass)genClassifier; 272 stringBuffer.append(TEXT_61); 273 stringBuffer.append(genClass.getQualifiedInterfaceName()); 274 stringBuffer.append(TEXT_62); 275 stringBuffer.append(genClass.getFormattedName()); 276 stringBuffer.append(TEXT_63); 277 stringBuffer.append(genClass.getFormattedName()); 278 stringBuffer.append(TEXT_64); 279 stringBuffer.append(genClass.getQualifiedInterfaceName()); 280 if (genClass.isExternalInterface()) { boolean first = true; for (StringTokenizer stringTokenizer = new StringTokenizer(genClass.getModelInfo(), "\n\r"); stringTokenizer.hasMoreTokens(); ) { String modelInfo = stringTokenizer.nextToken(); if (first) { first = false; 281 stringBuffer.append(TEXT_65); 282 stringBuffer.append(modelInfo); 283 } else { 284 stringBuffer.append(TEXT_66); 285 stringBuffer.append(modelInfo); 286 }} if (first) { 287 stringBuffer.append(TEXT_67); 288 }} 289 } else if (genClassifier instanceof GenEnum) { GenEnum genEnum = (GenEnum)genClassifier; 290 stringBuffer.append(TEXT_68); 291 stringBuffer.append(genEnum.getQualifiedName()); 292 stringBuffer.append(TEXT_69); 293 stringBuffer.append(genEnum.getFormattedName()); 294 stringBuffer.append(TEXT_70); 295 stringBuffer.append(genEnum.getFormattedName()); 296 stringBuffer.append(TEXT_71); 297 stringBuffer.append(genEnum.getQualifiedName()); 298 } else if (genClassifier instanceof GenDataType) { GenDataType genDataType = (GenDataType)genClassifier; 299 if (genDataType.isPrimitiveType() || genDataType.isArrayType()) { 300 stringBuffer.append(TEXT_72); 301 stringBuffer.append(genDataType.getFormattedName()); 302 stringBuffer.append(TEXT_73); 303 } else { 304 stringBuffer.append(TEXT_74); 305 stringBuffer.append(genDataType.getQualifiedInstanceClassName()); 306 stringBuffer.append(TEXT_75); 307 stringBuffer.append(genDataType.getFormattedName()); 308 stringBuffer.append(TEXT_76); 309 } 310 stringBuffer.append(TEXT_77); 311 stringBuffer.append(genDataType.getFormattedName()); 312 stringBuffer.append(TEXT_78); 313 if (!genDataType.isPrimitiveType() && !genDataType.isArrayType()) { 314 stringBuffer.append(TEXT_79); 315 stringBuffer.append(genDataType.getQualifiedInstanceClassName()); 316 } 317 {boolean first = true; for (StringTokenizer stringTokenizer = new StringTokenizer(genDataType.getModelInfo(), "\n\r"); stringTokenizer.hasMoreTokens(); ) { String modelInfo = stringTokenizer.nextToken(); if (first) { first = false; 318 stringBuffer.append(TEXT_80); 319 stringBuffer.append(modelInfo); 320 } else { 321 stringBuffer.append(TEXT_81); 322 stringBuffer.append(modelInfo); 323 }} if (first) { 324 stringBuffer.append(TEXT_82); 325 }} 326 } 327 stringBuffer.append(TEXT_83); 328 stringBuffer.append(genClassifier.getImportedMetaType()); 329 stringBuffer.append(TEXT_84); 330 stringBuffer.append(genClassifier.getClassifierAccessorName()); 331 stringBuffer.append(TEXT_85); 332 if (genClassifier instanceof GenClass) { GenClass genClass = (GenClass)genClassifier; 333 for (Iterator f=genClass.getGenFeatures().iterator(); f.hasNext();) { GenFeature genFeature = (GenFeature)f.next(); 334 stringBuffer.append(TEXT_86); 335 stringBuffer.append(genFeature.getFeatureKind()); 336 stringBuffer.append(TEXT_87); 337 stringBuffer.append(genClass.getQualifiedInterfaceName()); 338 if (!genClass.isMapEntry() && !genFeature.isSuppressedGetVisibility()) { 339 stringBuffer.append(TEXT_88); 340 stringBuffer.append(genFeature.getGetAccessor()); 341 } 342 stringBuffer.append(TEXT_89); 343 stringBuffer.append(genFeature.getFormattedName()); 344 stringBuffer.append(TEXT_90); 345 stringBuffer.append(genFeature.getFeatureKind()); 346 stringBuffer.append(TEXT_91); 347 stringBuffer.append(genFeature.getFormattedName()); 348 stringBuffer.append(TEXT_92); 349 stringBuffer.append(genClass.getQualifiedInterfaceName()); 350 if (!genClass.isMapEntry() && !genFeature.isSuppressedGetVisibility()) { 351 stringBuffer.append(TEXT_93); 352 stringBuffer.append(genFeature.getGetAccessor()); 353 stringBuffer.append(TEXT_94); 354 } 355 stringBuffer.append(TEXT_95); 356 stringBuffer.append(genClass.getClassifierAccessorName()); 357 stringBuffer.append(TEXT_96); 358 stringBuffer.append(genFeature.getImportedMetaType()); 359 stringBuffer.append(TEXT_97); 360 stringBuffer.append(genFeature.getFeatureAccessorName()); 361 stringBuffer.append(TEXT_98); 362 } 363 } 364 } 365 stringBuffer.append(TEXT_99); 366 stringBuffer.append(genPackage.getFactoryInterfaceName()); 367 stringBuffer.append(TEXT_100); 368 stringBuffer.append(genPackage.getFactoryInterfaceName()); 369 stringBuffer.append(TEXT_101); 370 stringBuffer.append(genPackage.getPackageInterfaceName()); 371 genModel.emitSortedImports(); 372 stringBuffer.append(TEXT_102); 373 return stringBuffer.toString(); 374 } 375 } 376 | Popular Tags |