/** | |
* ******************************************************************************* | |
* Copyright (c) 2008 Castor Technologies Inc. | |
* 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: | |
* Alain Picard (Castor Technologies Inc) - initial API and implementation | |
* ******************************************************************************* | |
* | |
* $Id$ | |
*/ | |
package org.eclipse.gmt.modisco.omg.smm.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.InternalEObject; | |
import org.eclipse.emf.ecore.impl.ENotificationImpl; | |
import org.eclipse.emf.ecore.util.EcoreUtil; | |
import org.eclipse.gmt.modisco.omg.smm.Attribute; | |
import org.eclipse.gmt.modisco.omg.smm.SmmElement; | |
import org.eclipse.gmt.modisco.omg.smm.SmmPackage; | |
/** | |
* <!-- begin-user-doc --> | |
* An implementation of the model object '<em><b>Attribute</b></em>'. | |
* <!-- end-user-doc --> | |
* <p> | |
* The following features are implemented: | |
* <ul> | |
* <li>{@link org.eclipse.gmt.modisco.omg.smm.impl.AttributeImpl#getTag <em>Tag</em>}</li> | |
* <li>{@link org.eclipse.gmt.modisco.omg.smm.impl.AttributeImpl#getValue <em>Value</em>}</li> | |
* <li>{@link org.eclipse.gmt.modisco.omg.smm.impl.AttributeImpl#getOwner <em>Owner</em>}</li> | |
* </ul> | |
* </p> | |
* | |
* @generated | |
*/ | |
public class AttributeImpl extends SmmElementImpl implements Attribute { | |
/** | |
* The default value of the '{@link #getTag() <em>Tag</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getTag() | |
* @generated | |
* @ordered | |
*/ | |
protected static final String TAG_EDEFAULT = null; | |
/** | |
* The cached value of the '{@link #getTag() <em>Tag</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getTag() | |
* @generated | |
* @ordered | |
*/ | |
protected String tag = TAG_EDEFAULT; | |
/** | |
* The default value of the '{@link #getValue() <em>Value</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getValue() | |
* @generated | |
* @ordered | |
*/ | |
protected static final String VALUE_EDEFAULT = null; | |
/** | |
* The cached value of the '{@link #getValue() <em>Value</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getValue() | |
* @generated | |
* @ordered | |
*/ | |
protected String value = VALUE_EDEFAULT; | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected AttributeImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
protected EClass eStaticClass() { | |
return SmmPackage.Literals.ATTRIBUTE; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public String getTag() { | |
return tag; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setTag(String newTag) { | |
String oldTag = tag; | |
tag = newTag; | |
if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, SmmPackage.ATTRIBUTE__TAG, oldTag, tag)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public String getValue() { | |
return value; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setValue(String newValue) { | |
String oldValue = value; | |
value = newValue; | |
if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, SmmPackage.ATTRIBUTE__VALUE, oldValue, value)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public SmmElement getOwner() { | |
if (eContainerFeatureID != SmmPackage.ATTRIBUTE__OWNER) return null; | |
return (SmmElement)eContainer(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public NotificationChain basicSetOwner(SmmElement newOwner, NotificationChain msgs) { | |
msgs = eBasicSetContainer((InternalEObject)newOwner, SmmPackage.ATTRIBUTE__OWNER, msgs); | |
return msgs; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setOwner(SmmElement newOwner) { | |
if (newOwner != eInternalContainer() || (eContainerFeatureID != SmmPackage.ATTRIBUTE__OWNER && newOwner != null)) { | |
if (EcoreUtil.isAncestor(this, newOwner)) | |
throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$ | |
NotificationChain msgs = null; | |
if (eInternalContainer() != null) | |
msgs = eBasicRemoveFromContainer(msgs); | |
if (newOwner != null) | |
msgs = ((InternalEObject)newOwner).eInverseAdd(this, SmmPackage.SMM_ELEMENT__ATTRIBUTE, SmmElement.class, msgs); | |
msgs = basicSetOwner(newOwner, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, SmmPackage.ATTRIBUTE__OWNER, newOwner, newOwner)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case SmmPackage.ATTRIBUTE__OWNER: | |
if (eInternalContainer() != null) | |
msgs = eBasicRemoveFromContainer(msgs); | |
return basicSetOwner((SmmElement)otherEnd, msgs); | |
} | |
return super.eInverseAdd(otherEnd, featureID, msgs); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case SmmPackage.ATTRIBUTE__OWNER: | |
return basicSetOwner(null, msgs); | |
} | |
return super.eInverseRemove(otherEnd, featureID, msgs); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { | |
switch (eContainerFeatureID) { | |
case SmmPackage.ATTRIBUTE__OWNER: | |
return eInternalContainer().eInverseRemove(this, SmmPackage.SMM_ELEMENT__ATTRIBUTE, SmmElement.class, msgs); | |
} | |
return super.eBasicRemoveFromContainerFeature(msgs); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public Object eGet(int featureID, boolean resolve, boolean coreType) { | |
switch (featureID) { | |
case SmmPackage.ATTRIBUTE__TAG: | |
return getTag(); | |
case SmmPackage.ATTRIBUTE__VALUE: | |
return getValue(); | |
case SmmPackage.ATTRIBUTE__OWNER: | |
return getOwner(); | |
} | |
return super.eGet(featureID, resolve, coreType); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void eSet(int featureID, Object newValue) { | |
switch (featureID) { | |
case SmmPackage.ATTRIBUTE__TAG: | |
setTag((String)newValue); | |
return; | |
case SmmPackage.ATTRIBUTE__VALUE: | |
setValue((String)newValue); | |
return; | |
case SmmPackage.ATTRIBUTE__OWNER: | |
setOwner((SmmElement)newValue); | |
return; | |
} | |
super.eSet(featureID, newValue); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void eUnset(int featureID) { | |
switch (featureID) { | |
case SmmPackage.ATTRIBUTE__TAG: | |
setTag(TAG_EDEFAULT); | |
return; | |
case SmmPackage.ATTRIBUTE__VALUE: | |
setValue(VALUE_EDEFAULT); | |
return; | |
case SmmPackage.ATTRIBUTE__OWNER: | |
setOwner((SmmElement)null); | |
return; | |
} | |
super.eUnset(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public boolean eIsSet(int featureID) { | |
switch (featureID) { | |
case SmmPackage.ATTRIBUTE__TAG: | |
return TAG_EDEFAULT == null ? tag != null : !TAG_EDEFAULT.equals(tag); | |
case SmmPackage.ATTRIBUTE__VALUE: | |
return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value); | |
case SmmPackage.ATTRIBUTE__OWNER: | |
return getOwner() != null; | |
} | |
return super.eIsSet(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public String toString() { | |
if (eIsProxy()) return super.toString(); | |
StringBuffer result = new StringBuffer(super.toString()); | |
result.append(" (tag: "); //$NON-NLS-1$ | |
result.append(tag); | |
result.append(", value: "); //$NON-NLS-1$ | |
result.append(value); | |
result.append(')'); | |
return result.toString(); | |
} | |
} //AttributeImpl |