KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > util > EObjectWithInverseEList


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: EObjectWithInverseEList.java,v 1.2 2005/06/08 06:20:10 nickb Exp $
16  */

17 package org.eclipse.emf.ecore.util;
18
19
20 import org.eclipse.emf.common.notify.Notification;
21 import org.eclipse.emf.ecore.InternalEObject;
22
23
24 public class EObjectWithInverseEList extends EObjectEList
25 {
26   public static class Unsettable extends EObjectWithInverseEList
27   {
28     public static class ManyInverse extends Unsettable
29     {
30       public ManyInverse(Class JavaDoc dataClass, InternalEObject owner, int featureID, int inverseFeatureID)
31       {
32         super(dataClass, owner, featureID, inverseFeatureID);
33       }
34
35       protected boolean hasManyInverse()
36       {
37         return true;
38       }
39     }
40
41     protected boolean isSet;
42
43     public Unsettable(Class JavaDoc dataClass, InternalEObject owner, int featureID, int inverseFeatureID)
44     {
45       super(dataClass, owner, featureID, inverseFeatureID);
46     }
47
48     protected void didChange()
49     {
50       isSet = true;
51     }
52
53     public boolean isSet()
54     {
55       return isSet;
56     }
57
58     public void unset()
59     {
60       super.unset();
61       if (isNotificationRequired())
62       {
63         boolean oldIsSet = isSet;
64         isSet = false;
65         owner.eNotify(createNotification(Notification.UNSET, oldIsSet, false));
66       }
67       else
68       {
69         isSet = false;
70       }
71     }
72   }
73
74   public static class ManyInverse extends EObjectWithInverseEList
75   {
76     public ManyInverse(Class JavaDoc dataClass, InternalEObject owner, int featureID, int inverseFeatureID)
77     {
78       super(dataClass, owner, featureID, inverseFeatureID);
79     }
80
81     protected boolean hasManyInverse()
82     {
83       return true;
84     }
85   }
86
87   protected final int inverseFeatureID;
88
89   public EObjectWithInverseEList
90     (Class JavaDoc dataClass, InternalEObject owner, int featureID, int inverseFeatureID)
91   {
92     super(dataClass, owner, featureID);
93     this.inverseFeatureID = inverseFeatureID;
94   }
95
96   protected boolean hasInverse()
97   {
98     return true;
99   }
100
101   protected boolean hasNavigableInverse()
102   {
103     return true;
104   }
105
106   public int getInverseFeatureID()
107   {
108     return inverseFeatureID;
109   }
110   
111   public Class JavaDoc getInverseFeatureClass()
112   {
113     return dataClass;
114   }
115 }
116
Popular Tags