| /****************************************************************************** |
| * Copyright (c) 2004, 2006 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.gmf.runtime.notation.impl; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.common.util.BasicEMap; |
| import org.eclipse.emf.common.util.EMap; |
| 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; |
| import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; |
| import org.eclipse.gmf.runtime.notation.Alignment; |
| import org.eclipse.gmf.runtime.notation.Node; |
| import org.eclipse.gmf.runtime.notation.NotationPackage; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Node Entry</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.gmf.runtime.notation.impl.NodeEntryImpl#getTypedValue <em>Value</em>}</li> |
| * <li>{@link org.eclipse.gmf.runtime.notation.impl.NodeEntryImpl#getTypedKey <em>Key</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| /* |
| * @canBeSeenBy org.eclipse.gmf.runtime.notation.* |
| */ |
| public class NodeEntryImpl extends MinimalEObjectImpl.Container implements BasicEMap.Entry { |
| |
| /** |
| * int field to store booleans and enums |
| * @since 1.2 |
| */ |
| protected int eFlags = 0; |
| |
| /** |
| * The default value of the '{@link #getTypedValue() <em>Value</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTypedValue() |
| * @generated |
| * @ordered |
| */ |
| protected static final Alignment VALUE_EDEFAULT = Alignment.CENTER_LITERAL; |
| |
| /** |
| * The offset of the flags representing the value of the '{@link #getTypedValue() <em>Value</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| protected static final int VALUE_EFLAG_OFFSET = 8; |
| |
| /** |
| * The flags representing the default value of the '{@link #getTypedValue() <em>Value</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| protected static final int VALUE_EFLAG_DEFAULT = Alignment.VALUES.indexOf(VALUE_EDEFAULT) << VALUE_EFLAG_OFFSET; |
| |
| /** |
| * The array of enumeration values for '{@link Alignment Alignment}' |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| private static final Alignment[] VALUE_EFLAG_VALUES = (Alignment[])Alignment.VALUES.toArray(new Alignment[Alignment.VALUES.size()]); |
| |
| /** |
| * The flags representing the value of the '{@link #getTypedValue() <em>Value</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTypedValue() |
| * @generated |
| * @ordered |
| */ |
| protected static final int VALUE_EFLAG = 0x7 << VALUE_EFLAG_OFFSET; |
| |
| /** |
| * The cached value of the '{@link #getTypedKey() <em>Key</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTypedKey() |
| * @generated |
| * @ordered |
| */ |
| protected Node key; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected NodeEntryImpl() { |
| super(); |
| eFlags |= VALUE_EFLAG_DEFAULT; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected EClass eStaticClass() { |
| return NotationPackage.Literals.NODE_ENTRY; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Alignment getTypedValue() { |
| return VALUE_EFLAG_VALUES[(eFlags & VALUE_EFLAG) >>> VALUE_EFLAG_OFFSET]; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setTypedValue(Alignment newValue) { |
| Alignment oldValue = VALUE_EFLAG_VALUES[(eFlags & VALUE_EFLAG) >>> VALUE_EFLAG_OFFSET]; |
| if (newValue == null) newValue = VALUE_EDEFAULT; |
| eFlags = eFlags & ~VALUE_EFLAG | Alignment.VALUES.indexOf(newValue) << VALUE_EFLAG_OFFSET; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, NotationPackage.NODE_ENTRY__VALUE, oldValue, newValue)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public Node getTypedKey() { |
| if (key != null && key.eIsProxy()) { |
| EObject oldKey = key; |
| key = (Node)eResolveProxy((InternalEObject)key); |
| if (key != oldKey) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, NotationPackage.NODE_ENTRY__KEY, oldKey, key)); |
| } |
| } |
| return key; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Node basicGetTypedKey() { |
| return key; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public void setTypedKey(Node newKey) { |
| Node oldKey = key; |
| key = newKey; |
| |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, NotationPackage.NODE_ENTRY__KEY, oldKey, key)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case NotationPackage.NODE_ENTRY__VALUE: |
| return getTypedValue(); |
| case NotationPackage.NODE_ENTRY__KEY: |
| if (resolve) return getTypedKey(); |
| return basicGetTypedKey(); |
| } |
| return eDynamicGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case NotationPackage.NODE_ENTRY__VALUE: |
| setTypedValue((Alignment)newValue); |
| return; |
| case NotationPackage.NODE_ENTRY__KEY: |
| setTypedKey((Node)newValue); |
| return; |
| } |
| eDynamicSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case NotationPackage.NODE_ENTRY__VALUE: |
| setTypedValue(VALUE_EDEFAULT); |
| return; |
| case NotationPackage.NODE_ENTRY__KEY: |
| setTypedKey((Node)null); |
| return; |
| } |
| eDynamicUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case NotationPackage.NODE_ENTRY__VALUE: |
| return (eFlags & VALUE_EFLAG) != VALUE_EFLAG_DEFAULT; |
| case NotationPackage.NODE_ENTRY__KEY: |
| return key != null; |
| } |
| return eDynamicIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String toString() { |
| if (eIsProxy()) return super.toString(); |
| |
| StringBuffer result = new StringBuffer(super.toString()); |
| result.append(" (value: "); //$NON-NLS-1$ |
| result.append(VALUE_EFLAG_VALUES[(eFlags & VALUE_EFLAG) >>> VALUE_EFLAG_OFFSET]); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected int hash = -1; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public int getHash() { |
| if (hash == -1) { |
| Object theKey = getKey(); |
| hash = (theKey == null ? 0 : theKey.hashCode()); |
| } |
| return hash; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setHash(int hash) { |
| this.hash = hash; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Object getKey() { |
| return getTypedKey(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setKey(Object key) { |
| setTypedKey((Node)key); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Object getValue() { |
| return getTypedValue(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Object setValue(Object value) { |
| Object oldValue = getValue(); |
| setTypedValue((Alignment)value); |
| return oldValue; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EMap getEMap() { |
| EObject container = eContainer(); |
| return container == null ? null : (EMap)container.eGet(eContainmentFeature()); |
| } |
| |
| } //NodeEntryImpl |