1 17 package org.eclipse.emf.ecore.change.impl; 18 19 20 import java.util.Map ; 21 22 import org.eclipse.emf.common.util.EList; 23 import org.eclipse.emf.ecore.EClass; 24 import org.eclipse.emf.ecore.EDataType; 25 import org.eclipse.emf.ecore.EObject; 26 import org.eclipse.emf.ecore.EStructuralFeature; 27 import org.eclipse.emf.ecore.change.*; 28 import org.eclipse.emf.ecore.impl.EFactoryImpl; 29 import org.eclipse.emf.ecore.resource.Resource; 30 31 32 38 public class ChangeFactoryImpl extends EFactoryImpl implements ChangeFactory 39 { 40 46 public ChangeFactoryImpl() 47 { 48 super(); 49 } 50 51 56 public EObject create(EClass eClass) 57 { 58 switch (eClass.getClassifierID()) 59 { 60 case ChangePackage.CHANGE_DESCRIPTION: return createChangeDescription(); 61 case ChangePackage.EOBJECT_TO_CHANGES_MAP_ENTRY: return (EObject)createEObjectToChangesMapEntry(); 62 case ChangePackage.FEATURE_CHANGE: return createFeatureChange(); 63 case ChangePackage.LIST_CHANGE: return createListChange(); 64 case ChangePackage.RESOURCE_CHANGE: return createResourceChange(); 65 case ChangePackage.FEATURE_MAP_ENTRY: return createFeatureMapEntry(); 66 default: 67 throw new IllegalArgumentException ("The class '" + eClass.getName() + "' is not a valid classifier"); 68 } 69 } 70 71 76 public Object createFromString(EDataType eDataType, String initialValue) 77 { 78 switch (eDataType.getClassifierID()) 79 { 80 case ChangePackage.CHANGE_KIND: 81 { 82 ChangeKind result = ChangeKind.get(initialValue); 83 if (result == null) throw new IllegalArgumentException ("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); 84 return result; 85 } 86 default: 87 throw new IllegalArgumentException ("The datatype '" + eDataType.getName() + "' is not a valid classifier"); 88 } 89 } 90 91 96 public String convertToString(EDataType eDataType, Object instanceValue) 97 { 98 switch (eDataType.getClassifierID()) 99 { 100 case ChangePackage.CHANGE_KIND: 101 return instanceValue == null ? null : instanceValue.toString(); 102 default: 103 throw new IllegalArgumentException ("The datatype '" + eDataType.getName() + "' is not a valid classifier"); 104 } 105 } 106 107 112 public ChangeDescription createChangeDescription() 113 { 114 ChangeDescriptionImpl changeDescription = new ChangeDescriptionImpl(); 115 return changeDescription; 116 } 117 118 123 public Map.Entry createEObjectToChangesMapEntry() 124 { 125 EObjectToChangesMapEntryImpl eObjectToChangesMapEntry = new EObjectToChangesMapEntryImpl(); 126 return eObjectToChangesMapEntry; 127 } 128 129 134 public FeatureChange createFeatureChange() 135 { 136 FeatureChangeImpl featureChange = new FeatureChangeImpl(); 137 return featureChange; 138 } 139 140 public FeatureChange createFeatureChange(EStructuralFeature feature, Object oldValue, boolean oldIsSet) 141 { 142 FeatureChangeImpl featureChange = new FeatureChangeImpl(feature, oldValue, oldIsSet); 143 return featureChange; 144 } 145 146 151 public ListChange createListChange() 152 { 153 ListChangeImpl listChange = new ListChangeImpl(); 154 return listChange; 155 } 156 157 162 public ResourceChange createResourceChange() 163 { 164 ResourceChangeImpl resourceChange = new ResourceChangeImpl(); 165 return resourceChange; 166 } 167 168 public ResourceChange createResourceChange(Resource resource, EList oldValue) 169 { 170 ResourceChangeImpl resourceChange = new ResourceChangeImpl(resource, oldValue); 171 return resourceChange; 172 } 173 174 179 public FeatureMapEntry createFeatureMapEntry() 180 { 181 FeatureMapEntryImpl featureMapEntry = new FeatureMapEntryImpl(); 182 return featureMapEntry; 183 } 184 185 public FeatureMapEntry createFeatureMapEntry(EStructuralFeature feature, Object value) 186 { 187 FeatureMapEntryImpl featureMapEntry = new FeatureMapEntryImpl(feature, value); 188 return featureMapEntry; 189 } 190 191 196 public ChangePackage getChangePackage() 197 { 198 return (ChangePackage)getEPackage(); 199 } 200 201 207 public static ChangePackage getPackage() 208 { 209 return ChangePackage.eINSTANCE; 210 } 211 212 public Map.Entry createEObjectToChangesMapEntry(EObject eObject) 213 { 214 EObjectToChangesMapEntryImpl eObjectToChangesMapEntry = new EObjectToChangesMapEntryImpl(); 215 eObjectToChangesMapEntry.setKey(eObject); 216 return eObjectToChangesMapEntry; 217 } 218 219 } | Popular Tags |