/** | |
* ******************************************************************************* | |
* Copyright (c) 2009 Mia-Software. | |
* All rights reserved. This program and the accompanying materials | |
* are made available under the terms of the Eclipse Public License v1.0 | |
* which accompanies this distribution, and is available at | |
* http://www.eclipse.org/legal/epl-v10.html | |
* | |
* Contributors: | |
* | |
* Fabien Giquel (Mia-Software) - initial API and implementation | |
* ******************************************************************************* | |
* | |
* $Id$ | |
*/ | |
package org.eclipse.gmt.modisco.java.emf.classic.impl; | |
import java.util.Collection; | |
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; | |
import org.eclipse.gmt.modisco.java.Block; | |
import org.eclipse.gmt.modisco.java.CatchClause; | |
import org.eclipse.gmt.modisco.java.TryStatement; | |
import org.eclipse.gmt.modisco.java.emf.classic.JavaPackage; | |
/** | |
* <!-- 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 org.eclipse.gmt.modisco.java.emf.classic.impl.TryStatementImpl#getBody <em>Body</em>}</li> | |
* <li>{@link org.eclipse.gmt.modisco.java.emf.classic.impl.TryStatementImpl#getFinally <em>Finally</em>}</li> | |
* <li>{@link org.eclipse.gmt.modisco.java.emf.classic.impl.TryStatementImpl#getCatchClauses <em>Catch Clauses</em>}</li> | |
* </ul> | |
* </p> | |
* | |
* @generated | |
*/ | |
public class TryStatementImpl extends StatementImpl implements TryStatement { | |
/** | |
* The cached value of the '{@link #getBody() <em>Body</em>}' containment reference. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getBody() | |
* @generated | |
* @ordered | |
*/ | |
protected Block body; | |
/** | |
* The cached value of the '{@link #getFinally() <em>Finally</em>}' containment reference. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getFinally() | |
* @generated | |
* @ordered | |
*/ | |
protected Block finally_; | |
/** | |
* The cached value of the '{@link #getCatchClauses() <em>Catch Clauses</em>}' containment reference list. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getCatchClauses() | |
* @generated | |
* @ordered | |
*/ | |
protected EList<CatchClause> catchClauses; | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected TryStatementImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
protected EClass eStaticClass() { | |
return JavaPackage.eINSTANCE.getTryStatement(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public Block getBody() { | |
return body; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public NotificationChain basicSetBody(Block newBody, NotificationChain msgs) { | |
Block oldBody = body; | |
body = newBody; | |
if (eNotificationRequired()) { | |
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, JavaPackage.TRY_STATEMENT__BODY, oldBody, newBody); | |
if (msgs == null) msgs = notification; else msgs.add(notification); | |
} | |
return msgs; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setBody(Block newBody) { | |
if (newBody != body) { | |
NotificationChain msgs = null; | |
if (body != null) | |
msgs = ((InternalEObject)body).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - JavaPackage.TRY_STATEMENT__BODY, null, msgs); | |
if (newBody != null) | |
msgs = ((InternalEObject)newBody).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JavaPackage.TRY_STATEMENT__BODY, null, msgs); | |
msgs = basicSetBody(newBody, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.TRY_STATEMENT__BODY, newBody, newBody)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public Block getFinally() { | |
return finally_; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public NotificationChain basicSetFinally(Block newFinally, NotificationChain msgs) { | |
Block oldFinally = finally_; | |
finally_ = newFinally; | |
if (eNotificationRequired()) { | |
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, JavaPackage.TRY_STATEMENT__FINALLY, oldFinally, newFinally); | |
if (msgs == null) msgs = notification; else msgs.add(notification); | |
} | |
return msgs; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setFinally(Block newFinally) { | |
if (newFinally != finally_) { | |
NotificationChain msgs = null; | |
if (finally_ != null) | |
msgs = ((InternalEObject)finally_).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - JavaPackage.TRY_STATEMENT__FINALLY, null, msgs); | |
if (newFinally != null) | |
msgs = ((InternalEObject)newFinally).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JavaPackage.TRY_STATEMENT__FINALLY, null, msgs); | |
msgs = basicSetFinally(newFinally, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.TRY_STATEMENT__FINALLY, newFinally, newFinally)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public EList<CatchClause> getCatchClauses() { | |
if (catchClauses == null) { | |
catchClauses = new EObjectContainmentEList<CatchClause>(CatchClause.class, this, JavaPackage.TRY_STATEMENT__CATCH_CLAUSES); | |
} | |
return catchClauses; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case JavaPackage.TRY_STATEMENT__BODY: | |
return basicSetBody(null, msgs); | |
case JavaPackage.TRY_STATEMENT__FINALLY: | |
return basicSetFinally(null, msgs); | |
case JavaPackage.TRY_STATEMENT__CATCH_CLAUSES: | |
return ((InternalEList<?>)getCatchClauses()).basicRemove(otherEnd, msgs); | |
} | |
return super.eInverseRemove(otherEnd, featureID, msgs); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public Object eGet(int featureID, boolean resolve, boolean coreType) { | |
switch (featureID) { | |
case JavaPackage.TRY_STATEMENT__BODY: | |
return getBody(); | |
case JavaPackage.TRY_STATEMENT__FINALLY: | |
return getFinally(); | |
case JavaPackage.TRY_STATEMENT__CATCH_CLAUSES: | |
return getCatchClauses(); | |
} | |
return super.eGet(featureID, resolve, coreType); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@SuppressWarnings("unchecked") | |
@Override | |
public void eSet(int featureID, Object newValue) { | |
switch (featureID) { | |
case JavaPackage.TRY_STATEMENT__BODY: | |
setBody((Block)newValue); | |
return; | |
case JavaPackage.TRY_STATEMENT__FINALLY: | |
setFinally((Block)newValue); | |
return; | |
case JavaPackage.TRY_STATEMENT__CATCH_CLAUSES: | |
getCatchClauses().clear(); | |
getCatchClauses().addAll((Collection<? extends CatchClause>)newValue); | |
return; | |
} | |
super.eSet(featureID, newValue); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void eUnset(int featureID) { | |
switch (featureID) { | |
case JavaPackage.TRY_STATEMENT__BODY: | |
setBody((Block)null); | |
return; | |
case JavaPackage.TRY_STATEMENT__FINALLY: | |
setFinally((Block)null); | |
return; | |
case JavaPackage.TRY_STATEMENT__CATCH_CLAUSES: | |
getCatchClauses().clear(); | |
return; | |
} | |
super.eUnset(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public boolean eIsSet(int featureID) { | |
switch (featureID) { | |
case JavaPackage.TRY_STATEMENT__BODY: | |
return body != null; | |
case JavaPackage.TRY_STATEMENT__FINALLY: | |
return finally_ != null; | |
case JavaPackage.TRY_STATEMENT__CATCH_CLAUSES: | |
return catchClauses != null && !catchClauses.isEmpty(); | |
} | |
return super.eIsSet(featureID); | |
} | |
} //TryStatementImpl |