001    /**
002     * <copyright>
003     * </copyright>
004     *
005     * $Id$
006     */
007    package com.hammurapi.config.impl;
008    
009    import com.hammurapi.config.*;
010    import java.io.File;
011    import java.net.URL;
012    
013    import org.eclipse.emf.ecore.EClass;
014    import org.eclipse.emf.ecore.EDataType;
015    import org.eclipse.emf.ecore.EObject;
016    import org.eclipse.emf.ecore.EPackage;
017    import org.eclipse.emf.ecore.impl.EFactoryImpl;
018    import org.eclipse.emf.ecore.plugin.EcorePlugin;
019    
020    import com.hammurapi.config.Collection;
021    import com.hammurapi.config.ConfigFactory;
022    import com.hammurapi.config.ConfigPackage;
023    import com.hammurapi.config.Constructor;
024    import com.hammurapi.config.Map;
025    import com.hammurapi.config.MapEntry;
026    import com.hammurapi.config.MethodCall;
027    import com.hammurapi.config.NamedCollection;
028    import com.hammurapi.config.NamedMap;
029    import com.hammurapi.config.NamedObjectDefinition;
030    import com.hammurapi.config.NamedReference;
031    import com.hammurapi.config.NamedScript;
032    import com.hammurapi.config.Null;
033    import com.hammurapi.config.ObjectDefinition;
034    import com.hammurapi.config.Path;
035    import com.hammurapi.config.Profile;
036    import com.hammurapi.config.Reference;
037    import com.hammurapi.config.Script;
038    import com.hammurapi.config.Source;
039    import com.hammurapi.config.bootstrap.ConfigurationException;
040    import com.hammurapi.config.bootstrap.FactoryClosure;
041    import com.hammurapi.config.bootstrap.TokenExpander.TokenSource;
042    import com.hammurapi.config.runtime.FactoryConfig;
043    import com.hammurapi.config.runtime.InjectionConfig;
044    
045    /**
046     * <!-- begin-user-doc -->
047     * An implementation of the model <b>Factory</b>.
048     * <!-- end-user-doc -->
049     * @generated
050     */
051    public class ConfigFactoryImpl extends EFactoryImpl implements ConfigFactory {
052            /**
053             * Creates the default factory implementation.
054             * <!-- begin-user-doc -->
055             * <!-- end-user-doc -->
056             * @generated
057             */
058            public static ConfigFactory init() {
059                    try {
060                            ConfigFactory theConfigFactory = (ConfigFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.hammurapi.com/config"); 
061                            if (theConfigFactory != null) {
062                                    return theConfigFactory;
063                            }
064                    }
065                    catch (Exception exception) {
066                            EcorePlugin.INSTANCE.log(exception);
067                    }
068                    return new ConfigFactoryImpl();
069            }
070    
071            /**
072             * Creates an instance of the factory.
073             * <!-- begin-user-doc -->
074             * <!-- end-user-doc -->
075             * @generated
076             */
077            public ConfigFactoryImpl() {
078                    super();
079            }
080    
081            /**
082             * <!-- begin-user-doc -->
083             * <!-- end-user-doc -->
084             * @generated
085             */
086            @Override
087            public EObject create(EClass eClass) {
088                    switch (eClass.getClassifierID()) {
089                            case ConfigPackage.PATH: return createPath();
090                            case ConfigPackage.PROFILE: return createProfile();
091                            case ConfigPackage.OBJECT_DEFINITION: return createObjectDefinition();
092                            case ConfigPackage.COLLECTION: return createCollection();
093                            case ConfigPackage.CONSTRUCTOR: return createConstructor();
094                            case ConfigPackage.MAP: return createMap();
095                            case ConfigPackage.MAP_ENTRY: return createMapEntry();
096                            case ConfigPackage.REFERENCE: return createReference();
097                            case ConfigPackage.NULL: return createNull();
098                            case ConfigPackage.SCRIPT: return createScript();
099                            case ConfigPackage.NAMED_REFERENCE: return createNamedReference();
100                            case ConfigPackage.NAMED_OBJECT_DEFINITION: return createNamedObjectDefinition();
101                            case ConfigPackage.NAMED_COLLECTION: return createNamedCollection();
102                            case ConfigPackage.NAMED_MAP: return createNamedMap();
103                            case ConfigPackage.METHOD_CALL: return createMethodCall();
104                            case ConfigPackage.NAMED_SCRIPT: return createNamedScript();
105                            case ConfigPackage.SOURCE: return createSource();
106                            default:
107                                    throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
108                    }
109            }
110    
111            /**
112             * <!-- begin-user-doc -->
113             * <!-- end-user-doc -->
114             * @generated
115             */
116            @Override
117            public Object createFromString(EDataType eDataType, String initialValue) {
118                    switch (eDataType.getClassifierID()) {
119                            case ConfigPackage.EFACTORY_CLOSURE:
120                                    return createEFactoryClosureFromString(eDataType, initialValue);
121                            case ConfigPackage.ECONFIGURATION_EXCEPTION:
122                                    return createEConfigurationExceptionFromString(eDataType, initialValue);
123                            case ConfigPackage.EFACTORY_CONFIG:
124                                    return createEFactoryConfigFromString(eDataType, initialValue);
125                            case ConfigPackage.EURL:
126                                    return createEUrlFromString(eDataType, initialValue);
127                            case ConfigPackage.ECLASS_LOADER:
128                                    return createEClassLoaderFromString(eDataType, initialValue);
129                            case ConfigPackage.ETOKEN_SOURCE:
130                                    return createETokenSourceFromString(eDataType, initialValue);
131                            case ConfigPackage.FILE:
132                                    return createFileFromString(eDataType, initialValue);
133                            case ConfigPackage.INJECTION_CONFIG:
134                                    return createInjectionConfigFromString(eDataType, initialValue);
135                            default:
136                                    throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
137                    }
138            }
139    
140            /**
141             * <!-- begin-user-doc -->
142             * <!-- end-user-doc -->
143             * @generated
144             */
145            @Override
146            public String convertToString(EDataType eDataType, Object instanceValue) {
147                    switch (eDataType.getClassifierID()) {
148                            case ConfigPackage.EFACTORY_CLOSURE:
149                                    return convertEFactoryClosureToString(eDataType, instanceValue);
150                            case ConfigPackage.ECONFIGURATION_EXCEPTION:
151                                    return convertEConfigurationExceptionToString(eDataType, instanceValue);
152                            case ConfigPackage.EFACTORY_CONFIG:
153                                    return convertEFactoryConfigToString(eDataType, instanceValue);
154                            case ConfigPackage.EURL:
155                                    return convertEUrlToString(eDataType, instanceValue);
156                            case ConfigPackage.ECLASS_LOADER:
157                                    return convertEClassLoaderToString(eDataType, instanceValue);
158                            case ConfigPackage.ETOKEN_SOURCE:
159                                    return convertETokenSourceToString(eDataType, instanceValue);
160                            case ConfigPackage.FILE:
161                                    return convertFileToString(eDataType, instanceValue);
162                            case ConfigPackage.INJECTION_CONFIG:
163                                    return convertInjectionConfigToString(eDataType, instanceValue);
164                            default:
165                                    throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
166                    }
167            }
168    
169            /**
170             * <!-- begin-user-doc -->
171             * <!-- end-user-doc -->
172             * @generated
173             */
174            public Path createPath() {
175                    PathImpl path = new PathImpl();
176                    return path;
177            }
178    
179            /**
180             * <!-- begin-user-doc -->
181             * <!-- end-user-doc -->
182             * @generated
183             */
184            public Profile createProfile() {
185                    ProfileImpl profile = new ProfileImpl();
186                    return profile;
187            }
188    
189            /**
190             * <!-- begin-user-doc -->
191             * <!-- end-user-doc -->
192             * @generated
193             */
194            public ObjectDefinition createObjectDefinition() {
195                    ObjectDefinitionImpl objectDefinition = new ObjectDefinitionImpl();
196                    return objectDefinition;
197            }
198    
199            /**
200             * <!-- begin-user-doc -->
201             * <!-- end-user-doc -->
202             * @generated
203             */
204            public Collection createCollection() {
205                    CollectionImpl collection = new CollectionImpl();
206                    return collection;
207            }
208    
209            /**
210             * <!-- begin-user-doc -->
211             * <!-- end-user-doc -->
212             * @generated
213             */
214            public Constructor createConstructor() {
215                    ConstructorImpl constructor = new ConstructorImpl();
216                    return constructor;
217            }
218    
219            /**
220             * <!-- begin-user-doc -->
221             * <!-- end-user-doc -->
222             * @generated
223             */
224            public Map createMap() {
225                    MapImpl map = new MapImpl();
226                    return map;
227            }
228    
229            /**
230             * <!-- begin-user-doc -->
231             * <!-- end-user-doc -->
232             * @generated
233             */
234            public MapEntry createMapEntry() {
235                    MapEntryImpl mapEntry = new MapEntryImpl();
236                    return mapEntry;
237            }
238    
239            /**
240             * <!-- begin-user-doc -->
241             * <!-- end-user-doc -->
242             * @generated
243             */
244            public Reference createReference() {
245                    ReferenceImpl reference = new ReferenceImpl();
246                    return reference;
247            }
248    
249            /**
250             * <!-- begin-user-doc -->
251             * <!-- end-user-doc -->
252             * @generated
253             */
254            public Null createNull() {
255                    NullImpl null_ = new NullImpl();
256                    return null_;
257            }
258    
259            /**
260             * <!-- begin-user-doc -->
261             * <!-- end-user-doc -->
262             * @generated
263             */
264            public Script createScript() {
265                    ScriptImpl script = new ScriptImpl();
266                    return script;
267            }
268    
269            /**
270             * <!-- begin-user-doc -->
271             * <!-- end-user-doc -->
272             * @generated
273             */
274            public NamedReference createNamedReference() {
275                    NamedReferenceImpl namedReference = new NamedReferenceImpl();
276                    return namedReference;
277            }
278    
279            /**
280             * <!-- begin-user-doc -->
281             * <!-- end-user-doc -->
282             * @generated
283             */
284            public NamedObjectDefinition createNamedObjectDefinition() {
285                    NamedObjectDefinitionImpl namedObjectDefinition = new NamedObjectDefinitionImpl();
286                    return namedObjectDefinition;
287            }
288    
289            /**
290             * <!-- begin-user-doc -->
291             * <!-- end-user-doc -->
292             * @generated
293             */
294            public NamedCollection createNamedCollection() {
295                    NamedCollectionImpl namedCollection = new NamedCollectionImpl();
296                    return namedCollection;
297            }
298    
299            /**
300             * <!-- begin-user-doc -->
301             * <!-- end-user-doc -->
302             * @generated
303             */
304            public NamedMap createNamedMap() {
305                    NamedMapImpl namedMap = new NamedMapImpl();
306                    return namedMap;
307            }
308    
309            /**
310             * <!-- begin-user-doc -->
311             * <!-- end-user-doc -->
312             * @generated
313             */
314            public MethodCall createMethodCall() {
315                    MethodCallImpl methodCall = new MethodCallImpl();
316                    return methodCall;
317            }
318    
319            /**
320             * <!-- begin-user-doc -->
321             * <!-- end-user-doc -->
322             * @generated
323             */
324            public NamedScript createNamedScript() {
325                    NamedScriptImpl namedScript = new NamedScriptImpl();
326                    return namedScript;
327            }
328    
329            /**
330             * <!-- begin-user-doc -->
331             * <!-- end-user-doc -->
332             * @generated
333             */
334            public Source createSource() {
335                    SourceImpl source = new SourceImpl();
336                    return source;
337            }
338    
339            /**
340             * <!-- begin-user-doc -->
341             * <!-- end-user-doc -->
342             * @generated
343             */
344            public FactoryClosure<?> createEFactoryClosureFromString(EDataType eDataType, String initialValue) {
345                    return (FactoryClosure<?>)super.createFromString(initialValue);
346            }
347    
348            /**
349             * <!-- begin-user-doc -->
350             * <!-- end-user-doc -->
351             * @generated
352             */
353            public String convertEFactoryClosureToString(EDataType eDataType, Object instanceValue) {
354                    return super.convertToString(instanceValue);
355            }
356    
357            /**
358             * <!-- begin-user-doc -->
359             * <!-- end-user-doc -->
360             * @generated
361             */
362            public ConfigurationException createEConfigurationExceptionFromString(EDataType eDataType, String initialValue) {
363                    return (ConfigurationException)super.createFromString(eDataType, initialValue);
364            }
365    
366            /**
367             * <!-- begin-user-doc -->
368             * <!-- end-user-doc -->
369             * @generated
370             */
371            public String convertEConfigurationExceptionToString(EDataType eDataType, Object instanceValue) {
372                    return super.convertToString(eDataType, instanceValue);
373            }
374    
375            /**
376             * <!-- begin-user-doc -->
377             * <!-- end-user-doc -->
378             * @generated
379             */
380            public FactoryConfig createEFactoryConfigFromString(EDataType eDataType, String initialValue) {
381                    return (FactoryConfig)super.createFromString(eDataType, initialValue);
382            }
383    
384            /**
385             * <!-- begin-user-doc -->
386             * <!-- end-user-doc -->
387             * @generated
388             */
389            public String convertEFactoryConfigToString(EDataType eDataType, Object instanceValue) {
390                    return super.convertToString(eDataType, instanceValue);
391            }
392    
393            /**
394             * <!-- begin-user-doc -->
395             * <!-- end-user-doc -->
396             * @generated
397             */
398            public URL createEUrlFromString(EDataType eDataType, String initialValue) {
399                    return (URL)super.createFromString(eDataType, initialValue);
400            }
401    
402            /**
403             * <!-- begin-user-doc -->
404             * <!-- end-user-doc -->
405             * @generated
406             */
407            public String convertEUrlToString(EDataType eDataType, Object instanceValue) {
408                    return super.convertToString(eDataType, instanceValue);
409            }
410    
411            /**
412             * <!-- begin-user-doc -->
413             * <!-- end-user-doc -->
414             * @generated
415             */
416            public ClassLoader createEClassLoaderFromString(EDataType eDataType, String initialValue) {
417                    return (ClassLoader)super.createFromString(eDataType, initialValue);
418            }
419    
420            /**
421             * <!-- begin-user-doc -->
422             * <!-- end-user-doc -->
423             * @generated
424             */
425            public String convertEClassLoaderToString(EDataType eDataType, Object instanceValue) {
426                    return super.convertToString(eDataType, instanceValue);
427            }
428    
429            /**
430             * <!-- begin-user-doc -->
431             * <!-- end-user-doc -->
432             * @generated
433             */
434            public TokenSource createETokenSourceFromString(EDataType eDataType, String initialValue) {
435                    return (TokenSource)super.createFromString(eDataType, initialValue);
436            }
437    
438            /**
439             * <!-- begin-user-doc -->
440             * <!-- end-user-doc -->
441             * @generated
442             */
443            public String convertETokenSourceToString(EDataType eDataType, Object instanceValue) {
444                    return super.convertToString(eDataType, instanceValue);
445            }
446    
447            /**
448             * <!-- begin-user-doc -->
449             * <!-- end-user-doc -->
450             * @generated
451             */
452            public File createFileFromString(EDataType eDataType, String initialValue) {
453                    return (File)super.createFromString(eDataType, initialValue);
454            }
455    
456            /**
457             * <!-- begin-user-doc -->
458             * <!-- end-user-doc -->
459             * @generated
460             */
461            public String convertFileToString(EDataType eDataType, Object instanceValue) {
462                    return super.convertToString(eDataType, instanceValue);
463            }
464    
465            /**
466             * <!-- begin-user-doc -->
467             * <!-- end-user-doc -->
468             * @generated
469             */
470            public InjectionConfig createInjectionConfigFromString(EDataType eDataType, String initialValue) {
471                    return (InjectionConfig)super.createFromString(eDataType, initialValue);
472            }
473    
474            /**
475             * <!-- begin-user-doc -->
476             * <!-- end-user-doc -->
477             * @generated
478             */
479            public String convertInjectionConfigToString(EDataType eDataType, Object instanceValue) {
480                    return super.convertToString(eDataType, instanceValue);
481            }
482    
483            /**
484             * <!-- begin-user-doc -->
485             * <!-- end-user-doc -->
486             * @generated
487             */
488            public ConfigPackage getConfigPackage() {
489                    return (ConfigPackage)getEPackage();
490            }
491    
492            /**
493             * <!-- begin-user-doc -->
494             * <!-- end-user-doc -->
495             * @deprecated
496             * @generated
497             */
498            @Deprecated
499            public static ConfigPackage getPackage() {
500                    return ConfigPackage.eINSTANCE;
501            }
502    
503    } //ConfigFactoryImpl