| /* |
| * Copyright (c) 2003, 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 - initial API and implementation |
| * |
| * $Id: RedefinableElementImpl.java,v 1.18 2005/11/09 22:53:09 khussey Exp $ |
| */ |
| package org.eclipse.uml2.impl; |
| |
| import java.lang.reflect.Method; |
| |
| import java.util.Collection; |
| import java.util.Iterator; |
| import java.util.List; |
| import java.util.Map; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| |
| import org.eclipse.emf.common.util.DiagnosticChain; |
| import org.eclipse.emf.common.util.EList; |
| import org.eclipse.emf.common.util.UniqueEList; |
| |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.EStructuralFeature; |
| |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| |
| import org.eclipse.uml2.Classifier; |
| import org.eclipse.uml2.RedefinableElement; |
| import org.eclipse.uml2.StringExpression; |
| import org.eclipse.uml2.TemplateSignature; |
| import org.eclipse.uml2.UML2Package; |
| import org.eclipse.uml2.VisibilityKind; |
| |
| import org.eclipse.uml2.common.util.CacheAdapter; |
| //import org.eclipse.uml2.common.util.DerivedUnionEObjectEList; |
| import org.eclipse.uml2.common.util.DerivedEObjectEList; |
| import org.eclipse.uml2.common.util.UnionEObjectEList; |
| |
| import org.eclipse.uml2.internal.operation.RedefinableElementOperations; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Redefinable Element</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.uml2.impl.RedefinableElementImpl#getRedefinitionContexts <em>Redefinition Context</em>}</li> |
| * <li>{@link org.eclipse.uml2.impl.RedefinableElementImpl#isLeaf <em>Is Leaf</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public abstract class RedefinableElementImpl extends NamedElementImpl implements RedefinableElement { |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public static final String copyright = "Copyright (c) IBM Corporation and others."; //$NON-NLS-1$ |
| |
| /** |
| * The cached value of the '{@link #getRedefinitionContexts() <em>Redefinition Context</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getRedefinitionContexts() |
| * @generated |
| * @ordered |
| */ |
| protected EList redefinitionContext = null; |
| |
| /** |
| * The default value of the '{@link #isLeaf() <em>Is Leaf</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isLeaf() |
| * @generated |
| * @ordered |
| */ |
| protected static final boolean IS_LEAF_EDEFAULT = false; |
| |
| /** |
| * The flag representing the value of the '{@link #isLeaf() <em>Is Leaf</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isLeaf() |
| * @generated |
| * @ordered |
| */ |
| protected static final int IS_LEAF_EFLAG = 1 << 8; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected RedefinableElementImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected EClass eStaticClass() { |
| return UML2Package.eINSTANCE.getRedefinableElement(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isLeaf() { |
| return (eFlags & IS_LEAF_EFLAG) != 0; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setIsLeaf(boolean newIsLeaf) { |
| boolean oldIsLeaf = (eFlags & IS_LEAF_EFLAG) != 0; |
| if (newIsLeaf) eFlags |= IS_LEAF_EFLAG; else eFlags &= ~IS_LEAF_EFLAG; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, UML2Package.REDEFINABLE_ELEMENT__IS_LEAF, oldIsLeaf, newIsLeaf)); |
| |
| } |
| |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean validateRedefinitionContextValid(DiagnosticChain diagnostics, Map context) { |
| return RedefinableElementOperations.validateRedefinitionContextValid(this, diagnostics, context); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean validateRedefinitionConsistent(DiagnosticChain diagnostics, Map context) { |
| return RedefinableElementOperations.validateRedefinitionConsistent(this, diagnostics, context); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public EList getRedefinitionContexts() { |
| if (redefinitionContext == null) { |
| redefinitionContext = new DerivedEObjectEList(Classifier.class, this, UML2Package.REDEFINABLE_ELEMENT__REDEFINITION_CONTEXT, new EStructuralFeature[] {UML2Package.eINSTANCE.getElement_Owner()}); |
| } |
| return redefinitionContext; |
| } |
| |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isSetRedefinitionContexts() { |
| return false; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Classifier getRedefinitionContext(String name) { |
| for (Iterator i = getRedefinitionContexts().iterator(); i.hasNext(); ) { |
| Classifier redefinitionContext = (Classifier) i.next(); |
| if (name.equals(redefinitionContext.getName())) { |
| return redefinitionContext; |
| } |
| } |
| return null; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected EList getRedefinedElementsHelper(EList redefinedElement) { |
| return redefinedElement; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isConsistentWith(RedefinableElement redefinee) { |
| return RedefinableElementOperations.isConsistentWith(this, redefinee); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isRedefinitionContextValid(RedefinableElement redefinable) { |
| return RedefinableElementOperations.isRedefinitionContextValid(this, redefinable); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList getRedefinedElements() { |
| CacheAdapter cache = getCacheAdapter(); |
| if (cache != null) { |
| try { |
| Method method = getClass().getMethod("getRedefinedElements", null); //$NON-NLS-1$ |
| EList redefinedElement = (EList) cache.get(eResource(), this, method); |
| if (redefinedElement == null) { |
| List union = getRedefinedElementsHelper(new UniqueEList()); |
| cache.put(eResource(), this, method, redefinedElement = new UnionEObjectEList(this, null, union.size(), union.toArray())); |
| } |
| return redefinedElement; |
| } catch (NoSuchMethodException nsme) { |
| // ignore |
| } |
| } |
| List union = getRedefinedElementsHelper(new UniqueEList()); |
| return new UnionEObjectEList(this, null, union.size(), union.toArray()); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isSetRedefinedElements() { |
| return false; |
| } |
| |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public RedefinableElement getRedefinedElement(String name) { |
| for (Iterator i = getRedefinedElements().iterator(); i.hasNext(); ) { |
| RedefinableElement redefinedElement = (RedefinableElement) i.next(); |
| if (name.equals(redefinedElement.getName())) { |
| return redefinedElement; |
| } |
| } |
| return null; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Object eGet(EStructuralFeature eFeature, boolean resolve) { |
| switch (eDerivedStructuralFeatureID(eFeature)) { |
| case UML2Package.REDEFINABLE_ELEMENT__EANNOTATIONS: |
| return getEAnnotations(); |
| case UML2Package.REDEFINABLE_ELEMENT__OWNED_ELEMENT: |
| return getOwnedElements(); |
| case UML2Package.REDEFINABLE_ELEMENT__OWNER: |
| if (resolve) return getOwner(); |
| return basicGetOwner(); |
| case UML2Package.REDEFINABLE_ELEMENT__OWNED_COMMENT: |
| return getOwnedComments(); |
| case UML2Package.REDEFINABLE_ELEMENT__TEMPLATE_BINDING: |
| return getTemplateBindings(); |
| case UML2Package.REDEFINABLE_ELEMENT__OWNED_TEMPLATE_SIGNATURE: |
| return getOwnedTemplateSignature(); |
| case UML2Package.REDEFINABLE_ELEMENT__NAME: |
| return getName(); |
| case UML2Package.REDEFINABLE_ELEMENT__QUALIFIED_NAME: |
| return getQualifiedName(); |
| case UML2Package.REDEFINABLE_ELEMENT__VISIBILITY: |
| return getVisibility(); |
| case UML2Package.REDEFINABLE_ELEMENT__CLIENT_DEPENDENCY: |
| return getClientDependencies(); |
| case UML2Package.REDEFINABLE_ELEMENT__NAME_EXPRESSION: |
| return getNameExpression(); |
| case UML2Package.REDEFINABLE_ELEMENT__REDEFINITION_CONTEXT: |
| return getRedefinitionContexts(); |
| case UML2Package.REDEFINABLE_ELEMENT__IS_LEAF: |
| return isLeaf() ? Boolean.TRUE : Boolean.FALSE; |
| } |
| return eDynamicGet(eFeature, resolve); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void eSet(EStructuralFeature eFeature, Object newValue) { |
| switch (eDerivedStructuralFeatureID(eFeature)) { |
| case UML2Package.REDEFINABLE_ELEMENT__EANNOTATIONS: |
| getEAnnotations().clear(); |
| getEAnnotations().addAll((Collection)newValue); |
| return; |
| case UML2Package.REDEFINABLE_ELEMENT__OWNED_COMMENT: |
| getOwnedComments().clear(); |
| getOwnedComments().addAll((Collection)newValue); |
| return; |
| case UML2Package.REDEFINABLE_ELEMENT__TEMPLATE_BINDING: |
| getTemplateBindings().clear(); |
| getTemplateBindings().addAll((Collection)newValue); |
| return; |
| case UML2Package.REDEFINABLE_ELEMENT__OWNED_TEMPLATE_SIGNATURE: |
| setOwnedTemplateSignature((TemplateSignature)newValue); |
| return; |
| case UML2Package.REDEFINABLE_ELEMENT__NAME: |
| setName((String)newValue); |
| return; |
| case UML2Package.REDEFINABLE_ELEMENT__VISIBILITY: |
| setVisibility((VisibilityKind)newValue); |
| return; |
| case UML2Package.REDEFINABLE_ELEMENT__CLIENT_DEPENDENCY: |
| getClientDependencies().clear(); |
| getClientDependencies().addAll((Collection)newValue); |
| return; |
| case UML2Package.REDEFINABLE_ELEMENT__NAME_EXPRESSION: |
| setNameExpression((StringExpression)newValue); |
| return; |
| case UML2Package.REDEFINABLE_ELEMENT__IS_LEAF: |
| setIsLeaf(((Boolean)newValue).booleanValue()); |
| return; |
| } |
| eDynamicSet(eFeature, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void eUnset(EStructuralFeature eFeature) { |
| switch (eDerivedStructuralFeatureID(eFeature)) { |
| case UML2Package.REDEFINABLE_ELEMENT__EANNOTATIONS: |
| getEAnnotations().clear(); |
| return; |
| case UML2Package.REDEFINABLE_ELEMENT__OWNED_COMMENT: |
| getOwnedComments().clear(); |
| return; |
| case UML2Package.REDEFINABLE_ELEMENT__TEMPLATE_BINDING: |
| getTemplateBindings().clear(); |
| return; |
| case UML2Package.REDEFINABLE_ELEMENT__OWNED_TEMPLATE_SIGNATURE: |
| setOwnedTemplateSignature((TemplateSignature)null); |
| return; |
| case UML2Package.REDEFINABLE_ELEMENT__NAME: |
| setName(NAME_EDEFAULT); |
| return; |
| case UML2Package.REDEFINABLE_ELEMENT__VISIBILITY: |
| setVisibility(VISIBILITY_EDEFAULT); |
| return; |
| case UML2Package.REDEFINABLE_ELEMENT__CLIENT_DEPENDENCY: |
| getClientDependencies().clear(); |
| return; |
| case UML2Package.REDEFINABLE_ELEMENT__NAME_EXPRESSION: |
| setNameExpression((StringExpression)null); |
| return; |
| case UML2Package.REDEFINABLE_ELEMENT__IS_LEAF: |
| setIsLeaf(IS_LEAF_EDEFAULT); |
| return; |
| } |
| eDynamicUnset(eFeature); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean eIsSet(EStructuralFeature eFeature) { |
| switch (eDerivedStructuralFeatureID(eFeature)) { |
| case UML2Package.REDEFINABLE_ELEMENT__EANNOTATIONS: |
| return eAnnotations != null && !eAnnotations.isEmpty(); |
| case UML2Package.REDEFINABLE_ELEMENT__OWNED_ELEMENT: |
| return isSetOwnedElements(); |
| case UML2Package.REDEFINABLE_ELEMENT__OWNER: |
| return isSetOwner(); |
| case UML2Package.REDEFINABLE_ELEMENT__OWNED_COMMENT: |
| return ownedComment != null && !ownedComment.isEmpty(); |
| case UML2Package.REDEFINABLE_ELEMENT__TEMPLATE_BINDING: |
| return templateBinding != null && !templateBinding.isEmpty(); |
| case UML2Package.REDEFINABLE_ELEMENT__OWNED_TEMPLATE_SIGNATURE: |
| return ownedTemplateSignature != null; |
| case UML2Package.REDEFINABLE_ELEMENT__NAME: |
| return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
| case UML2Package.REDEFINABLE_ELEMENT__QUALIFIED_NAME: |
| return QUALIFIED_NAME_EDEFAULT == null ? getQualifiedName() != null : !QUALIFIED_NAME_EDEFAULT.equals(getQualifiedName()); |
| case UML2Package.REDEFINABLE_ELEMENT__VISIBILITY: |
| return visibility != VISIBILITY_EDEFAULT; |
| case UML2Package.REDEFINABLE_ELEMENT__CLIENT_DEPENDENCY: |
| return clientDependency != null && !clientDependency.isEmpty(); |
| case UML2Package.REDEFINABLE_ELEMENT__NAME_EXPRESSION: |
| return nameExpression != null; |
| case UML2Package.REDEFINABLE_ELEMENT__REDEFINITION_CONTEXT: |
| return isSetRedefinitionContexts(); |
| case UML2Package.REDEFINABLE_ELEMENT__IS_LEAF: |
| return ((eFlags & IS_LEAF_EFLAG) != 0) != IS_LEAF_EDEFAULT; |
| } |
| return eDynamicIsSet(eFeature); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String toString() { |
| if (eIsProxy()) return super.toString(); |
| |
| StringBuffer result = new StringBuffer(super.toString()); |
| result.append(" (isLeaf: "); //$NON-NLS-1$ |
| result.append((eFlags & IS_LEAF_EFLAG) != 0); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| |
| } //RedefinableElementImpl |