/**
* <copyright>
* </copyright>
*
* $Id$
*/
package net.sf.etl.samples.ej.ast.impl;
import java.util.Collection;
import net.sf.etl.samples.ej.ast.AstPackage;
import net.sf.etl.samples.ej.ast.CatchPart;
import net.sf.etl.samples.ej.ast.MethodBlock;
import net.sf.etl.samples.ej.ast.TryStatement;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Try Statement</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link net.sf.etl.samples.ej.ast.impl.TryStatementImpl#getFinallyPart <em>Finally Part</em>}</li>
* <li>{@link net.sf.etl.samples.ej.ast.impl.TryStatementImpl#getCatchPart <em>Catch Part</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class TryStatementImpl extends ScopeStatementImpl implements TryStatement {
/**
* The cached value of the '{@link #getFinallyPart() <em>Finally Part</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getFinallyPart()
* @generated
* @ordered
*/
protected MethodBlock finallyPart = null;
/**
* The cached value of the '{@link #getCatchPart() <em>Catch Part</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCatchPart()
* @generated
* @ordered
*/
protected EList catchPart = null;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected TryStatementImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EClass eStaticClass() {
return AstPackage.Literals.TRY_STATEMENT;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public MethodBlock getFinallyPart() {
return finallyPart;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetFinallyPart(MethodBlock newFinallyPart, NotificationChain msgs) {
MethodBlock oldFinallyPart = finallyPart;
finallyPart = newFinallyPart;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AstPackage.TRY_STATEMENT__FINALLY_PART, oldFinallyPart, newFinallyPart);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setFinallyPart(MethodBlock newFinallyPart) {
if (newFinallyPart != finallyPart) {
NotificationChain msgs = null;
if (finallyPart != null)
msgs = ((InternalEObject)finallyPart).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AstPackage.TRY_STATEMENT__FINALLY_PART, null, msgs);
if (newFinallyPart != null)
msgs = ((InternalEObject)newFinallyPart).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AstPackage.TRY_STATEMENT__FINALLY_PART, null, msgs);
msgs = basicSetFinallyPart(newFinallyPart, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, AstPackage.TRY_STATEMENT__FINALLY_PART, newFinallyPart, newFinallyPart));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList getCatchPart() {
if (catchPart == null) {
catchPart = new EObjectContainmentEList(CatchPart.class, this, AstPackage.TRY_STATEMENT__CATCH_PART);
}
return catchPart;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case AstPackage.TRY_STATEMENT__FINALLY_PART:
return basicSetFinallyPart(null, msgs);
case AstPackage.TRY_STATEMENT__CATCH_PART:
return ((InternalEList)getCatchPart()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case AstPackage.TRY_STATEMENT__FINALLY_PART:
return getFinallyPart();
case AstPackage.TRY_STATEMENT__CATCH_PART:
return getCatchPart();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case AstPackage.TRY_STATEMENT__FINALLY_PART:
setFinallyPart((MethodBlock)newValue);
return;
case AstPackage.TRY_STATEMENT__CATCH_PART:
getCatchPart().clear();
getCatchPart().addAll((Collection)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eUnset(int featureID) {
switch (featureID) {
case AstPackage.TRY_STATEMENT__FINALLY_PART:
setFinallyPart((MethodBlock)null);
return;
case AstPackage.TRY_STATEMENT__CATCH_PART:
getCatchPart().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean eIsSet(int featureID) {
switch (featureID) {
case AstPackage.TRY_STATEMENT__FINALLY_PART:
return finallyPart != null;
case AstPackage.TRY_STATEMENT__CATCH_PART:
return catchPart != null && !catchPart.isEmpty();
}
return super.eIsSet(featureID);
}
} //TryStatementImpl