/******************************************************************************* * Copyright (c) 2010 Martin Schnabel <mb0@mb0.org>. * 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 ******************************************************************************/ package org.axdt.as3.model.impl; import org.axdt.as3.As3EPackage; import org.axdt.as3.model.As3Attributes; import org.axdt.as3.model.As3Definition; import org.axdt.as3.model.As3Package; import org.axdt.avm.model.AvmDefinition; import org.axdt.avm.model.AvmType; import org.axdt.avm.model.AvmVisibility; import org.axdt.avm.naming.AvmQualifiedName; 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.EObject; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>As3 Definition</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.axdt.as3.model.impl.As3DefinitionImpl#getName <em>Name</em>}</li> * <li>{@link org.axdt.as3.model.impl.As3DefinitionImpl#getAttributes <em>Attributes</em>}</li> * </ul> * </p> * * @generated */ public abstract class As3DefinitionImpl extends As3IdentifiableImpl implements As3Definition { /** * The default value of the '{@link #getName() <em>Name</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getName() * @generated * @ordered */ protected static final String NAME_EDEFAULT = null; /** * The cached value of the '{@link #getName() <em>Name</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getName() * @generated * @ordered */ protected String name = NAME_EDEFAULT; /** * The cached value of the '{@link #getAttributes() <em>Attributes</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getAttributes() * @generated * @ordered */ protected As3Attributes attributes; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected As3DefinitionImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return As3EPackage.Literals.AS3_DEFINITION; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getName() { return name; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setName(String newName) { String oldName = name; name = newName; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, As3EPackage.AS3_DEFINITION__NAME, oldName, name)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public As3Attributes getAttributes() { return attributes; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetAttributes(As3Attributes newAttributes, NotificationChain msgs) { As3Attributes oldAttributes = attributes; attributes = newAttributes; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, As3EPackage.AS3_DEFINITION__ATTRIBUTES, oldAttributes, newAttributes); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setAttributes(As3Attributes newAttributes) { if (newAttributes != attributes) { NotificationChain msgs = null; if (attributes != null) msgs = ((InternalEObject)attributes).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - As3EPackage.AS3_DEFINITION__ATTRIBUTES, null, msgs); if (newAttributes != null) msgs = ((InternalEObject)newAttributes).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - As3EPackage.AS3_DEFINITION__ATTRIBUTES, null, msgs); msgs = basicSetAttributes(newAttributes, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, As3EPackage.AS3_DEFINITION__ATTRIBUTES, newAttributes, newAttributes)); } public AvmVisibility getVisibility() { As3Attributes attris = getAttributes(); return attris != null ? attris.getVisibility() : getDefaultVisibility(); } protected AvmVisibility getDefaultVisibility() { return AvmVisibility.INTERNAL; } public String getQualifier() { EObject parent = getQualifyingParent(); if (!(parent instanceof AvmDefinition)) return null; String name = ((AvmDefinition)parent).getCanonicalName(); return name != null && name.length() > 0 ? name : null; } protected EObject getQualifyingParent() { return eContainer(); } public String getCanonicalName() { if (getName()==null) return null; EObject container = getQualifyingParent(); String qualifier = getQualifier(); if (qualifier != null) { if (container instanceof AvmType) qualifier += '#'; else qualifier += '.'; return qualifier + getName(); } return container == null || container instanceof As3Package ? getName() : "."+getName(); } public AvmQualifiedName getQualifiedName() { if (name == null) return null; EObject container = getQualifyingParent(); if (container instanceof AvmDefinition) { AvmQualifiedName qname = ((AvmDefinition) container).getQualifiedName(); if (qname != null) return qname.append(name); } return AvmQualifiedName.create(name); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case As3EPackage.AS3_DEFINITION__ATTRIBUTES: return basicSetAttributes(null, 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 As3EPackage.AS3_DEFINITION__NAME: return getName(); case As3EPackage.AS3_DEFINITION__ATTRIBUTES: return getAttributes(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case As3EPackage.AS3_DEFINITION__NAME: setName((String)newValue); return; case As3EPackage.AS3_DEFINITION__ATTRIBUTES: setAttributes((As3Attributes)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case As3EPackage.AS3_DEFINITION__NAME: setName(NAME_EDEFAULT); return; case As3EPackage.AS3_DEFINITION__ATTRIBUTES: setAttributes((As3Attributes)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case As3EPackage.AS3_DEFINITION__NAME: return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); case As3EPackage.AS3_DEFINITION__ATTRIBUTES: return attributes != 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(" (name: "); result.append(name); result.append(')'); return result.toString(); } } //As3DefinitionImpl