001    /**
002     * <copyright>
003     * </copyright>
004     *
005     * $Id$
006     */
007    package com.hammurapi.party.impl;
008    
009    import com.hammurapi.party.Party;
010    import com.hammurapi.party.PartyPackage;
011    import com.hammurapi.party.Tag;
012    import com.hammurapi.party.Web;
013    
014    import java.util.Collection;
015    import java.util.Date;
016    
017    import org.eclipse.emf.common.notify.Notification;
018    import org.eclipse.emf.common.notify.NotificationChain;
019    
020    import org.eclipse.emf.common.util.EList;
021    
022    import org.eclipse.emf.ecore.EClass;
023    import org.eclipse.emf.ecore.InternalEObject;
024    
025    import org.eclipse.emf.ecore.impl.ENotificationImpl;
026    import org.eclipse.emf.ecore.impl.EObjectImpl;
027    
028    import org.eclipse.emf.ecore.util.EObjectContainmentEList;
029    import org.eclipse.emf.ecore.util.EcoreUtil;
030    import org.eclipse.emf.ecore.util.InternalEList;
031    
032    /**
033     * <!-- begin-user-doc -->
034     * An implementation of the model object '<em><b>Web</b></em>'.
035     * <!-- end-user-doc -->
036     * <p>
037     * The following features are implemented:
038     * <ul>
039     *   <li>{@link com.hammurapi.party.impl.WebImpl#getTags <em>Tags</em>}</li>
040     *   <li>{@link com.hammurapi.party.impl.WebImpl#getComment <em>Comment</em>}</li>
041     *   <li>{@link com.hammurapi.party.impl.WebImpl#getStart <em>Start</em>}</li>
042     *   <li>{@link com.hammurapi.party.impl.WebImpl#getEnd <em>End</em>}</li>
043     *   <li>{@link com.hammurapi.party.impl.WebImpl#getCategory <em>Category</em>}</li>
044     *   <li>{@link com.hammurapi.party.impl.WebImpl#getOwner <em>Owner</em>}</li>
045     *   <li>{@link com.hammurapi.party.impl.WebImpl#getAddress <em>Address</em>}</li>
046     * </ul>
047     * </p>
048     *
049     * @generated
050     */
051    public class WebImpl extends EObjectImpl implements Web {
052            /**
053             * The cached value of the '{@link #getTags() <em>Tags</em>}' containment reference list.
054             * <!-- begin-user-doc -->
055             * <!-- end-user-doc -->
056             * @see #getTags()
057             * @generated
058             * @ordered
059             */
060            protected EList<Tag> tags;
061    
062            /**
063             * The default value of the '{@link #getComment() <em>Comment</em>}' attribute.
064             * <!-- begin-user-doc -->
065             * <!-- end-user-doc -->
066             * @see #getComment()
067             * @generated
068             * @ordered
069             */
070            protected static final String COMMENT_EDEFAULT = null;
071    
072            /**
073             * The cached value of the '{@link #getComment() <em>Comment</em>}' attribute.
074             * <!-- begin-user-doc -->
075             * <!-- end-user-doc -->
076             * @see #getComment()
077             * @generated
078             * @ordered
079             */
080            protected String comment = COMMENT_EDEFAULT;
081    
082            /**
083             * The default value of the '{@link #getStart() <em>Start</em>}' attribute.
084             * <!-- begin-user-doc -->
085             * <!-- end-user-doc -->
086             * @see #getStart()
087             * @generated
088             * @ordered
089             */
090            protected static final Date START_EDEFAULT = null;
091    
092            /**
093             * The cached value of the '{@link #getStart() <em>Start</em>}' attribute.
094             * <!-- begin-user-doc -->
095             * <!-- end-user-doc -->
096             * @see #getStart()
097             * @generated
098             * @ordered
099             */
100            protected Date start = START_EDEFAULT;
101    
102            /**
103             * The default value of the '{@link #getEnd() <em>End</em>}' attribute.
104             * <!-- begin-user-doc -->
105             * <!-- end-user-doc -->
106             * @see #getEnd()
107             * @generated
108             * @ordered
109             */
110            protected static final Date END_EDEFAULT = null;
111    
112            /**
113             * The cached value of the '{@link #getEnd() <em>End</em>}' attribute.
114             * <!-- begin-user-doc -->
115             * <!-- end-user-doc -->
116             * @see #getEnd()
117             * @generated
118             * @ordered
119             */
120            protected Date end = END_EDEFAULT;
121    
122            /**
123             * The default value of the '{@link #getCategory() <em>Category</em>}' attribute.
124             * <!-- begin-user-doc -->
125             * <!-- end-user-doc -->
126             * @see #getCategory()
127             * @generated
128             * @ordered
129             */
130            protected static final String CATEGORY_EDEFAULT = null;
131    
132            /**
133             * The cached value of the '{@link #getCategory() <em>Category</em>}' attribute.
134             * <!-- begin-user-doc -->
135             * <!-- end-user-doc -->
136             * @see #getCategory()
137             * @generated
138             * @ordered
139             */
140            protected String category = CATEGORY_EDEFAULT;
141    
142            /**
143             * The default value of the '{@link #getAddress() <em>Address</em>}' attribute.
144             * <!-- begin-user-doc -->
145             * <!-- end-user-doc -->
146             * @see #getAddress()
147             * @generated
148             * @ordered
149             */
150            protected static final String ADDRESS_EDEFAULT = null;
151    
152            /**
153             * The cached value of the '{@link #getAddress() <em>Address</em>}' attribute.
154             * <!-- begin-user-doc -->
155             * <!-- end-user-doc -->
156             * @see #getAddress()
157             * @generated
158             * @ordered
159             */
160            protected String address = ADDRESS_EDEFAULT;
161    
162            /**
163             * <!-- begin-user-doc -->
164             * <!-- end-user-doc -->
165             * @generated
166             */
167            protected WebImpl() {
168                    super();
169            }
170    
171            /**
172             * <!-- begin-user-doc -->
173             * <!-- end-user-doc -->
174             * @generated
175             */
176            @Override
177            protected EClass eStaticClass() {
178                    return PartyPackage.Literals.WEB;
179            }
180    
181            /**
182             * <!-- begin-user-doc -->
183             * <!-- end-user-doc -->
184             * @generated
185             */
186            public EList<Tag> getTags() {
187                    if (tags == null) {
188                            tags = new EObjectContainmentEList<Tag>(Tag.class, this, PartyPackage.WEB__TAGS);
189                    }
190                    return tags;
191            }
192    
193            /**
194             * <!-- begin-user-doc -->
195             * <!-- end-user-doc -->
196             * @generated
197             */
198            public String getComment() {
199                    return comment;
200            }
201    
202            /**
203             * <!-- begin-user-doc -->
204             * <!-- end-user-doc -->
205             * @generated
206             */
207            public void setComment(String newComment) {
208                    String oldComment = comment;
209                    comment = newComment;
210                    if (eNotificationRequired())
211                            eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.WEB__COMMENT, oldComment, comment));
212            }
213    
214            /**
215             * <!-- begin-user-doc -->
216             * <!-- end-user-doc -->
217             * @generated
218             */
219            public Date getStart() {
220                    return start;
221            }
222    
223            /**
224             * <!-- begin-user-doc -->
225             * <!-- end-user-doc -->
226             * @generated
227             */
228            public void setStart(Date newStart) {
229                    Date oldStart = start;
230                    start = newStart;
231                    if (eNotificationRequired())
232                            eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.WEB__START, oldStart, start));
233            }
234    
235            /**
236             * <!-- begin-user-doc -->
237             * <!-- end-user-doc -->
238             * @generated
239             */
240            public Date getEnd() {
241                    return end;
242            }
243    
244            /**
245             * <!-- begin-user-doc -->
246             * <!-- end-user-doc -->
247             * @generated
248             */
249            public void setEnd(Date newEnd) {
250                    Date oldEnd = end;
251                    end = newEnd;
252                    if (eNotificationRequired())
253                            eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.WEB__END, oldEnd, end));
254            }
255    
256            /**
257             * <!-- begin-user-doc -->
258             * <!-- end-user-doc -->
259             * @generated
260             */
261            public String getCategory() {
262                    return category;
263            }
264    
265            /**
266             * <!-- begin-user-doc -->
267             * <!-- end-user-doc -->
268             * @generated
269             */
270            public void setCategory(String newCategory) {
271                    String oldCategory = category;
272                    category = newCategory;
273                    if (eNotificationRequired())
274                            eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.WEB__CATEGORY, oldCategory, category));
275            }
276    
277            /**
278             * <!-- begin-user-doc -->
279             * <!-- end-user-doc -->
280             * @generated
281             */
282            public Party getOwner() {
283                    if (eContainerFeatureID() != PartyPackage.WEB__OWNER) return null;
284                    return (Party)eContainer();
285            }
286    
287            /**
288             * <!-- begin-user-doc -->
289             * <!-- end-user-doc -->
290             * @generated
291             */
292            public NotificationChain basicSetOwner(Party newOwner, NotificationChain msgs) {
293                    msgs = eBasicSetContainer((InternalEObject)newOwner, PartyPackage.WEB__OWNER, msgs);
294                    return msgs;
295            }
296    
297            /**
298             * <!-- begin-user-doc -->
299             * <!-- end-user-doc -->
300             * @generated
301             */
302            public void setOwner(Party newOwner) {
303                    if (newOwner != eInternalContainer() || (eContainerFeatureID() != PartyPackage.WEB__OWNER && newOwner != null)) {
304                            if (EcoreUtil.isAncestor(this, newOwner))
305                                    throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
306                            NotificationChain msgs = null;
307                            if (eInternalContainer() != null)
308                                    msgs = eBasicRemoveFromContainer(msgs);
309                            if (newOwner != null)
310                                    msgs = ((InternalEObject)newOwner).eInverseAdd(this, PartyPackage.PARTY__CONTACT_INFO, Party.class, msgs);
311                            msgs = basicSetOwner(newOwner, msgs);
312                            if (msgs != null) msgs.dispatch();
313                    }
314                    else if (eNotificationRequired())
315                            eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.WEB__OWNER, newOwner, newOwner));
316            }
317    
318            /**
319             * <!-- begin-user-doc -->
320             * <!-- end-user-doc -->
321             * @generated
322             */
323            public String getAddress() {
324                    return address;
325            }
326    
327            /**
328             * <!-- begin-user-doc -->
329             * <!-- end-user-doc -->
330             * @generated
331             */
332            public void setAddress(String newAddress) {
333                    String oldAddress = address;
334                    address = newAddress;
335                    if (eNotificationRequired())
336                            eNotify(new ENotificationImpl(this, Notification.SET, PartyPackage.WEB__ADDRESS, oldAddress, address));
337            }
338    
339    
340            /**
341             * <!-- begin-user-doc -->
342             * <!-- end-user-doc -->
343             * @generated NOT
344             */
345            public boolean isEffectiveNow() {
346                    return isEffective(new Date());
347            }
348    
349            /**
350             * <!-- begin-user-doc -->
351             * <!-- end-user-doc -->
352             * @generated NOT
353             */
354            public boolean isEffective(Date date) {
355                    if (getStart()!=null && getStart().after(date)) {
356                            return false;
357                    }
358                    
359                    if (getEnd()!=null && getEnd().before(date)) {
360                            return false;
361                    }
362                    
363                    return true;
364            }
365    
366            /**
367             * <!-- begin-user-doc -->
368             * <!-- end-user-doc -->
369             * @generated
370             */
371            @Override
372            public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
373                    switch (featureID) {
374                            case PartyPackage.WEB__OWNER:
375                                    if (eInternalContainer() != null)
376                                            msgs = eBasicRemoveFromContainer(msgs);
377                                    return basicSetOwner((Party)otherEnd, msgs);
378                    }
379                    return super.eInverseAdd(otherEnd, featureID, msgs);
380            }
381    
382            /**
383             * <!-- begin-user-doc -->
384             * <!-- end-user-doc -->
385             * @generated
386             */
387            @Override
388            public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
389                    switch (featureID) {
390                            case PartyPackage.WEB__TAGS:
391                                    return ((InternalEList<?>)getTags()).basicRemove(otherEnd, msgs);
392                            case PartyPackage.WEB__OWNER:
393                                    return basicSetOwner(null, msgs);
394                    }
395                    return super.eInverseRemove(otherEnd, featureID, msgs);
396            }
397    
398            /**
399             * <!-- begin-user-doc -->
400             * <!-- end-user-doc -->
401             * @generated
402             */
403            @Override
404            public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
405                    switch (eContainerFeatureID()) {
406                            case PartyPackage.WEB__OWNER:
407                                    return eInternalContainer().eInverseRemove(this, PartyPackage.PARTY__CONTACT_INFO, Party.class, msgs);
408                    }
409                    return super.eBasicRemoveFromContainerFeature(msgs);
410            }
411    
412            /**
413             * <!-- begin-user-doc -->
414             * <!-- end-user-doc -->
415             * @generated
416             */
417            @Override
418            public Object eGet(int featureID, boolean resolve, boolean coreType) {
419                    switch (featureID) {
420                            case PartyPackage.WEB__TAGS:
421                                    return getTags();
422                            case PartyPackage.WEB__COMMENT:
423                                    return getComment();
424                            case PartyPackage.WEB__START:
425                                    return getStart();
426                            case PartyPackage.WEB__END:
427                                    return getEnd();
428                            case PartyPackage.WEB__CATEGORY:
429                                    return getCategory();
430                            case PartyPackage.WEB__OWNER:
431                                    return getOwner();
432                            case PartyPackage.WEB__ADDRESS:
433                                    return getAddress();
434                    }
435                    return super.eGet(featureID, resolve, coreType);
436            }
437    
438            /**
439             * <!-- begin-user-doc -->
440             * <!-- end-user-doc -->
441             * @generated
442             */
443            @SuppressWarnings("unchecked")
444            @Override
445            public void eSet(int featureID, Object newValue) {
446                    switch (featureID) {
447                            case PartyPackage.WEB__TAGS:
448                                    getTags().clear();
449                                    getTags().addAll((Collection<? extends Tag>)newValue);
450                                    return;
451                            case PartyPackage.WEB__COMMENT:
452                                    setComment((String)newValue);
453                                    return;
454                            case PartyPackage.WEB__START:
455                                    setStart((Date)newValue);
456                                    return;
457                            case PartyPackage.WEB__END:
458                                    setEnd((Date)newValue);
459                                    return;
460                            case PartyPackage.WEB__CATEGORY:
461                                    setCategory((String)newValue);
462                                    return;
463                            case PartyPackage.WEB__OWNER:
464                                    setOwner((Party)newValue);
465                                    return;
466                            case PartyPackage.WEB__ADDRESS:
467                                    setAddress((String)newValue);
468                                    return;
469                    }
470                    super.eSet(featureID, newValue);
471            }
472    
473            /**
474             * <!-- begin-user-doc -->
475             * <!-- end-user-doc -->
476             * @generated
477             */
478            @Override
479            public void eUnset(int featureID) {
480                    switch (featureID) {
481                            case PartyPackage.WEB__TAGS:
482                                    getTags().clear();
483                                    return;
484                            case PartyPackage.WEB__COMMENT:
485                                    setComment(COMMENT_EDEFAULT);
486                                    return;
487                            case PartyPackage.WEB__START:
488                                    setStart(START_EDEFAULT);
489                                    return;
490                            case PartyPackage.WEB__END:
491                                    setEnd(END_EDEFAULT);
492                                    return;
493                            case PartyPackage.WEB__CATEGORY:
494                                    setCategory(CATEGORY_EDEFAULT);
495                                    return;
496                            case PartyPackage.WEB__OWNER:
497                                    setOwner((Party)null);
498                                    return;
499                            case PartyPackage.WEB__ADDRESS:
500                                    setAddress(ADDRESS_EDEFAULT);
501                                    return;
502                    }
503                    super.eUnset(featureID);
504            }
505    
506            /**
507             * <!-- begin-user-doc -->
508             * <!-- end-user-doc -->
509             * @generated
510             */
511            @Override
512            public boolean eIsSet(int featureID) {
513                    switch (featureID) {
514                            case PartyPackage.WEB__TAGS:
515                                    return tags != null && !tags.isEmpty();
516                            case PartyPackage.WEB__COMMENT:
517                                    return COMMENT_EDEFAULT == null ? comment != null : !COMMENT_EDEFAULT.equals(comment);
518                            case PartyPackage.WEB__START:
519                                    return START_EDEFAULT == null ? start != null : !START_EDEFAULT.equals(start);
520                            case PartyPackage.WEB__END:
521                                    return END_EDEFAULT == null ? end != null : !END_EDEFAULT.equals(end);
522                            case PartyPackage.WEB__CATEGORY:
523                                    return CATEGORY_EDEFAULT == null ? category != null : !CATEGORY_EDEFAULT.equals(category);
524                            case PartyPackage.WEB__OWNER:
525                                    return getOwner() != null;
526                            case PartyPackage.WEB__ADDRESS:
527                                    return ADDRESS_EDEFAULT == null ? address != null : !ADDRESS_EDEFAULT.equals(address);
528                    }
529                    return super.eIsSet(featureID);
530            }
531    
532            /**
533             * <!-- begin-user-doc -->
534             * <!-- end-user-doc -->
535             * @generated
536             */
537            @Override
538            public String toString() {
539                    if (eIsProxy()) return super.toString();
540    
541                    StringBuffer result = new StringBuffer(super.toString());
542                    result.append(" (comment: ");
543                    result.append(comment);
544                    result.append(", start: ");
545                    result.append(start);
546                    result.append(", end: ");
547                    result.append(end);
548                    result.append(", category: ");
549                    result.append(category);
550                    result.append(", address: ");
551                    result.append(address);
552                    result.append(')');
553                    return result.toString();
554            }
555    
556    } //WebImpl