blob: e6370b4b44153c8b725733573616d5523269e2c4 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2008, 2012 Obeo.
* 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:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.acceleo.parser.cst.impl;
import org.eclipse.acceleo.parser.cst.CstPackage;
import org.eclipse.acceleo.parser.cst.ModelExpression;
import org.eclipse.acceleo.parser.cst.Variable;
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.impl.EObjectImpl;
/**
* <!-- begin-user-doc --> An implementation of the model object '<em><b>Variable</b></em>'. <!-- end-user-doc
* -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.acceleo.parser.cst.impl.VariableImpl#getStartPosition <em>Start Position</em>}</li>
* <li>{@link org.eclipse.acceleo.parser.cst.impl.VariableImpl#getEndPosition <em>End Position</em>}</li>
* <li>{@link org.eclipse.acceleo.parser.cst.impl.VariableImpl#getName <em>Name</em>}</li>
* <li>{@link org.eclipse.acceleo.parser.cst.impl.VariableImpl#getType <em>Type</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class VariableImpl extends EObjectImpl implements Variable {
/**
* The default value of the '{@link #getStartPosition() <em>Start Position</em>}' attribute. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @see #getStartPosition()
* @generated
* @ordered
*/
protected static final int START_POSITION_EDEFAULT = 0;
/**
* The cached value of the '{@link #getStartPosition() <em>Start Position</em>}' attribute. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @see #getStartPosition()
* @generated
* @ordered
*/
protected int startPosition = START_POSITION_EDEFAULT;
/**
* The default value of the '{@link #getEndPosition() <em>End Position</em>}' attribute. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @see #getEndPosition()
* @generated
* @ordered
*/
protected static final int END_POSITION_EDEFAULT = 0;
/**
* The cached value of the '{@link #getEndPosition() <em>End Position</em>}' attribute. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @see #getEndPosition()
* @generated
* @ordered
*/
protected int endPosition = END_POSITION_EDEFAULT;
/**
* 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 default value of the '{@link #getType() <em>Type</em>}' attribute. <!-- begin-user-doc --> <!--
* end-user-doc -->
*
* @see #getType()
* @generated
* @ordered
*/
protected static final String TYPE_EDEFAULT = null;
/**
* The cached value of the '{@link #getType() <em>Type</em>}' attribute. <!-- begin-user-doc --> <!--
* end-user-doc -->
*
* @see #getType()
* @generated
* @ordered
*/
protected String type = TYPE_EDEFAULT;
/**
* The cached value of the '{@link #getInitExpression() <em>Init Expression</em>}' containment reference.
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @see #getInitExpression()
* @generated
* @ordered
*/
protected ModelExpression initExpression;
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
protected VariableImpl() {
super();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return CstPackage.Literals.VARIABLE;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public int getStartPosition() {
return startPosition;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public void setStartPosition(int newStartPosition) {
int oldStartPosition = startPosition;
startPosition = newStartPosition;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CstPackage.VARIABLE__START_POSITION,
oldStartPosition, startPosition));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public int getEndPosition() {
return endPosition;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public void setEndPosition(int newEndPosition) {
int oldEndPosition = endPosition;
endPosition = newEndPosition;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CstPackage.VARIABLE__END_POSITION,
oldEndPosition, endPosition));
}
/**
* <!-- 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, CstPackage.VARIABLE__NAME, oldName, name));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public String getType() {
return type;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public void setType(String newType) {
String oldType = type;
type = newType;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CstPackage.VARIABLE__TYPE, oldType, type));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public ModelExpression getInitExpression() {
return initExpression;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public NotificationChain basicSetInitExpression(ModelExpression newInitExpression, NotificationChain msgs) {
ModelExpression oldInitExpression = initExpression;
initExpression = newInitExpression;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
CstPackage.VARIABLE__INIT_EXPRESSION, oldInitExpression, newInitExpression);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public void setInitExpression(ModelExpression newInitExpression) {
if (newInitExpression != initExpression) {
NotificationChain msgs = null;
if (initExpression != null)
msgs = ((InternalEObject)initExpression).eInverseRemove(this, EOPPOSITE_FEATURE_BASE
- CstPackage.VARIABLE__INIT_EXPRESSION, null, msgs);
if (newInitExpression != null)
msgs = ((InternalEObject)newInitExpression).eInverseAdd(this, EOPPOSITE_FEATURE_BASE
- CstPackage.VARIABLE__INIT_EXPRESSION, null, msgs);
msgs = basicSetInitExpression(newInitExpression, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CstPackage.VARIABLE__INIT_EXPRESSION,
newInitExpression, newInitExpression));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case CstPackage.VARIABLE__INIT_EXPRESSION:
return basicSetInitExpression(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 CstPackage.VARIABLE__START_POSITION:
return new Integer(getStartPosition());
case CstPackage.VARIABLE__END_POSITION:
return new Integer(getEndPosition());
case CstPackage.VARIABLE__NAME:
return getName();
case CstPackage.VARIABLE__TYPE:
return getType();
case CstPackage.VARIABLE__INIT_EXPRESSION:
return getInitExpression();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case CstPackage.VARIABLE__START_POSITION:
setStartPosition(((Integer)newValue).intValue());
return;
case CstPackage.VARIABLE__END_POSITION:
setEndPosition(((Integer)newValue).intValue());
return;
case CstPackage.VARIABLE__NAME:
setName((String)newValue);
return;
case CstPackage.VARIABLE__TYPE:
setType((String)newValue);
return;
case CstPackage.VARIABLE__INIT_EXPRESSION:
setInitExpression((ModelExpression)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case CstPackage.VARIABLE__START_POSITION:
setStartPosition(START_POSITION_EDEFAULT);
return;
case CstPackage.VARIABLE__END_POSITION:
setEndPosition(END_POSITION_EDEFAULT);
return;
case CstPackage.VARIABLE__NAME:
setName(NAME_EDEFAULT);
return;
case CstPackage.VARIABLE__TYPE:
setType(TYPE_EDEFAULT);
return;
case CstPackage.VARIABLE__INIT_EXPRESSION:
setInitExpression((ModelExpression)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case CstPackage.VARIABLE__START_POSITION:
return startPosition != START_POSITION_EDEFAULT;
case CstPackage.VARIABLE__END_POSITION:
return endPosition != END_POSITION_EDEFAULT;
case CstPackage.VARIABLE__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case CstPackage.VARIABLE__TYPE:
return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type);
case CstPackage.VARIABLE__INIT_EXPRESSION:
return initExpression != 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(" (startPosition: "); //$NON-NLS-1$
result.append(startPosition);
result.append(", endPosition: "); //$NON-NLS-1$
result.append(endPosition);
result.append(", name: "); //$NON-NLS-1$
result.append(name);
result.append(", type: "); //$NON-NLS-1$
result.append(type);
result.append(')');
return result.toString();
}
} // VariableImpl