/** | |
* <copyright> | |
* | |
* Copyright (c) 2008-2014 See4sys, itemis and others. | |
* All rights reserved. This program and the accompanying materials | |
* are made available under the terms of the Eclipse Public License v2.0 | |
* which accompanies this distribution, and is available at | |
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html | |
* | |
* Contributors: | |
* See4sys - Initial API and implementation | |
* itemis - Enhancements and maintenance | |
* | |
* </copyright> | |
*/ | |
package org.eclipse.sphinx.examples.hummingbird20.common.impl; | |
import org.eclipse.emf.common.util.URI; | |
import org.eclipse.emf.ecore.EClass; | |
import org.eclipse.emf.ecore.EDataType; | |
import org.eclipse.emf.ecore.EObject; | |
import org.eclipse.emf.ecore.EPackage; | |
import org.eclipse.emf.ecore.impl.EFactoryImpl; | |
import org.eclipse.emf.ecore.plugin.EcorePlugin; | |
import org.eclipse.sphinx.examples.hummingbird20.common.*; | |
import org.eclipse.sphinx.examples.hummingbird20.common.Common20Factory; | |
import org.eclipse.sphinx.examples.hummingbird20.common.Common20Package; | |
import org.eclipse.sphinx.examples.hummingbird20.common.Description; | |
/** | |
* <!-- begin-user-doc --> An implementation of the model <b>Factory</b>. <!-- end-user-doc --> | |
* @generated | |
*/ | |
public class Common20FactoryImpl extends EFactoryImpl implements Common20Factory { | |
/** | |
* Creates the default factory implementation. | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @generated | |
*/ | |
public static Common20Factory init() { | |
try { | |
Common20Factory theCommon20Factory = (Common20Factory)EPackage.Registry.INSTANCE.getEFactory(Common20Package.eNS_URI); | |
if (theCommon20Factory != null) { | |
return theCommon20Factory; | |
} | |
} | |
catch (Exception exception) { | |
EcorePlugin.INSTANCE.log(exception); | |
} | |
return new Common20FactoryImpl(); | |
} | |
/** | |
* Creates an instance of the factory. | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @generated | |
*/ | |
public Common20FactoryImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public EObject create(EClass eClass) { | |
switch (eClass.getClassifierID()) { | |
case Common20Package.DESCRIPTION: return createDescription(); | |
case Common20Package.TRANSLATION: return createTranslation(); | |
default: | |
throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ | |
} | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public Object createFromString(EDataType eDataType, String initialValue) { | |
switch (eDataType.getClassifierID()) { | |
case Common20Package.LANGUAGE_CULTURE_NAME: | |
return createLanguageCultureNameFromString(eDataType, initialValue); | |
case Common20Package.EURI: | |
return createEURIFromString(eDataType, initialValue); | |
default: | |
throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ | |
} | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public String convertToString(EDataType eDataType, Object instanceValue) { | |
switch (eDataType.getClassifierID()) { | |
case Common20Package.LANGUAGE_CULTURE_NAME: | |
return convertLanguageCultureNameToString(eDataType, instanceValue); | |
case Common20Package.EURI: | |
return convertEURIToString(eDataType, instanceValue); | |
default: | |
throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ | |
} | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public Description createDescription() { | |
DescriptionImpl description = new DescriptionImpl(); | |
return description; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public Translation createTranslation() { | |
TranslationImpl translation = new TranslationImpl(); | |
return translation; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public LanguageCultureName createLanguageCultureNameFromString(EDataType eDataType, String initialValue) { | |
LanguageCultureName result = LanguageCultureName.get(initialValue); | |
if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ | |
return result; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public String convertLanguageCultureNameToString(EDataType eDataType, Object instanceValue) { | |
return instanceValue == null ? null : instanceValue.toString(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated NOT | |
*/ | |
public URI createEURIFromString(EDataType eDataType, String initialValue) { | |
return URI.createURI(initialValue); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public String convertEURIToString(EDataType eDataType, Object instanceValue) { | |
return super.convertToString(eDataType, instanceValue); | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public Common20Package getCommon20Package() { | |
return (Common20Package)getEPackage(); | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @deprecated | |
* @generated | |
*/ | |
@Deprecated | |
public static Common20Package getPackage() { | |
return Common20Package.eINSTANCE; | |
} | |
} // Common20FactoryImpl |