1 17 package org.eclipse.emf.ecore.xml.namespace.impl; 18 19 import org.eclipse.emf.ecore.EClass; 20 import org.eclipse.emf.ecore.EDataType; 21 import org.eclipse.emf.ecore.EObject; 22 import org.eclipse.emf.ecore.impl.EFactoryImpl; 23 import org.eclipse.emf.ecore.xml.namespace.*; 24 25 26 32 public class XMLNamespaceFactoryImpl extends EFactoryImpl implements XMLNamespaceFactory 33 { 34 40 public XMLNamespaceFactoryImpl() 41 { 42 super(); 43 } 44 45 50 public EObject create(EClass eClass) 51 { 52 switch (eClass.getClassifierID()) 53 { 54 case XMLNamespacePackage.XML_NAMESPACE_DOCUMENT_ROOT: return createXMLNamespaceDocumentRoot(); 55 default: 56 throw new IllegalArgumentException ("The class '" + eClass.getName() + "' is not a valid classifier"); 57 } 58 } 59 60 65 public Object createFromString(EDataType eDataType, String initialValue) 66 { 67 switch (eDataType.getClassifierID()) 68 { 69 case XMLNamespacePackage.SPACE_TYPE: 70 { 71 SpaceType result = SpaceType.get(initialValue); 72 if (result == null) throw new IllegalArgumentException ("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); 73 return result; 74 } 75 case XMLNamespacePackage.SPACE_TYPE_OBJECT: 76 return createSpaceTypeObjectFromString(eDataType, initialValue); 77 default: 78 throw new IllegalArgumentException ("The datatype '" + eDataType.getName() + "' is not a valid classifier"); 79 } 80 } 81 82 87 public String convertToString(EDataType eDataType, Object instanceValue) 88 { 89 switch (eDataType.getClassifierID()) 90 { 91 case XMLNamespacePackage.SPACE_TYPE: 92 return instanceValue == null ? null : instanceValue.toString(); 93 case XMLNamespacePackage.SPACE_TYPE_OBJECT: 94 return convertSpaceTypeObjectToString(eDataType, instanceValue); 95 default: 96 throw new IllegalArgumentException ("The datatype '" + eDataType.getName() + "' is not a valid classifier"); 97 } 98 } 99 100 105 public XMLNamespaceDocumentRoot createXMLNamespaceDocumentRoot() 106 { 107 XMLNamespaceDocumentRootImpl xmlNamespaceDocumentRoot = new XMLNamespaceDocumentRootImpl(); 108 return xmlNamespaceDocumentRoot; 109 } 110 111 116 public SpaceType createSpaceTypeObjectFromString(EDataType eDataType, String initialValue) 117 { 118 return (SpaceType)XMLNamespaceFactory.eINSTANCE.createFromString(XMLNamespacePackage.eINSTANCE.getSpaceType(), initialValue); 119 } 120 121 126 public String convertSpaceTypeObjectToString(EDataType eDataType, Object instanceValue) 127 { 128 return XMLNamespaceFactory.eINSTANCE.convertToString(XMLNamespacePackage.eINSTANCE.getSpaceType(), instanceValue); 129 } 130 131 136 public XMLNamespacePackage getXMLNamespacePackage() 137 { 138 return (XMLNamespacePackage)getEPackage(); 139 } 140 141 147 public static XMLNamespacePackage getPackage() 148 { 149 return XMLNamespacePackage.eINSTANCE; 150 } 151 152 } | Popular Tags |