1 17 package org.eclipse.emf.ecore.xmi.impl; 18 19 20 import org.eclipse.emf.common.util.URI; 21 import org.eclipse.emf.ecore.EcorePackage; 22 import org.eclipse.emf.ecore.resource.Resource; 23 import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; 24 import org.eclipse.emf.ecore.xmi.XMIResource; 25 import org.eclipse.emf.ecore.xmi.XMLResource; 26 27 28 public class EMOFResourceFactoryImpl extends ResourceFactoryImpl 29 { 30 protected EMOFExtendedMetaData extendedMetaData; 31 32 public EMOFResourceFactoryImpl() 33 { 34 super(); 35 36 XMLResource.XMLMap xmlMap = new XMLMapImpl(); 37 38 xmlMap.add(EcorePackage.eINSTANCE.getEFactory(), createXMLInfo("Factory")); 39 xmlMap.add(EcorePackage.eINSTANCE.getEPackage(), createXMLInfo("Package")); 40 xmlMap.add(EcorePackage.eINSTANCE.getEAttribute(), createXMLInfo("Property")); 41 xmlMap.add(EcorePackage.eINSTANCE.getEReference(), createXMLInfo("Property")); 42 xmlMap.add(EcorePackage.eINSTANCE.getEParameter(), createXMLInfo("Parameter")); 43 xmlMap.add(EcorePackage.eINSTANCE.getEOperation(), createXMLInfo("Operation")); 44 xmlMap.add(EcorePackage.eINSTANCE.getEEnumLiteral(), createXMLInfo("EnumerationLiteral")); 45 xmlMap.add(EcorePackage.eINSTANCE.getEDataType(), createXMLInfo("PrimitiveType")); 46 xmlMap.add(EcorePackage.eINSTANCE.getEEnum(), createXMLInfo("Enumeration")); 47 xmlMap.add(EcorePackage.eINSTANCE.getEClass(), createXMLInfo("Class")); 48 49 xmlMap.add(EcorePackage.eINSTANCE.getEFactory_EPackage(), createXMLInfo("package")); 50 51 xmlMap.add(EcorePackage.eINSTANCE.getEPackage_NsURI(), createXMLInfo("uri")); 52 xmlMap.add(EcorePackage.eINSTANCE.getEPackage_ESubpackages(), createXMLInfo("nestedPackage")); 53 xmlMap.add(EcorePackage.eINSTANCE.getEPackage_ESuperPackage(), createXMLInfo("nestingPackage")); 54 xmlMap.add(EcorePackage.eINSTANCE.getEPackage_EClassifiers(), createXMLInfo("ownedType")); 55 xmlMap.add(EcorePackage.eINSTANCE.getEPackage_NsPrefix(), createXMLInfo()); 57 xmlMap.add(EcorePackage.eINSTANCE.getETypedElement_EType(), createXMLInfo("type")); 58 xmlMap.add(EcorePackage.eINSTANCE.getETypedElement_Ordered(), createXMLInfo("isOrdered")); 59 xmlMap.add(EcorePackage.eINSTANCE.getETypedElement_Unique(), createXMLInfo("isUnique")); 60 xmlMap.add(EcorePackage.eINSTANCE.getETypedElement_LowerBound(), createXMLInfo("lower")); 61 xmlMap.add(EcorePackage.eINSTANCE.getETypedElement_UpperBound(), createXMLInfo("upper")); 62 63 xmlMap.add(EcorePackage.eINSTANCE.getEStructuralFeature_Changeable(), createXMLInfo("isReadOnly")); xmlMap.add(EcorePackage.eINSTANCE.getEStructuralFeature_DefaultValueLiteral(), createXMLInfo("default")); 65 xmlMap.add(EcorePackage.eINSTANCE.getEStructuralFeature_Volatile(), createXMLInfo()); xmlMap.add(EcorePackage.eINSTANCE.getEStructuralFeature_Unsettable(), createXMLInfo()); xmlMap.add(EcorePackage.eINSTANCE.getEStructuralFeature_Transient(), createXMLInfo()); xmlMap.add(EcorePackage.eINSTANCE.getEStructuralFeature_Derived(), createXMLInfo("isDerived")); 69 70 xmlMap.add(EcorePackage.eINSTANCE.getEAttribute_ID(), createXMLInfo("isID")); 71 72 xmlMap.add(EcorePackage.eINSTANCE.getEReference_Containment(), createXMLInfo("isComposite")); 73 xmlMap.add(EcorePackage.eINSTANCE.getEReference_EOpposite(), createXMLInfo("opposite")); 74 xmlMap.add(EcorePackage.eINSTANCE.getEReference_ResolveProxies(), createXMLInfo()); 76 xmlMap.add(EcorePackage.eINSTANCE.getEEnumLiteral_Value(), createXMLInfo()); 78 xmlMap.add(EcorePackage.eINSTANCE.getEOperation_EParameters(), createXMLInfo("ownedParameter")); 79 xmlMap.add(EcorePackage.eINSTANCE.getEOperation_EExceptions(), createXMLInfo("raisedException")); 80 81 xmlMap.add(EcorePackage.eINSTANCE.getEClassifier_InstanceClassName(), createXMLInfo()); 83 xmlMap.add(EcorePackage.eINSTANCE.getEDataType_Serializable(), createXMLInfo()); 85 xmlMap.add(EcorePackage.eINSTANCE.getEEnum_ELiterals(), createXMLInfo("ownedLiteral")); 86 87 xmlMap.add(EcorePackage.eINSTANCE.getEClass_Abstract(), createXMLInfo("isAbstract")); 88 xmlMap.add(EcorePackage.eINSTANCE.getEClass_EStructuralFeatures(), createXMLInfo("ownedAttribute")); xmlMap.add(EcorePackage.eINSTANCE.getEClass_EOperations(), createXMLInfo("ownedOperation")); 90 xmlMap.add(EcorePackage.eINSTANCE.getEClass_ESuperTypes(), createXMLInfo("superClass")); 91 xmlMap.add(EcorePackage.eINSTANCE.getEClass_Interface(), createXMLInfo()); 93 extendedMetaData = new EMOFExtendedMetaData(xmlMap); 94 } 95 96 public Resource createResource(URI uri) 97 { 98 EMOFResourceImpl result = new EMOFResourceImpl(uri); 99 100 result.setEncoding("UTF-8"); 101 102 result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData); 103 result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData); 104 105 result.getDefaultSaveOptions().put(XMLResource.OPTION_LINE_WIDTH, new Integer (80)); 106 result.getDefaultSaveOptions().put(XMIResource.OPTION_USE_XMI_TYPE, Boolean.TRUE); 107 108 return result; 109 } 110 111 protected XMLResource.XMLInfo createXMLInfo(String name) 112 { 113 XMLResource.XMLInfo info = new XMLInfoImpl(); 114 info.setName(name); 115 return info; 116 } 117 118 protected XMLResource.XMLInfo createXMLInfo() 119 { 120 XMLResource.XMLInfo info = new XMLInfoImpl(); 121 info.setXMLRepresentation(XMLResource.XMLInfo.ELEMENT); return info; 123 } 124 } 125 | Popular Tags |