/**
* <copyright>
* </copyright>
*
* $Id$
*/
package OntoUML.impl;
import OntoUML.Derivation;
import OntoUML.OntoUMLPackage;
import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EOperation;
import org.eclipse.ocl.ParserException;
import org.eclipse.ocl.Query;
import org.eclipse.ocl.ecore.OCL;
import org.eclipse.ocl.expressions.OCLExpression;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Derivation</b></em>'.
* <!-- end-user-doc -->
* <p>
* </p>
*
* @generated
*/
public class DerivationImpl extends DependencyRelationshipImpl implements Derivation {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected DerivationImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return OntoUMLPackage.Literals.DERIVATION;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public int deriveLowerDerivation() {
if (deriveLowerDerivationBodyOCL == null) {
EOperation eOperation = OntoUMLPackage.Literals.DERIVATION.getEOperations().get(0);
OCL.Helper helper = OCL_ENV.createOCLHelper();
helper.setOperationContext(OntoUMLPackage.Literals.DERIVATION, eOperation);
EAnnotation ocl = eOperation.getEAnnotation(OCL_ANNOTATION_SOURCE);
String body = ocl.getDetails().get("body");
try {
deriveLowerDerivationBodyOCL = helper.createQuery(body);
} catch (ParserException e) {
throw new UnsupportedOperationException(e.getLocalizedMessage());
}
}
Query<EClassifier, ?, ?> query = OCL_ENV.createQuery(deriveLowerDerivationBodyOCL);
return ((Integer) query.evaluate(this)).intValue();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public int deriveUpperDerivation() {
if (deriveUpperDerivationBodyOCL == null) {
EOperation eOperation = OntoUMLPackage.Literals.DERIVATION.getEOperations().get(1);
OCL.Helper helper = OCL_ENV.createOCLHelper();
helper.setOperationContext(OntoUMLPackage.Literals.DERIVATION, eOperation);
EAnnotation ocl = eOperation.getEAnnotation(OCL_ANNOTATION_SOURCE);
String body = ocl.getDetails().get("body");
try {
deriveUpperDerivationBodyOCL = helper.createQuery(body);
} catch (ParserException e) {
throw new UnsupportedOperationException(e.getLocalizedMessage());
}
}
Query<EClassifier, ?, ?> query = OCL_ENV.createQuery(deriveUpperDerivationBodyOCL);
return ((Integer) query.evaluate(this)).intValue();
}
/**
* The parsed OCL expression for the body of the '{@link #deriveLowerDerivation <em>Derive Lower Derivation</em>}' operation.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #deriveLowerDerivation
* @generated
*/
private static OCLExpression<EClassifier> deriveLowerDerivationBodyOCL;
/**
* The parsed OCL expression for the body of the '{@link #deriveUpperDerivation <em>Derive Upper Derivation</em>}' operation.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #deriveUpperDerivation
* @generated
*/
private static OCLExpression<EClassifier> deriveUpperDerivationBodyOCL;
private static final String OCL_ANNOTATION_SOURCE = "http://www.eclipse.org/ocl/examples/OCL";
private static final OCL OCL_ENV = OCL.newInstance();
} //DerivationImpl