001: /**
002: * <copyright>
003: * </copyright>
004: *
005: * $Id$
006: */package newprocess.impl;
007:
008: import java.util.Collection;
009:
010: import newprocess.Expression;
011: import newprocess.NewprocessPackage;
012: import newprocess.Root;
013: import newprocess.Term;
014: import newprocess.validation.ExpressionValidator;
015: import newprocess.validation.ExpressionValidatorImpl;
016:
017: import org.eclipse.emf.common.notify.Notification;
018: import org.eclipse.emf.common.notify.NotificationChain;
019: import org.eclipse.emf.common.util.EList;
020: import org.eclipse.emf.ecore.EClass;
021: import org.eclipse.emf.ecore.InternalEObject;
022: import org.eclipse.emf.ecore.impl.ENotificationImpl;
023: import org.eclipse.emf.ecore.impl.EObjectImpl;
024: import org.eclipse.emf.ecore.util.EObjectContainmentEList;
025: import org.eclipse.emf.ecore.util.InternalEList;
026:
027: /**
028: * <!-- begin-user-doc -->
029: * An implementation of the model object '<em><b>Expression</b></em>'.
030: * <!-- end-user-doc -->
031: * <p>
032: * The following features are implemented:
033: * <ul>
034: * <li>{@link newprocess.impl.ExpressionImpl#getExpression <em>Expression</em>}</li>
035: * <li>{@link newprocess.impl.ExpressionImpl#getHasTerms <em>Has Terms</em>}</li>
036: * <li>{@link newprocess.impl.ExpressionImpl#getHasRoot <em>Has Root</em>}</li>
037: * </ul>
038: * </p>
039: *
040: * @generated NOT
041: * @author sh
042: */
043: public class ExpressionImpl extends EObjectImpl implements Expression,
044: ExpressionValidator {
045:
046: /**
047: * The default value of the '{@link #getExpression() <em>Expression</em>}' attribute.
048: * <!-- begin-user-doc -->
049: * <!-- end-user-doc -->
050: * @see #getExpression()
051: * @generated
052: * @ordered
053: */
054: protected static final String EXPRESSION_EDEFAULT = null;
055:
056: /**
057: * The cached value of the '{@link #getExpression() <em>Expression</em>}' attribute.
058: * <!-- begin-user-doc -->
059: * <!-- end-user-doc -->
060: * @see #getExpression()
061: * @generated
062: * @ordered
063: */
064: protected String expression = EXPRESSION_EDEFAULT;
065:
066: /**
067: * The cached value of the '{@link #getHasTerms() <em>Has Terms</em>}' containment reference list.
068: * <!-- begin-user-doc -->
069: * <!-- end-user-doc -->
070: * @see #getHasTerms()
071: * @generated
072: * @ordered
073: */
074: protected EList<Term> hasTerms = null;
075:
076: /**
077: * The cached value of the '{@link #getHasRoot() <em>Has Root</em>}' containment reference.
078: * <!-- begin-user-doc -->
079: * <!-- end-user-doc -->
080: * @see #getHasRoot()
081: * @generated
082: * @ordered
083: */
084: protected Root hasRoot = null;
085:
086: /**
087: * <!-- begin-user-doc -->
088: * <!-- end-user-doc -->
089: * @generated
090: */
091: protected ExpressionImpl() {
092: super ();
093: }
094:
095: /**
096: * <!-- begin-user-doc -->
097: * <!-- end-user-doc -->
098: * @generated
099: */
100: @Override
101: protected EClass eStaticClass() {
102: return NewprocessPackage.Literals.EXPRESSION;
103: }
104:
105: /**
106: * <!-- begin-user-doc -->
107: * <!-- end-user-doc -->
108: * @generated
109: */
110: public String getExpression() {
111: return expression;
112: }
113:
114: /**
115: * <!-- begin-user-doc -->
116: * <!-- end-user-doc -->
117: * @generated
118: */
119: public void setExpression(String newExpression) {
120: String oldExpression = expression;
121: expression = newExpression;
122: if (eNotificationRequired())
123: eNotify(new ENotificationImpl(this , Notification.SET,
124: NewprocessPackage.EXPRESSION__EXPRESSION,
125: oldExpression, expression));
126: }
127:
128: /**
129: * <!-- begin-user-doc -->
130: * <!-- end-user-doc -->
131: * @generated
132: */
133: public EList<Term> getHasTerms() {
134: if (hasTerms == null) {
135: hasTerms = new EObjectContainmentEList<Term>(Term.class,
136: this , NewprocessPackage.EXPRESSION__HAS_TERMS);
137: }
138: return hasTerms;
139: }
140:
141: /**
142: * <!-- begin-user-doc -->
143: * <!-- end-user-doc -->
144: * @generated
145: */
146: public Root getHasRoot() {
147: return hasRoot;
148: }
149:
150: /**
151: * <!-- begin-user-doc -->
152: * <!-- end-user-doc -->
153: * @generated
154: */
155: public NotificationChain basicSetHasRoot(Root newHasRoot,
156: NotificationChain msgs) {
157: Root oldHasRoot = hasRoot;
158: hasRoot = newHasRoot;
159: if (eNotificationRequired()) {
160: ENotificationImpl notification = new ENotificationImpl(
161: this , Notification.SET,
162: NewprocessPackage.EXPRESSION__HAS_ROOT, oldHasRoot,
163: newHasRoot);
164: if (msgs == null)
165: msgs = notification;
166: else
167: msgs.add(notification);
168: }
169: return msgs;
170: }
171:
172: /**
173: * <!-- begin-user-doc -->
174: * <!-- end-user-doc -->
175: * @generated
176: */
177: public void setHasRoot(Root newHasRoot) {
178: if (newHasRoot != hasRoot) {
179: NotificationChain msgs = null;
180: if (hasRoot != null)
181: msgs = ((InternalEObject) hasRoot)
182: .eInverseRemove(
183: this ,
184: EOPPOSITE_FEATURE_BASE
185: - NewprocessPackage.EXPRESSION__HAS_ROOT,
186: null, msgs);
187: if (newHasRoot != null)
188: msgs = ((InternalEObject) newHasRoot)
189: .eInverseAdd(
190: this ,
191: EOPPOSITE_FEATURE_BASE
192: - NewprocessPackage.EXPRESSION__HAS_ROOT,
193: null, msgs);
194: msgs = basicSetHasRoot(newHasRoot, msgs);
195: if (msgs != null)
196: msgs.dispatch();
197: } else if (eNotificationRequired())
198: eNotify(new ENotificationImpl(this , Notification.SET,
199: NewprocessPackage.EXPRESSION__HAS_ROOT, newHasRoot,
200: newHasRoot));
201: }
202:
203: /**
204: * <!-- begin-user-doc -->
205: * update conditions expression
206: * <!-- end-user-doc -->
207: * @generated NOT
208: * @author sh
209: */
210: public void updateExpression() {
211: if (getHasRoot() != null)
212: setExpression(getHasRoot().getExpression());
213: }
214:
215: /**
216: * <!-- begin-user-doc -->
217: * <!-- end-user-doc -->
218: * @generated
219: */
220: public void updateName() {
221: // TODO: implement this method
222: // Ensure that you remove @generated or mark it @generated NOT
223: throw new UnsupportedOperationException();
224: }
225:
226: /**
227: * <!-- begin-user-doc -->
228: * <!-- end-user-doc -->
229: * @generated NOT
230: * @author sh
231: */
232: public boolean acceptOperator() {
233: if (getHasRoot() == null)
234: return false; // error we are missing an root port
235: else
236: return getHasRoot().acceptOperator(); // ask the root port
237: }
238:
239: /**
240: * <!-- begin-user-doc -->
241: * return the decoration hint for diagramms, depending on the containment feature
242: * <!-- end-user-doc -->
243: * @generated NOT
244: * @author sh
245: */
246: public int decorateLink() {
247: /*
248: if (eContainer() instanceof AbstractActivity) {
249: if (((AbstractActivity)eContainer()).getHasPrecondition() == this)
250: return DECORATION_SOURCE;
251: if (((AbstractActivity)eContainer()).getHasPostcondition() == this)
252: return DECORATION_TARGET;
253: }
254: */
255: return DECORATION_NONE; // it must be a Child of Process, a modelling abstraction
256: }
257:
258: /**
259: * <!-- begin-user-doc -->
260: * <!-- end-user-doc -->
261: * @generated
262: */
263: @Override
264: public NotificationChain eInverseRemove(InternalEObject otherEnd,
265: int featureID, NotificationChain msgs) {
266: switch (featureID) {
267: case NewprocessPackage.EXPRESSION__HAS_TERMS:
268: return ((InternalEList<?>) getHasTerms()).basicRemove(
269: otherEnd, msgs);
270: case NewprocessPackage.EXPRESSION__HAS_ROOT:
271: return basicSetHasRoot(null, msgs);
272: }
273: return super .eInverseRemove(otherEnd, featureID, msgs);
274: }
275:
276: /**
277: * <!-- begin-user-doc -->
278: * <!-- end-user-doc -->
279: * @generated
280: */
281: @Override
282: public Object eGet(int featureID, boolean resolve, boolean coreType) {
283: switch (featureID) {
284: case NewprocessPackage.EXPRESSION__EXPRESSION:
285: return getExpression();
286: case NewprocessPackage.EXPRESSION__HAS_TERMS:
287: return getHasTerms();
288: case NewprocessPackage.EXPRESSION__HAS_ROOT:
289: return getHasRoot();
290: }
291: return super .eGet(featureID, resolve, coreType);
292: }
293:
294: /**
295: * <!-- begin-user-doc -->
296: * <!-- end-user-doc -->
297: * @generated
298: */
299: @SuppressWarnings("unchecked")
300: @Override
301: public void eSet(int featureID, Object newValue) {
302: switch (featureID) {
303: case NewprocessPackage.EXPRESSION__EXPRESSION:
304: setExpression((String) newValue);
305: return;
306: case NewprocessPackage.EXPRESSION__HAS_TERMS:
307: getHasTerms().clear();
308: getHasTerms().addAll((Collection<? extends Term>) newValue);
309: return;
310: case NewprocessPackage.EXPRESSION__HAS_ROOT:
311: setHasRoot((Root) newValue);
312: return;
313: }
314: super .eSet(featureID, newValue);
315: }
316:
317: /**
318: * <!-- begin-user-doc -->
319: * <!-- end-user-doc -->
320: * @generated
321: */
322: @Override
323: public void eUnset(int featureID) {
324: switch (featureID) {
325: case NewprocessPackage.EXPRESSION__EXPRESSION:
326: setExpression(EXPRESSION_EDEFAULT);
327: return;
328: case NewprocessPackage.EXPRESSION__HAS_TERMS:
329: getHasTerms().clear();
330: return;
331: case NewprocessPackage.EXPRESSION__HAS_ROOT:
332: setHasRoot((Root) null);
333: return;
334: }
335: super .eUnset(featureID);
336: }
337:
338: /**
339: * <!-- begin-user-doc -->
340: * <!-- end-user-doc -->
341: * @generated
342: */
343: @Override
344: public boolean eIsSet(int featureID) {
345: switch (featureID) {
346: case NewprocessPackage.EXPRESSION__EXPRESSION:
347: return EXPRESSION_EDEFAULT == null ? expression != null
348: : !EXPRESSION_EDEFAULT.equals(expression);
349: case NewprocessPackage.EXPRESSION__HAS_TERMS:
350: return hasTerms != null && !hasTerms.isEmpty();
351: case NewprocessPackage.EXPRESSION__HAS_ROOT:
352: return hasRoot != null;
353: }
354: return super .eIsSet(featureID);
355: }
356:
357: /**
358: * <!-- begin-user-doc -->
359: * <!-- end-user-doc -->
360: * @generated
361: */
362: @Override
363: public String toString() {
364: if (eIsProxy())
365: return super .toString();
366:
367: StringBuffer result = new StringBuffer(super .toString());
368: result.append(" (expression: ");
369: result.append(expression);
370: result.append(')');
371: return result.toString();
372: }
373:
374: /**
375: * Validates the Expression of the Expression
376: * @author sh
377: */
378: public boolean validateExpression(Expression expr) {
379: return ExpressionValidatorImpl.INSTANCE
380: .validateExpression(expr);
381: }
382: } //ExpressionImpl
|