blob: 96114e13d4f786886306e9a53942b0dc7c25c804 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others.
* 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jem.internal.instantiation.impl;
/*
*/
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.jem.internal.instantiation.*;
import org.eclipse.jem.internal.instantiation.PTExpression;
import org.eclipse.jem.internal.instantiation.PTFieldAccess;
import org.eclipse.jem.internal.instantiation.InstantiationPackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Field Access</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.jem.internal.instantiation.impl.PTFieldAccessImpl#getReceiver <em>Receiver</em>}</li>
* <li>{@link org.eclipse.jem.internal.instantiation.impl.PTFieldAccessImpl#getField <em>Field</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class PTFieldAccessImpl extends PTExpressionImpl implements PTFieldAccess {
/**
* The cached value of the '{@link #getReceiver() <em>Receiver</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getReceiver()
* @generated
* @ordered
*/
protected PTExpression receiver = null;
/**
* The default value of the '{@link #getField() <em>Field</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getField()
* @generated
* @ordered
*/
protected static final String FIELD_EDEFAULT = null;
/**
* The cached value of the '{@link #getField() <em>Field</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getField()
* @generated
* @ordered
*/
protected String field = FIELD_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected PTFieldAccessImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EClass eStaticClass() {
return InstantiationPackage.eINSTANCE.getPTFieldAccess();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public PTExpression getReceiver() {
return receiver;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetReceiver(PTExpression newReceiver, NotificationChain msgs) {
PTExpression oldReceiver = receiver;
receiver = newReceiver;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, InstantiationPackage.PT_FIELD_ACCESS__RECEIVER, oldReceiver, newReceiver);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setReceiver(PTExpression newReceiver) {
if (newReceiver != receiver) {
NotificationChain msgs = null;
if (receiver != null)
msgs = ((InternalEObject)receiver).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - InstantiationPackage.PT_FIELD_ACCESS__RECEIVER, null, msgs);
if (newReceiver != null)
msgs = ((InternalEObject)newReceiver).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - InstantiationPackage.PT_FIELD_ACCESS__RECEIVER, null, msgs);
msgs = basicSetReceiver(newReceiver, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, InstantiationPackage.PT_FIELD_ACCESS__RECEIVER, newReceiver, newReceiver));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getField() {
return field;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setField(String newField) {
String oldField = field;
field = newField;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, InstantiationPackage.PT_FIELD_ACCESS__FIELD, oldField, field));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
if (featureID >= 0) {
switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
case InstantiationPackage.PT_FIELD_ACCESS__RECEIVER:
return basicSetReceiver(null, msgs);
default:
return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
}
}
return eBasicSetContainer(null, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Object eGet(EStructuralFeature eFeature, boolean resolve) {
switch (eDerivedStructuralFeatureID(eFeature)) {
case InstantiationPackage.PT_FIELD_ACCESS__RECEIVER:
return getReceiver();
case InstantiationPackage.PT_FIELD_ACCESS__FIELD:
return getField();
}
return eDynamicGet(eFeature, resolve);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eSet(EStructuralFeature eFeature, Object newValue) {
switch (eDerivedStructuralFeatureID(eFeature)) {
case InstantiationPackage.PT_FIELD_ACCESS__RECEIVER:
setReceiver((PTExpression)newValue);
return;
case InstantiationPackage.PT_FIELD_ACCESS__FIELD:
setField((String)newValue);
return;
}
eDynamicSet(eFeature, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eUnset(EStructuralFeature eFeature) {
switch (eDerivedStructuralFeatureID(eFeature)) {
case InstantiationPackage.PT_FIELD_ACCESS__RECEIVER:
setReceiver((PTExpression)null);
return;
case InstantiationPackage.PT_FIELD_ACCESS__FIELD:
setField(FIELD_EDEFAULT);
return;
}
eDynamicUnset(eFeature);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean eIsSet(EStructuralFeature eFeature) {
switch (eDerivedStructuralFeatureID(eFeature)) {
case InstantiationPackage.PT_FIELD_ACCESS__RECEIVER:
return receiver != null;
case InstantiationPackage.PT_FIELD_ACCESS__FIELD:
return FIELD_EDEFAULT == null ? field != null : !FIELD_EDEFAULT.equals(field);
}
return eDynamicIsSet(eFeature);
}
public String toString() {
return super.toString(); // Really want toString to be final at PTExpression, but EMF doesn't allow it.
}
/*
* (non-Javadoc)
* @see org.eclipse.jem.internal.instantiation.impl.ExpressionImpl#accept0(org.eclipse.jem.internal.instantiation.ParseVisitor)
*/
protected void accept0(ParseVisitor visitor) {
boolean visitChildren = visitor.visit(this);
if (visitChildren) {
// visit children in normal left to right reading order
acceptChild(visitor, getReceiver());
}
visitor.endVisit(this);
}
} //FieldAccessImpl