Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 255469 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/ocl/ecore/tests/AbstractTestSuite.java (-1 / +2 lines)
Lines 9-15 Link Here
9
 *
9
 *
10
 * Contributors:
10
 * Contributors:
11
 *   IBM - Initial API and implementation
11
 *   IBM - Initial API and implementation
12
 *   Zeligsoft - Bugs 243079, 244948, 244886, 245619
12
 *   Zeligsoft - Bugs 243079, 244948, 244886, 245619, 216701
13
 *
13
 *
14
 * </copyright>
14
 * </copyright>
15
 *
15
 *
Lines 162-167 Link Here
162
		result.addTest(RegressionTest.suite());
162
		result.addTest(RegressionTest.suite());
163
		result.addTest(EcoreEnvironmentTest.suite());
163
		result.addTest(EcoreEnvironmentTest.suite());
164
        result.addTest(ExtensibilityTest.suite());
164
        result.addTest(ExtensibilityTest.suite());
165
        result.addTest(OCLSettingDelegateTest.suite());
165
		result.addTest(ValidationTest.suite());
166
		result.addTest(ValidationTest.suite());
166
		result.addTest(ProblemOptionTest.suite());
167
		result.addTest(ProblemOptionTest.suite());
167
		result.addTest(ParsingOptionsTest.suite());
168
		result.addTest(ParsingOptionsTest.suite());
(-)src/org/eclipse/ocl/ecore/tests/OCLSettingDelegateTest.java (+331 lines)
Added Link Here
1
/**
2
 * <copyright>
3
 * 
4
 * Copyright (c) 2008 Zeligsoft Inc. 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
 *   Zeligsoft - Initial API and implementation
12
 * 
13
 * </copyright>
14
 *
15
 * $Id$
16
 */
17
18
package org.eclipse.ocl.ecore.tests;
19
20
import java.lang.reflect.InvocationTargetException;
21
import java.util.Arrays;
22
import java.util.Map;
23
24
import junit.framework.Test;
25
import junit.framework.TestSuite;
26
27
import org.eclipse.emf.common.util.BasicEList;
28
import org.eclipse.emf.common.util.ECollections;
29
import org.eclipse.emf.common.util.EList;
30
import org.eclipse.emf.common.util.Enumerator;
31
import org.eclipse.emf.common.util.URI;
32
import org.eclipse.emf.ecore.EAttribute;
33
import org.eclipse.emf.ecore.EClass;
34
import org.eclipse.emf.ecore.EEnum;
35
import org.eclipse.emf.ecore.EFactory;
36
import org.eclipse.emf.ecore.EObject;
37
import org.eclipse.emf.ecore.EOperation;
38
import org.eclipse.emf.ecore.EPackage;
39
import org.eclipse.emf.ecore.EReference;
40
import org.eclipse.emf.ecore.EStructuralFeature;
41
import org.eclipse.emf.ecore.resource.Resource;
42
import org.eclipse.emf.ecore.resource.ResourceSet;
43
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
44
import org.eclipse.ocl.ecore.dynamic.OCLCallDelegateFactory;
45
import org.eclipse.ocl.ecore.dynamic.OCLSettingDelegateFactory;
46
47
/**
48
 * Tests for the OCL setting delegate implementation.
49
 * 
50
 * @author Christian W. Damus (cdamus)
51
 */
52
@SuppressWarnings("nls")
53
public class OCLSettingDelegateTest
54
		extends AbstractTestSuite {
55
56
	private ResourceSet rset;
57
58
	private Resource testResource;
59
60
	private EPackage companyPackage;
61
62
	private EFactory companyFactory;
63
64
	private EClass companyClass;
65
66
	private EAttribute companyName;
67
68
	private EReference companyEmployees;
69
70
	private EAttribute companySize;
71
72
	private EClass employeeClass;
73
74
	private EAttribute employeeName;
75
76
	private EReference employeeManager;
77
78
	private EReference employeeDirectReports;
79
80
	private EReference employeeAllReports;
81
82
	private EOperation employeeReportsTo;
83
84
	private EEnum sizeKind;
85
86
	private Enumerator sizeSmall;
87
88
	private Enumerator sizeMedium;
89
90
	private Enumerator sizeLarge;
91
92
	private EObject acme;
93
94
	private Map<String, EObject> employees;
95
96
	public OCLSettingDelegateTest(String name) {
97
		super(name);
98
	}
99
100
	public static Test suite() {
101
		return new TestSuite(OCLSettingDelegateTest.class,
102
			"OCL Setting Delegate Tests");
103
	}
104
105
	public void test_eattributeDerivation() {
106
		assertSame(sizeSmall, size(acme));
107
108
		// add a load of employees
109
		EList<EObject> emps = employees(acme);
110
		for (int i = 0; i < 60; i++) {
111
			emps.add(companyFactory.create(employeeClass));
112
		}
113
114
		assertSame(sizeMedium, size(acme));
115
116
		// and another bunch
117
		for (int i = 0; i < 1000; i++) {
118
			emps.add(companyFactory.create(employeeClass));
119
		}
120
121
		assertSame(sizeLarge, size(acme));
122
	}
123
124
	public void test_ereferenceDerivation() {
125
		EList<EObject> amyReports = directReports(employee("Amy"));
126
		assertEquals(3, amyReports.size());
127
		assertTrue(amyReports.contains(employee("Bob")));
128
		assertTrue(amyReports.contains(employee("Jane")));
129
		assertTrue(amyReports.contains(employee("Fred")));
130
131
		EList<EObject> bobReports = directReports(employee("Bob"));
132
		assertEquals(2, bobReports.size());
133
		assertTrue(bobReports.contains(employee("Norbert")));
134
		assertTrue(bobReports.contains(employee("Sally")));
135
136
		EList<EObject> sallyReports = directReports(employee("Sally"));
137
		assertEquals(0, sallyReports.size());
138
	}
139
140
	public void test_allInstances() {
141
		EList<EObject> amyAllReports = allReports(employee("Amy"));
142
		assertEquals(5, amyAllReports.size());
143
		assertTrue(amyAllReports.contains(employee("Bob")));
144
		assertTrue(amyAllReports.contains(employee("Jane")));
145
		assertTrue(amyAllReports.contains(employee("Fred")));
146
		assertTrue(amyAllReports.contains(employee("Norbert")));
147
		assertTrue(amyAllReports.contains(employee("Sally")));
148
149
		// change the set of all instances of Employee
150
		set(create(acme, companyEmployees, employeeClass, "Manuel"),
151
			employeeManager, employee("Bob"));
152
153
		amyAllReports = allReports(employee("Amy"));
154
		assertEquals(6, amyAllReports.size());
155
		assertTrue(amyAllReports.contains(employee("Manuel")));
156
	}
157
158
	public void test_operationCall() {
159
		EObject amy = employee("Amy");
160
161
		// allReports is implemented using reportsTo()
162
		EList<EObject> amyAllReports = allReports(amy);
163
		assertEquals(5, amyAllReports.size());
164
165
		for (EObject next : amyAllReports) {
166
			assertTrue(this.<Boolean> call(next, employeeReportsTo, amy));
167
		}
168
	}
169
170
	//
171
	// Test framework
172
	//
173
174
	@Override
175
	protected void setUp()
176
			throws Exception {
177
178
		super.setUp();
179
180
		EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE
181
			.registerFactory("org.eclipse.ocl.ecore.OCL",
182
				new OCLSettingDelegateFactory());
183
		EOperation.Internal.CallDelegate.Factory.Registry.INSTANCE
184
			.registerFactory("org.eclipse.ocl.ecore.OCL",
185
				new OCLCallDelegateFactory());
186
187
		rset = new ResourceSetImpl();
188
		testResource = rset.getResource(URI.createPlatformPluginURI(
189
			"/org.eclipse.ocl.ecore.tests/model/TestCompany.xmi", true), true);
190
191
		acme = testResource.getContents().get(0);
192
193
		companyClass = acme.eClass();
194
		companyPackage = companyClass.getEPackage();
195
		companyFactory = companyPackage.getEFactoryInstance();
196
197
		companyName = (EAttribute) companyClass.getEStructuralFeature("name");
198
		companyEmployees = (EReference) companyClass
199
			.getEStructuralFeature("employees");
200
		companySize = (EAttribute) companyClass.getEStructuralFeature("size");
201
202
		employeeClass = companyEmployees.getEReferenceType();
203
		employeeName = (EAttribute) employeeClass.getEStructuralFeature("name");
204
		employeeManager = (EReference) employeeClass
205
			.getEStructuralFeature("manager");
206
		employeeDirectReports = (EReference) employeeClass
207
			.getEStructuralFeature("directReports");
208
		employeeAllReports = (EReference) employeeClass
209
			.getEStructuralFeature("allReports");
210
		employeeReportsTo = employeeClass.getEOperations().get(0);
211
212
		sizeKind = (EEnum) companySize.getEAttributeType();
213
		sizeSmall = sizeKind.getEEnumLiteral("small");
214
		sizeMedium = sizeKind.getEEnumLiteral("medium");
215
		sizeLarge = sizeKind.getEEnumLiteral("large");
216
217
		employees = new java.util.HashMap<String, EObject>();
218
	}
219
220
	@Override
221
	protected void tearDown()
222
			throws Exception {
223
224
		for (Resource next : rset.getResources()) {
225
			next.unload();
226
		}
227
		rset.getResources().clear();
228
		rset = null;
229
		testResource = null;
230
		companyPackage = null;
231
		companyFactory = null;
232
		employees = null;
233
234
		EOperation.Internal.CallDelegate.Factory.Registry.INSTANCE
235
			.deregisterFactory("org.eclipse.ocl.ecore.OCL");
236
		EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE
237
			.deregisterFactory("org.eclipse.ocl.ecore.OCL");
238
239
		super.tearDown();
240
	}
241
242
	EObject employee(String name) {
243
		EObject result = employees.get(name);
244
		if (result == null) {
245
			EList<EObject> emps = get(acme, companyEmployees);
246
			for (EObject next : emps) {
247
				if (name.equals(name(next))) {
248
					result = next;
249
					employees.put(name, result);
250
					break;
251
				}
252
			}
253
		}
254
255
		return result;
256
	}
257
258
	String name(EObject employeeOrCompany) {
259
		EAttribute name = employeeClass.isInstance(employeeOrCompany)
260
			? employeeName
261
			: companyName;
262
		return get(employeeOrCompany, name);
263
	}
264
265
	EObject manager(EObject employee) {
266
		return get(employee, employeeManager);
267
	}
268
269
	EList<EObject> directReports(EObject employee) {
270
		return get(employee, employeeDirectReports);
271
	}
272
273
	EList<EObject> allReports(EObject employee) {
274
		return get(employee, employeeAllReports);
275
	}
276
277
	EList<EObject> employees(EObject company) {
278
		return get(company, companyEmployees);
279
	}
280
281
	Enumerator size(EObject company) {
282
		return get(company, companySize);
283
	}
284
285
	@SuppressWarnings("unchecked")
286
	<T> T get(EObject owner, EStructuralFeature feature) {
287
		return (T) owner.eGet(feature);
288
	}
289
290
	void set(EObject owner, EStructuralFeature feature, Object value) {
291
		owner.eSet(feature, value);
292
	}
293
294
	void add(EObject owner, EStructuralFeature feature, Object value) {
295
		this.<EList<Object>> get(owner, feature).add(value);
296
	}
297
298
	EObject create(EObject owner, EReference containment, EClass type,
299
			String name) {
300
		EObject result = companyFactory.create(type);
301
302
		if (containment.isMany()) {
303
			add(owner, containment, result);
304
		} else {
305
			set(owner, containment, result);
306
		}
307
308
		if (name != null) {
309
			set(result, type.getEStructuralFeature("name"), name);
310
		}
311
312
		return result;
313
	}
314
315
	<T> EList<T> list(T... element) {
316
		return new BasicEList<T>(Arrays.asList(element));
317
	}
318
319
	@SuppressWarnings("unchecked")
320
	<T> T call(EObject target, EOperation operation, Object... arguments) {
321
		try {
322
			return (T) target.eCall(operation, (arguments.length == 0)
323
				? ECollections.<Object> emptyEList()
324
				: new BasicEList.UnmodifiableEList<Object>(arguments.length,
325
					arguments));
326
		} catch (InvocationTargetException e) {
327
			fail("Failed to call operation: " + e.getLocalizedMessage());
328
			return null;
329
		}
330
	}
331
}
(-)model/SettingDelegateTest.ecore (+58 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<ecore:EPackage xmi:version="2.0"
3
    xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="settingtest"
5
    nsURI="http://www.eclipse.org/ocl/test/2008/SettingDelegate" nsPrefix="st">
6
  <eClassifiers xsi:type="ecore:EClass" name="Company">
7
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
8
    <eStructuralFeatures xsi:type="ecore:EReference" name="employees" upperBound="-1"
9
        eType="#//Employee" containment="true" eOpposite="#//Employee/company"/>
10
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="size" lowerBound="1" eType="#//CompanySizeKind"
11
        changeable="false" volatile="true" transient="true" derived="true">
12
      <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
13
        <details key="settingDelegate" value="org.eclipse.ocl.ecore.OCL"/>
14
        <details key="OCL" value="let table : Set(Tuple(range : Sequence(Integer), size : CompanySizeKind)) =&#xD;    Set{Tuple{range=Sequence{0..49}, size=CompanySizeKind::small},&#xD;         Tuple{range=Sequence{50..999}, size=CompanySizeKind::medium},&#xD;         Tuple{range=Sequence{1000..1000000}, size=CompanySizeKind::large}} in&#xD;table->any(range->includes(employees->size())).size"/>
15
      </eAnnotations>
16
    </eStructuralFeatures>
17
  </eClassifiers>
18
  <eClassifiers xsi:type="ecore:EClass" name="Employee">
19
    <eOperations name="reportsTo" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean">
20
      <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
21
        <details key="callDelegate" value="org.eclipse.ocl.ecore.OCL"/>
22
        <details key="OCL" value="self.reportingChain->includes(manager)"/>
23
      </eAnnotations>
24
      <eParameters name="manager" eType="#//Employee"/>
25
    </eOperations>
26
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
27
    <eStructuralFeatures xsi:type="ecore:EReference" name="manager" eType="#//Employee"/>
28
    <eStructuralFeatures xsi:type="ecore:EReference" name="company" lowerBound="1"
29
        eType="#//Company" eOpposite="#//Company/employees"/>
30
    <eStructuralFeatures xsi:type="ecore:EReference" name="directReports" upperBound="-1"
31
        eType="#//Employee" changeable="false" volatile="true" transient="true" derived="true">
32
      <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
33
        <details key="settingDelegate" value="org.eclipse.ocl.ecore.OCL"/>
34
        <details key="OCL" value="company.employees->select(manager = self)"/>
35
      </eAnnotations>
36
    </eStructuralFeatures>
37
    <eStructuralFeatures xsi:type="ecore:EReference" name="allReports" ordered="false"
38
        upperBound="-1" eType="#//Employee" changeable="false" volatile="true" transient="true"
39
        derived="true">
40
      <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
41
        <details key="settingDelegate" value="org.eclipse.ocl.ecore.OCL"/>
42
        <details key="OCL" value="Employee.allInstances()->select(reportsTo(self))"/>
43
      </eAnnotations>
44
    </eStructuralFeatures>
45
    <eStructuralFeatures xsi:type="ecore:EReference" name="reportingChain" upperBound="-1"
46
        eType="#//Employee" changeable="false" volatile="true" transient="true" derived="true">
47
      <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
48
        <details key="settingDelegate" value="org.eclipse.ocl.ecore.OCL"/>
49
        <details key="OCL" value="if (manager.oclIsUndefined()) then&#xD;    OrderedSet{}&#xD;else&#xD;    manager.reportingChain->prepend(manager)&#xD;endif"/>
50
      </eAnnotations>
51
    </eStructuralFeatures>
52
  </eClassifiers>
53
  <eClassifiers xsi:type="ecore:EEnum" name="CompanySizeKind">
54
    <eLiterals name="small"/>
55
    <eLiterals name="medium" value="1"/>
56
    <eLiterals name="large" value="2"/>
57
  </eClassifiers>
58
</ecore:EPackage>
(-)model/TestCompany.xmi (+9 lines)
Added Link Here
1
<?xml version="1.0" encoding="ASCII"?>
2
<st:Company xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:st="http://www.eclipse.org/ocl/test/2008/SettingDelegate" xsi:schemaLocation="http://www.eclipse.org/ocl/test/2008/SettingDelegate SettingDelegateTest.ecore" name="Acme">
3
  <employees name="Bob" manager="//@employees.3"/>
4
  <employees name="Jane" manager="//@employees.3"/>
5
  <employees name="Fred" manager="//@employees.3"/>
6
  <employees name="Amy"/>
7
  <employees name="Norbert" manager="//@employees.0"/>
8
  <employees name="Sally" manager="//@employees.0"/>
9
</st:Company>
(-)src/org/eclipse/ocl/ecore/EcoreEvaluationEnvironment.java (-1 / +21 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005, 2008 IBM Corporation and others.
4
 * Copyright (c) 2005, 2008 IBM Corporation, Zeligsoft Inc., and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 9-14 Link Here
9
 *
9
 *
10
 * Contributors:
10
 * Contributors:
11
 *   IBM - Initial API and implementation
11
 *   IBM - Initial API and implementation
12
 *   Zeligsoft - Bug 255469
12
 *
13
 *
13
 * </copyright>
14
 * </copyright>
14
 *
15
 *
Lines 17-22 Link Here
17
18
18
package org.eclipse.ocl.ecore;
19
package org.eclipse.ocl.ecore;
19
20
21
import java.lang.reflect.InvocationTargetException;
20
import java.lang.reflect.Method;
22
import java.lang.reflect.Method;
21
import java.util.Collection;
23
import java.util.Collection;
22
import java.util.Collections;
24
import java.util.Collections;
Lines 24-29 Link Here
24
import java.util.Map;
26
import java.util.Map;
25
import java.util.Set;
27
import java.util.Set;
26
28
29
import org.eclipse.emf.common.util.BasicEList;
30
import org.eclipse.emf.common.util.ECollections;
27
import org.eclipse.emf.common.util.EList;
31
import org.eclipse.emf.common.util.EList;
28
import org.eclipse.emf.common.util.Enumerator;
32
import org.eclipse.emf.common.util.Enumerator;
29
import org.eclipse.emf.ecore.EClass;
33
import org.eclipse.emf.ecore.EClass;
Lines 35-40 Link Here
35
import org.eclipse.emf.ecore.EReference;
39
import org.eclipse.emf.ecore.EReference;
36
import org.eclipse.emf.ecore.EStructuralFeature;
40
import org.eclipse.emf.ecore.EStructuralFeature;
37
import org.eclipse.emf.ecore.ETypedElement;
41
import org.eclipse.emf.ecore.ETypedElement;
42
import org.eclipse.emf.ecore.impl.DynamicEObjectImpl;
38
import org.eclipse.ocl.AbstractEvaluationEnvironment;
43
import org.eclipse.ocl.AbstractEvaluationEnvironment;
39
import org.eclipse.ocl.EvaluationEnvironment;
44
import org.eclipse.ocl.EvaluationEnvironment;
40
import org.eclipse.ocl.LazyExtentMap;
45
import org.eclipse.ocl.LazyExtentMap;
Lines 84-89 Link Here
84
            Object source, Object[] args)
89
            Object source, Object[] args)
85
        throws IllegalArgumentException {
90
        throws IllegalArgumentException {
86
91
92
    	// FIXME: Pull up so that UML environment can benefit. This is only here
93
    	// for now in order to avoid including org.eclipse.ocl in the patch
94
    	if (source instanceof DynamicEObjectImpl) {
95
			EList<Object> arguments = (args.length == 0)
96
				? ECollections.emptyEList()
97
				: new BasicEList.UnmodifiableEList<Object>(args.length, args);
98
99
			try {
100
				return coerceValue(operation, ((EObject) source).eCall(
101
					operation, arguments), true);
102
			} catch (InvocationTargetException e) {
103
				throw new IllegalArgumentException(e);
104
			}
105
    	}
106
    	
87
        // TODO: WBN to pull up createValue to the superclass as a pass-thru
107
        // TODO: WBN to pull up createValue to the superclass as a pass-thru
88
        // so that subclasses don't have to override callOperation
108
        // so that subclasses don't have to override callOperation
89
        return coerceValue(operation, super.callOperation(operation, opcode,
109
        return coerceValue(operation, super.callOperation(operation, opcode,
(-)META-INF/MANIFEST.MF (+2 lines)
Lines 14-20 Link Here
14
Eclipse-LazyStart: true
14
Eclipse-LazyStart: true
15
Bundle-ActivationPolicy: lazy
15
Bundle-ActivationPolicy: lazy
16
Export-Package: org.eclipse.ocl.ecore,
16
Export-Package: org.eclipse.ocl.ecore,
17
 org.eclipse.ocl.ecore.dynamic,
17
 org.eclipse.ocl.ecore.impl,
18
 org.eclipse.ocl.ecore.impl,
18
 org.eclipse.ocl.ecore.internal;x-friends:="org.eclipse.ocl.ecore.tests,org.eclipse.emf.ocl",
19
 org.eclipse.ocl.ecore.internal;x-friends:="org.eclipse.ocl.ecore.tests,org.eclipse.emf.ocl",
20
 org.eclipse.ocl.ecore.internal.l10n,
19
 org.eclipse.ocl.ecore.util
21
 org.eclipse.ocl.ecore.util
20
Bundle-RequiredExecutionEnvironment: J2SE-1.5
22
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-)src/org/eclipse/ocl/ecore/internal/l10n/OCLEcoreMessages.properties (+31 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2008 Zeligsoft Inc. and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     Zeligsoft - initial API and implementation
10
#
11
# $Id$
12
#
13
###############################################################################
14
15
#
16
# Indicates an invalid derivation expression for an EStructuralFeature
17
# in the OCL setting delegate annotation
18
#
19
#   0 - the EClass name that owns the feature
20
#   1 - the EStructuralFeature name
21
#   2 - the OCL parser's error message
22
bad_attribute_derivation = Invalid OCL attribute derivation for {0}.{1}: {2}
23
24
#
25
# Indicates an invalid body expression for an EOperation
26
# in the OCL call delegate annotation
27
#
28
#   0 - the EClass name that owns the operation
29
#   1 - the EOperation name
30
#   2 - the OCL parser's error message
31
bad_operation_body = Invalid OCL operation body for {0}.{1}: {2}
(-)src/org/eclipse/ocl/ecore/dynamic/OCLCallDelegate.java (+106 lines)
Added Link Here
1
/**
2
 * <copyright>
3
 * 
4
 * Copyright (c) 2008 Zeligsoft Inc. 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
 *   Zeligsoft - Initial API and implementation
12
 * 
13
 * </copyright>
14
 *
15
 * $Id$
16
 */
17
18
package org.eclipse.ocl.ecore.dynamic;
19
20
import java.lang.reflect.InvocationTargetException;
21
22
import org.eclipse.emf.common.util.EList;
23
import org.eclipse.emf.ecore.EClass;
24
import org.eclipse.emf.ecore.EClassifier;
25
import org.eclipse.emf.ecore.EOperation;
26
import org.eclipse.emf.ecore.EPackage;
27
import org.eclipse.emf.ecore.EParameter;
28
import org.eclipse.emf.ecore.EcorePackage;
29
import org.eclipse.emf.ecore.InternalEObject;
30
import org.eclipse.emf.ecore.util.BasicCallDelegate;
31
import org.eclipse.emf.ecore.util.EcoreUtil;
32
import org.eclipse.ocl.EvaluationEnvironment;
33
import org.eclipse.ocl.ParserException;
34
import org.eclipse.ocl.ecore.OCL;
35
import org.eclipse.ocl.expressions.OCLExpression;
36
37
/**
38
 * An implementation of an operation-call delegate for OCL body expressions.
39
 * 
40
 * @author Christian W. Damus (cdamus)
41
 * 
42
 * @since 1.3
43
 */
44
public class OCLCallDelegate
45
		extends BasicCallDelegate {
46
47
	private OCL ocl;
48
49
	private OCLExpression<EClassifier> body;
50
51
	private ValueConverter converter;
52
53
	/**
54
	 * Initializes me with my operation.
55
	 * 
56
	 * @param operation
57
	 *            the operation that I handle
58
	 * 
59
	 * @throws ParserException
60
	 *             if the operation's OCL body expression is invalid
61
	 */
62
	protected OCLCallDelegate(EOperation operation, OCLCache oclCache)
63
			throws ParserException {
64
65
		super(operation);
66
67
		EClass context = operation.getEContainingClass();
68
		EPackage ePackage = context.getEPackage();
69
70
		this.ocl = oclCache.getOCL(ePackage);
71
72
		OCL.Helper helper = ocl.createOCLHelper();
73
		helper.setOperationContext(context, operation);
74
75
		String expr = EcoreUtil.getAnnotation(operation, EcorePackage.eNS_URI,
76
			"OCL"); //$NON-NLS-1$
77
78
		this.body = helper.createBodyCondition(expr).getSpecification()
79
			.getBodyExpression();
80
81
		this.converter = operation.isMany()
82
			? ValueConverter.LIST
83
			: ValueConverter.VERBATIM;
84
	}
85
86
	@Override
87
	public Object dynamicCall(InternalEObject target, EList<?> arguments)
88
			throws InvocationTargetException {
89
90
		OCL.Query query = ocl.createQuery(body);
91
92
		EList<EParameter> parms = eOperation.getEParameters();
93
		if (!parms.isEmpty()) {
94
			// bind arguments to parameter names
95
			EvaluationEnvironment<EClassifier, ?, ?, ?, ?> env = query
96
				.getEvaluationEnvironment();
97
98
			for (int i = 0; i < parms.size(); i++) {
99
				env.add(parms.get(i).getName(), arguments.get(i));
100
			}
101
		}
102
103
		return converter.convert(ocl, query.evaluate(target));
104
	}
105
	
106
}
(-)src/org/eclipse/ocl/ecore/dynamic/OCLCallDelegateFactory.java (+119 lines)
Added Link Here
1
/**
2
 * <copyright>
3
 * 
4
 * Copyright (c) 2008 Zeligsoft Inc. 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
 *   Zeligsoft - Initial API and implementation
12
 * 
13
 * </copyright>
14
 *
15
 * $Id$
16
 */
17
18
package org.eclipse.ocl.ecore.dynamic;
19
20
import java.lang.reflect.InvocationTargetException;
21
22
import org.eclipse.emf.common.notify.Notification;
23
import org.eclipse.emf.common.notify.impl.AdapterImpl;
24
import org.eclipse.emf.common.util.ECollections;
25
import org.eclipse.emf.common.util.EList;
26
import org.eclipse.emf.ecore.EOperation;
27
import org.eclipse.emf.ecore.EPackage;
28
import org.eclipse.emf.ecore.InternalEObject;
29
import org.eclipse.emf.ecore.resource.Resource;
30
import org.eclipse.emf.ecore.util.BasicCallDelegate;
31
import org.eclipse.ocl.ParserException;
32
import org.eclipse.ocl.ecore.EcoreEnvironmentFactory;
33
import org.eclipse.ocl.ecore.OCL;
34
import org.eclipse.ocl.ecore.internal.OCLEcorePlugin;
35
import org.eclipse.ocl.ecore.internal.l10n.OCLEcoreMessages;
36
37
/**
38
 * Factory for OCL operation-call delegates.
39
 * 
40
 * @author Christian W. Damus (cdamus)
41
 * 
42
 * @since 1.3
43
 */
44
public class OCLCallDelegateFactory
45
		extends AbstractOCLDelegateFactory
46
		implements EOperation.Internal.CallDelegate.Factory {
47
48
	public EOperation.Internal.CallDelegate createCallDelegate(
49
			EOperation operation) {
50
51
		EOperation.Internal.CallDelegate result;
52
53
		try {
54
			result = new OCLCallDelegate(operation, getCache());
55
		} catch (ParserException e) {
56
			// I will not be able to return any values
57
			OCLEcorePlugin.error(1, OCLEcoreMessages.bind(
58
				OCLEcoreMessages.bad_operation_body, new Object[]{
59
					operation.getEContainingClass().getName(),
60
					operation.getName(), e.getLocalizedMessage()}));
61
62
			// so, return a call delegate that has no value, ever
63
			return new BasicCallDelegate(operation) {
64
65
				@Override
66
				public Object dynamicCall(InternalEObject target,
67
						EList<?> arguments)
68
						throws InvocationTargetException {
69
70
					return eOperation.isMany()
71
						? ECollections.EMPTY_ELIST
72
						: null;
73
				}
74
75
			};
76
		}
77
78
		return result;
79
	}
80
81
	/**
82
	 * Creates the OCL environment in which to parse setting delegates for the
83
	 * specified environment. Subclasses may override to create custom
84
	 * environments, but should note that the result is cached.
85
	 * 
86
	 * @param ePackage
87
	 *            an Ecore package for which to create a setting delegate
88
	 *            environment
89
	 * @return the environment
90
	 */
91
	public OCL createOCL(final EPackage ePackage) {
92
		Resource res = ePackage.eResource();
93
		EcoreEnvironmentFactory envFactory;
94
95
		if ((res != null) && (res.getResourceSet() != null)) {
96
			// it's a dynamic package. Use the local package registry
97
			envFactory = new EcoreEnvironmentFactory(res.getResourceSet()
98
				.getPackageRegistry());
99
100
			// and expunge when it's unloaded
101
			res.eAdapters().add(new AdapterImpl() {
102
103
				@Override
104
				public void notifyChanged(Notification msg) {
105
					if ((msg.getFeatureID(Resource.class) == Resource.RESOURCE__IS_LOADED)
106
						&& !msg.getNewBooleanValue()) {
107
						getCache().expunge(ePackage);
108
					}
109
				}
110
			});
111
		} else {
112
			// the shared instance uses the static package registry
113
			envFactory = EcoreEnvironmentFactory.INSTANCE;
114
		}
115
116
		return OCL.newInstance(envFactory);
117
	}
118
119
}
(-)src/org/eclipse/ocl/ecore/dynamic/ValueConverter.java (+61 lines)
Added Link Here
1
/**
2
 * <copyright>
3
 * 
4
 * Copyright (c) 2008 Zeligsoft Inc. 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
 *   Zeligsoft - Initial API and implementation
12
 * 
13
 * </copyright>
14
 *
15
 * $Id$
16
 */
17
18
package org.eclipse.ocl.ecore.dynamic;
19
20
import java.util.Collection;
21
22
import org.eclipse.emf.common.util.BasicEList;
23
import org.eclipse.emf.common.util.ECollections;
24
import org.eclipse.ocl.ecore.OCL;
25
26
/**
27
 * An object that converts values according to their declared multiplicities,
28
 * as collections or not.
29
 * 
30
 * @author Christian W. Damus (cdamus)
31
 * 
32
 * @since 1.3
33
 */
34
interface ValueConverter {
35
36
	ValueConverter VERBATIM = new ValueConverter() {
37
38
		public Object convert(OCL ocl, Object value) {
39
			// no way to report problem to the user in invalid case
40
			return ocl.isInvalid(value)
41
				? null
42
				: value;
43
		}
44
	};
45
46
	ValueConverter LIST = new ValueConverter() {
47
48
		public Object convert(OCL ocl, Object value) {
49
			if (ocl.isInvalid(value)) {
50
				// no way to report specific problem to the user
51
				return ECollections.EMPTY_ELIST;
52
			}
53
54
			Collection<?> collection = (Collection<?>) value;
55
			return new BasicEList.UnmodifiableEList<Object>(collection
56
				.size(), collection.toArray());
57
		}
58
	};
59
60
	Object convert(OCL ocl, Object value);
61
}
(-)src/org/eclipse/ocl/ecore/dynamic/OCLCache.java (+86 lines)
Added Link Here
1
/**
2
 * <copyright>
3
 * 
4
 * Copyright (c) 2008 Zeligsoft Inc. 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
 *   Zeligsoft - Initial API and implementation
12
 * 
13
 * </copyright>
14
 *
15
 * $Id$
16
 */
17
18
package org.eclipse.ocl.ecore.dynamic;
19
20
import java.lang.ref.Reference;
21
22
import org.eclipse.emf.ecore.EPackage;
23
import org.eclipse.ocl.ecore.OCL;
24
25
/**
26
 * A doubly-weak-referenced cache of OCL environments created to handle Ecore
27
 * packages.
28
 * 
29
 * @author Christian W. Damus (cdamus)
30
 * 
31
 * @since 1.3
32
 */
33
final class OCLCache
34
		extends java.util.WeakHashMap<EPackage, Reference<OCL>> {
35
36
	/**
37
	 * My OCL factory.
38
	 */
39
	private final Factory oclFactory;
40
41
	/**
42
	 * Initializes me with a factory that I may use to create OCL environments.
43
	 * 
44
	 * @param oclFactory
45
	 *            my OCL environment factory
46
	 */
47
	OCLCache(Factory oclFactory) {
48
		this.oclFactory = oclFactory;
49
	}
50
51
	protected synchronized OCL getOCL(EPackage ePackage) {
52
		Reference<OCL> result = get(ePackage);
53
54
		if ((result == null) || (result.get() == null)) {
55
			result = new java.lang.ref.WeakReference<OCL>(oclFactory
56
				.createOCL(ePackage));
57
		}
58
59
		put(ePackage, result);
60
61
		return result.get();
62
	}
63
64
	protected synchronized void expunge(EPackage ePackage) {
65
		Reference<OCL> oclRef = get(ePackage);
66
		if (oclRef != null) {
67
			OCL ocl = oclRef.get();
68
69
			if (ocl != null) {
70
				ocl.dispose();
71
			}
72
73
			remove(ePackage);
74
		}
75
	}
76
77
	/**
78
	 * A factory of OCL environment objects.
79
	 * 
80
	 * @author Christian W. Damus (cdamus)
81
	 */
82
	static interface Factory {
83
84
		OCL createOCL(EPackage ePackage);
85
	}
86
}
(-)src/org/eclipse/ocl/ecore/dynamic/AbstractOCLDelegateFactory.java (+81 lines)
Added Link Here
1
/**
2
 * <copyright>
3
 * 
4
 * Copyright (c) 2008 Zeligsoft Inc. 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
 *   Zeligsoft - Initial API and implementation
12
 * 
13
 * </copyright>
14
 *
15
 * $Id$
16
 */
17
18
package org.eclipse.ocl.ecore.dynamic;
19
20
import org.eclipse.emf.common.notify.Notification;
21
import org.eclipse.emf.common.notify.impl.AdapterImpl;
22
import org.eclipse.emf.ecore.EPackage;
23
import org.eclipse.emf.ecore.resource.Resource;
24
import org.eclipse.ocl.ecore.EcoreEnvironmentFactory;
25
import org.eclipse.ocl.ecore.OCL;
26
27
/**
28
 * Partial implementation of a factory of OCL delegates for Ecore features.
29
 * 
30
 * @author Christian W. Damus (cdamus)
31
 * 
32
 * @since 1.3
33
 */
34
abstract class AbstractOCLDelegateFactory
35
		implements OCLCache.Factory {
36
37
	private OCLCache oclCache = new OCLCache(this);
38
39
	protected OCLCache getCache() {
40
		return oclCache;
41
	}
42
43
	/**
44
	 * Creates the OCL environment in which to parse setting delegates for the
45
	 * specified environment. Subclasses may override to create custom
46
	 * environments, but should note that the result is cached.
47
	 * 
48
	 * @param ePackage
49
	 *            an Ecore package for which to create a setting delegate
50
	 *            environment
51
	 * @return the environment
52
	 */
53
	public OCL createOCL(final EPackage ePackage) {
54
		Resource res = ePackage.eResource();
55
		EcoreEnvironmentFactory envFactory;
56
57
		if ((res != null) && (res.getResourceSet() != null)) {
58
			// it's a dynamic package. Use the local package registry
59
			envFactory = new EcoreEnvironmentFactory(res.getResourceSet()
60
				.getPackageRegistry());
61
62
			// and expunge when it's unloaded
63
			res.eAdapters().add(new AdapterImpl() {
64
65
				@Override
66
				public void notifyChanged(Notification msg) {
67
					if ((msg.getFeatureID(Resource.class) == Resource.RESOURCE__IS_LOADED)
68
						&& !msg.getNewBooleanValue()) {
69
						getCache().expunge(ePackage);
70
					}
71
				}
72
			});
73
		} else {
74
			// the shared instance uses the static package registry
75
			envFactory = EcoreEnvironmentFactory.INSTANCE;
76
		}
77
78
		return OCL.newInstance(envFactory);
79
	}
80
81
}
(-)src/org/eclipse/ocl/ecore/internal/l10n/IMessages.java (+65 lines)
Added Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2006, 2008 IBM Corporation, Zeligsoft Inc., 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
 *   Zeligsoft - Bug 216701
13
 *
14
 * </copyright>
15
 *
16
 * $Id: IMessages.java,v 1.2 2007/02/14 14:46:07 cdamus Exp $
17
 */
18
package org.eclipse.ocl.ecore.internal.l10n;
19
20
import java.text.MessageFormat;
21
22
/**
23
 * Abstraction of the OSGi runtime's NLS class, to abstract the dependency on
24
 * Eclipse platform.
25
 *
26
 * @author Christian W. Damus (cdamus)
27
 */
28
interface IMessages {
29
	String bind(String message, Object arg);
30
	String bind(String message, Object arg1, Object arg2);
31
	String bind(String message, Object[] args);
32
	
33
	class Default implements IMessages {
34
		public String bind(String message, Object arg) {
35
			return MessageFormat.format(message, new Object[] {arg});
36
		}
37
38
		public String bind(String message, Object arg1, Object arg2) {
39
			return MessageFormat.format(message, new Object[] {arg1, arg2});
40
		}
41
42
		public String bind(String message, Object[] args) {
43
			return MessageFormat.format(message, args);
44
		}
45
	}
46
	
47
	class NLS implements IMessages {
48
		public NLS() {
49
			org.eclipse.osgi.util.NLS.initializeMessages(
50
					OCLEcoreMessages.BUNDLE_NAME, OCLEcoreMessages.class);
51
		}
52
53
		public String bind(String message, Object arg) {
54
			return org.eclipse.osgi.util.NLS.bind(message, arg);
55
		}
56
57
		public String bind(String message, Object arg1, Object arg2) {
58
			return org.eclipse.osgi.util.NLS.bind(message, arg1, arg2);
59
		}
60
61
		public String bind(String message, Object[] args) {
62
			return org.eclipse.osgi.util.NLS.bind(message, args);
63
		}
64
	}
65
}
(-)src/org/eclipse/ocl/ecore/dynamic/OCLSettingDelegate.java (+95 lines)
Added Link Here
1
/**
2
 * <copyright>
3
 * 
4
 * Copyright (c) 2008 Zeligsoft Inc. 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
 *   Zeligsoft - Initial API and implementation
12
 * 
13
 * </copyright>
14
 *
15
 * $Id$
16
 */
17
18
package org.eclipse.ocl.ecore.dynamic;
19
20
import org.eclipse.emf.ecore.EClass;
21
import org.eclipse.emf.ecore.EClassifier;
22
import org.eclipse.emf.ecore.EPackage;
23
import org.eclipse.emf.ecore.EStructuralFeature;
24
import org.eclipse.emf.ecore.EcorePackage;
25
import org.eclipse.emf.ecore.InternalEObject;
26
import org.eclipse.emf.ecore.util.BasicSettingDelegate;
27
import org.eclipse.emf.ecore.util.EcoreUtil;
28
import org.eclipse.ocl.ParserException;
29
import org.eclipse.ocl.ecore.OCL;
30
import org.eclipse.ocl.expressions.OCLExpression;
31
32
/**
33
 * An implementation of a setting delegate that computes OCL derived features.
34
 * 
35
 * @author Christian W. Damus (cdamus)
36
 * @since 1.3
37
 */
38
public class OCLSettingDelegate
39
		extends BasicSettingDelegate.Stateless {
40
41
	private OCL ocl;
42
43
	private OCLExpression<EClassifier> derivation;
44
45
	private ValueConverter converter;
46
47
	/**
48
	 * Initializes me with my structural feature.
49
	 * 
50
	 * @param structuralFeature
51
	 *            the structural feature that I handle
52
	 * 
53
	 * @throws ParserException
54
	 *             if the structural feature's OCL derivation is invalid
55
	 */
56
	protected OCLSettingDelegate(EStructuralFeature structuralFeature,
57
			OCLCache oclCache)
58
			throws ParserException {
59
60
		super(structuralFeature);
61
62
		EClass context = structuralFeature.getEContainingClass();
63
		EPackage ePackage = context.getEPackage();
64
65
		this.ocl = oclCache.getOCL(ePackage);
66
67
		OCL.Helper helper = ocl.createOCLHelper();
68
		helper.setAttributeContext(context, structuralFeature);
69
70
		String expr = EcoreUtil.getAnnotation(structuralFeature,
71
			EcorePackage.eNS_URI, "OCL"); //$NON-NLS-1$
72
73
		this.derivation = helper.createDerivedValueExpression(expr)
74
			.getSpecification().getBodyExpression();
75
76
		this.converter = structuralFeature.isMany()
77
			? ValueConverter.LIST
78
			: ValueConverter.VERBATIM;
79
	}
80
81
	@Override
82
	protected Object get(InternalEObject owner, boolean resolve,
83
			boolean coreType) {
84
85
		OCL.Query query = ocl.createQuery(derivation);
86
87
		return converter.convert(ocl, query.evaluate(owner));
88
	}
89
90
	@Override
91
	protected boolean isSet(InternalEObject owner) {
92
		return false; // derived features are, implicitly, never set
93
	}
94
	
95
}
(-)src/org/eclipse/ocl/ecore/internal/l10n/OCLEcoreMessages.java (+103 lines)
Added Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2005, 2008 IBM Corporation, Zeligsoft Inc., 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
 *   Zeligsoft - Bug 216701
13
 *
14
 * </copyright>
15
 *
16
 * $Id: OCLMessages.java,v 1.6 2007/12/12 22:08:04 cdamus Exp $
17
 */
18
19
package org.eclipse.ocl.ecore.internal.l10n;
20
21
import java.lang.reflect.Field;
22
import java.lang.reflect.Modifier;
23
import java.util.MissingResourceException;
24
import java.util.ResourceBundle;
25
26
/**
27
 * An accessor class for externalized strings.
28
 * 
29
 * @author Christian Vogt (cvogt)
30
 * @since 1.3
31
 */
32
public class OCLEcoreMessages {
33
34
	static final String BUNDLE_NAME = "org.eclipse.ocl.ecore.internal.l10n.OCLMessages"; //$NON-NLS-1$
35
36
	public static String bad_attribute_derivation;
37
	
38
	public static String bad_operation_body;
39
	
40
	private static IMessages messagesImpl;
41
	
42
	public static String bind(String message, Object arg) {
43
		return messagesImpl.bind(message, arg);
44
	}
45
	
46
	public static String bind(String message, Object arg1, Object arg2) {
47
		return messagesImpl.bind(message, arg1, arg2);
48
	}
49
	
50
	public static String bind(String message, Object[] args) {
51
		return messagesImpl.bind(message, args);
52
	}
53
54
	static {
55
		try {
56
			@SuppressWarnings("unchecked")
57
			Class<IMessages> nlsClass = (Class<IMessages>) Class.forName("org.eclipse.ocl.ecore.internal.l10n.IMessages$NLS"); //$NON-NLS-1$
58
			messagesImpl = nlsClass.newInstance();
59
		} catch (NoClassDefFoundError e) {
60
			// expected in non-Eclipse environment
61
		} catch (Exception e) {
62
			// expected in non-Eclipse environment
63
		}
64
		
65
		if (messagesImpl == null) {
66
			// could not find the NLS class.  Try initializing the messages,
67
			//    ourselves
68
			initializeMessages();
69
			messagesImpl = new IMessages.Default();
70
		}
71
	}
72
	
73
	private static void initializeMessages() {
74
		ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_NAME);
75
		int publicStatic = Modifier.PUBLIC | Modifier.STATIC;
76
		
77
		Class<OCLEcoreMessages> clazz = OCLEcoreMessages.class;
78
		
79
		if (bundle != null) {
80
			Field[] fields = clazz.getDeclaredFields();
81
			
82
			for (int i = 0; i < fields.length; i++) {
83
				Field next = fields[i];
84
				
85
				if (((next.getModifiers() & publicStatic) == publicStatic)
86
						&& (next.getType() == String.class)) {
87
					String name = next.getName();
88
					
89
					try {
90
						try {
91
							next.set(null, bundle.getString(name));
92
						} catch (MissingResourceException e) {
93
							// just use its own name, then
94
							next.set(null, "Missing message for key: " + name); //$NON-NLS-1$
95
						}
96
					} catch (Exception e) {
97
						// oh, well.  Can't set a value for this one
98
					}
99
				}
100
			}
101
		}
102
	}
103
}
(-)src/org/eclipse/ocl/ecore/dynamic/OCLSettingDelegateFactory.java (+76 lines)
Added Link Here
1
/**
2
 * <copyright>
3
 * 
4
 * Copyright (c) 2008 Zeligsoft Inc. 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
 *   Zeligsoft - Initial API and implementation
12
 * 
13
 * </copyright>
14
 *
15
 * $Id$
16
 */
17
18
package org.eclipse.ocl.ecore.dynamic;
19
20
import org.eclipse.emf.common.util.ECollections;
21
import org.eclipse.emf.ecore.EStructuralFeature;
22
import org.eclipse.emf.ecore.InternalEObject;
23
import org.eclipse.emf.ecore.util.BasicSettingDelegate;
24
import org.eclipse.ocl.ParserException;
25
import org.eclipse.ocl.ecore.internal.OCLEcorePlugin;
26
import org.eclipse.ocl.ecore.internal.l10n.OCLEcoreMessages;
27
28
/**
29
 * Factory for OCL derived-attribute setting delegates.
30
 * 
31
 * @author Christian W. Damus (cdamus)
32
 * 
33
 * @since 1.3
34
 */
35
public class OCLSettingDelegateFactory
36
extends AbstractOCLDelegateFactory
37
		implements EStructuralFeature.Internal.SettingDelegate.Factory {
38
39
	public EStructuralFeature.Internal.SettingDelegate createSettingDelegate(
40
			EStructuralFeature structuralFeature) {
41
42
		EStructuralFeature.Internal.SettingDelegate result;
43
44
		try {
45
			result = new OCLSettingDelegate(structuralFeature, getCache());
46
		} catch (ParserException e) {
47
			// I will not be able to return any values
48
			OCLEcorePlugin.error(1, OCLEcoreMessages.bind(
49
				OCLEcoreMessages.bad_attribute_derivation, new Object[]{
50
					structuralFeature.getEContainingClass().getName(),
51
					structuralFeature.getName(), e.getLocalizedMessage()}));
52
53
			// so, return a setting delegate that has no value, ever
54
			return new BasicSettingDelegate.Stateless(structuralFeature) {
55
56
				@Override
57
				protected Object get(InternalEObject owner, boolean resolve,
58
						boolean coreType) {
59
60
					return eStructuralFeature.isMany()
61
						? ECollections.EMPTY_ELIST
62
						: null;
63
				}
64
65
				@Override
66
				protected boolean isSet(InternalEObject owner) {
67
					return false;
68
				}
69
70
			};
71
		}
72
73
		return result;
74
	}
75
76
}
(-)src/org/eclipse/emf/ecore/EObject.java (-1 / +28 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002-2006 IBM Corporation and others.
4
 * Copyright (c) 2002-2008 IBM Corporation, Zeligsoft Inc., and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 9-14 Link Here
9
 * 
9
 * 
10
 * Contributors: 
10
 * Contributors: 
11
 *   IBM - Initial API and implementation
11
 *   IBM - Initial API and implementation
12
 *   Zeligsoft - 255469 Implement basic eCall support
12
 *
13
 *
13
 * </copyright>
14
 * </copyright>
14
 *
15
 *
Lines 17-22 Link Here
17
package org.eclipse.emf.ecore;
18
package org.eclipse.emf.ecore;
18
19
19
20
21
import java.lang.reflect.InvocationTargetException;
22
20
import org.eclipse.emf.common.notify.Notifier;
23
import org.eclipse.emf.common.notify.Notifier;
21
import org.eclipse.emf.common.util.EList;
24
import org.eclipse.emf.common.util.EList;
22
import org.eclipse.emf.common.util.TreeIterator;
25
import org.eclipse.emf.common.util.TreeIterator;
Lines 427-430 Link Here
427
   */
430
   */
428
  void eUnset(EStructuralFeature feature);
431
  void eUnset(EStructuralFeature feature);
429
432
433
  /**
434
   * <!-- begin-user-doc -->
435
   * <p>
436
   * Calls the specified operation of the object.  If the operation has
437
   * parameters, then corresponding arguments must be supplied.  There are no
438
   * optional parameters in Ecore operations.
439
   * </p><p>
440
   * If the operation is a void operation, then on successful execution, the
441
   * result of this call is <code>null</code>.  Otherwise, if the operation is
442
   * {@linkplain ETypedElement#isMany() nulti-valued}, then an {@link EList}
443
   * is returned (possibly empty).  If single-valued, then an instance of the
444
   * operation's {@linkplain ETypedElement#getEType() type} is returned, or
445
   * possibly <code>null</code>.
446
   * </p><p>
447
   * If the called operation fails with an
448
   * {@linkplain EOperation#getEExceptions() exception}, then it is re-thrown,
449
   * wrapped in an {@link InvocationTargetException}.
450
   * </p>
451
   * <!-- end-user-doc -->
452
   * @model exceptions="org.eclipse.emf.ecore.EInvocationTargetException" argumentsMany="false"
453
   * @generated
454
   */
455
  Object eCall(EOperation operation, EList<?> arguments) throws InvocationTargetException;
456
430
}
457
}
(-)src/org/eclipse/emf/ecore/EcorePackage.java (-1 / +33 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002-2006 IBM Corporation and others.
4
 * Copyright (c) 2002-2008 IBM Corporation, Zeligsoft Inc., and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 9-14 Link Here
9
 * 
9
 * 
10
 * Contributors: 
10
 * Contributors: 
11
 *   IBM - Initial API and implementation
11
 *   IBM - Initial API and implementation
12
 *   Zeligsoft - 255469 Implement basic eCall support
12
 *
13
 *
13
 * </copyright>
14
 * </copyright>
14
 *
15
 *
Lines 2389-2394 Link Here
2389
2390
2390
2391
2391
  /**
2392
  /**
2393
   * The meta object id for the '<em>EInvocation Target Exception</em>' data type.
2394
   * <!-- begin-user-doc -->
2395
   * <!-- end-user-doc -->
2396
   * @see java.lang.reflect.InvocationTargetException
2397
   * @see org.eclipse.emf.ecore.impl.EcorePackageImpl#getEInvocationTargetException()
2398
   * @generated
2399
   */
2400
  int EINVOCATION_TARGET_EXCEPTION = 52;
2401
2402
  /**
2392
   * The meta object id for the '<em>EFeature Map Entry</em>' data type.
2403
   * The meta object id for the '<em>EFeature Map Entry</em>' data type.
2393
   * <!-- begin-user-doc -->
2404
   * <!-- begin-user-doc -->
2394
   * <!-- end-user-doc -->
2405
   * <!-- end-user-doc -->
Lines 3877-3882 Link Here
3877
  EDataType getETreeIterator();
3888
  EDataType getETreeIterator();
3878
3889
3879
  /**
3890
  /**
3891
   * Returns the meta object for data type '{@link java.lang.reflect.InvocationTargetException <em>EInvocation Target Exception</em>}'.
3892
   * <!-- begin-user-doc -->
3893
   * <!-- end-user-doc -->
3894
   * @return the meta object for data type '<em>EInvocation Target Exception</em>'.
3895
   * @see java.lang.reflect.InvocationTargetException
3896
   * @model instanceClass="java.lang.reflect.InvocationTargetException"
3897
   * @generated
3898
   */
3899
  EDataType getEInvocationTargetException();
3900
3901
  /**
3880
   * Returns the meta object for data type '{@link org.eclipse.emf.ecore.util.FeatureMap.Entry <em>EFeature Map Entry</em>}'.
3902
   * Returns the meta object for data type '{@link org.eclipse.emf.ecore.util.FeatureMap.Entry <em>EFeature Map Entry</em>}'.
3881
   * <!-- begin-user-doc -->
3903
   * <!-- begin-user-doc -->
3882
   * <!-- end-user-doc -->
3904
   * <!-- end-user-doc -->
Lines 5103-5108 Link Here
5103
     */
5125
     */
5104
    EDataType ETREE_ITERATOR = eINSTANCE.getETreeIterator();
5126
    EDataType ETREE_ITERATOR = eINSTANCE.getETreeIterator();
5105
5127
5128
    /**
5129
     * The meta object literal for the '<em>EInvocation Target Exception</em>' data type.
5130
     * <!-- begin-user-doc -->
5131
     * <!-- end-user-doc -->
5132
     * @see java.lang.reflect.InvocationTargetException
5133
     * @see org.eclipse.emf.ecore.impl.EcorePackageImpl#getEInvocationTargetException()
5134
     * @generated
5135
     */
5136
    EDataType EINVOCATION_TARGET_EXCEPTION = eINSTANCE.getEInvocationTargetException();
5137
5106
  }
5138
  }
5107
5139
5108
  // Internal bootstrap uses Literals constants, so we must force initialization this inner interface first.
5140
  // Internal bootstrap uses Literals constants, so we must force initialization this inner interface first.
(-)src/org/eclipse/emf/ecore/EOperation.java (-1 / +96 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002-2006 IBM Corporation and others.
4
 * Copyright (c) 2002-2008 IBM Corporation, Zeligsoft Inc., and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 9-14 Link Here
9
 * 
9
 * 
10
 * Contributors: 
10
 * Contributors: 
11
 *   IBM - Initial API and implementation
11
 *   IBM - Initial API and implementation
12
 *   Zeligsoft - 255469 Implement basic eCall support
12
 *
13
 *
13
 * </copyright>
14
 * </copyright>
14
 *
15
 *
Lines 17-22 Link Here
17
package org.eclipse.emf.ecore;
18
package org.eclipse.emf.ecore;
18
19
19
20
21
import java.lang.reflect.InvocationTargetException;
22
import java.util.HashMap;
23
20
import org.eclipse.emf.common.util.EList;
24
import org.eclipse.emf.common.util.EList;
21
25
22
26
Lines 126-129 Link Here
126
   */
130
   */
127
  EList<ETypeParameter> getETypeParameters();
131
  EList<ETypeParameter> getETypeParameters();
128
132
133
  /**
134
   * Internal API implemented by all operations.
135
   * 
136
   * @since 2.5
137
   */
138
  interface Internal extends EOperation, InternalEObject
139
  {
140
	/**
141
	 * A pluggable, dynamic implementation of operation behaviour.
142
	 */
143
    interface CallDelegate
144
    {
145
      /**
146
       * A factory for creating call delegates.
147
       */
148
      interface Factory
149
      {
150
        /**
151
         * Creates the call delegate for the specified <tt>operation</tt>.
152
         * 
153
         * @param operation the operation
154
         * @return its call delegate
155
         */
156
        CallDelegate createCallDelegate(EOperation operation);
157
        
158
        /**
159
         * A registry of call-delegate factories.
160
         */
161
        interface Registry
162
        {
163
          Registry INSTANCE = new Impl();
164
          
165
          Factory getFactory(String key);
166
          
167
          void registerFactory(String key, Factory factory);
168
          
169
          void deregisterFactory(String key);
170
          
171
          class Impl extends HashMap<String, Factory> implements Registry
172
          {
173
            private static final long serialVersionUID = 1L;
174
            
175
            public Factory getFactory(String key)
176
            {
177
              return get(key);
178
            }
179
            
180
            public void registerFactory(String key, Factory factory)
181
            {
182
              put(key, factory);
183
            }
184
            
185
            public void deregisterFactory(String key)
186
            {
187
              remove(key);
188
            }
189
          }
190
        }
191
      }
192
      
193
      /**
194
       * Invokes the operation behaviour for the specified <tt>target</tt>
195
       * object.
196
       * 
197
       * @param target the object on which to call the operation
198
       * @param arguments the arguments for the operation parameters (an
199
       *    empty list if the operation has no parameters)
200
       * @return the operation's return result, or <code>null</code> if it is
201
       *    a void operation
202
       * @throws InvocationTargetException in case of failure to execute the
203
       *    operation behaviour, usually because of an exception
204
       */
205
      Object dynamicCall(InternalEObject target, EList<?> arguments) throws InvocationTargetException;
206
    }
207
    
208
    /**
209
     * Obtains the delegate for this operation.
210
     * A default delegate is always available, so this should not return
211
     * <code>null</code>.
212
     * 
213
     * @return the operation delegate
214
     */
215
    CallDelegate getCallDelegate();
216
    
217
    /**
218
     * Assigns a delegate to this operation.
219
     * 
220
     * @param callDelegate the new operation delegate
221
     */
222
    void setCallDelegate(CallDelegate callDelegate);
223
  }
129
} //EOperation
224
} //EOperation
(-)src/org/eclipse/emf/ecore/EStructuralFeature.java (-1 / +65 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002-2006 IBM Corporation and others.
4
 * Copyright (c) 2002-2008 IBM Corporation, Zeligsoft Inc. and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 9-14 Link Here
9
 * 
9
 * 
10
 * Contributors: 
10
 * Contributors: 
11
 *   IBM - Initial API and implementation
11
 *   IBM - Initial API and implementation
12
 *   Zeligsoft - 216701 Add support for mutating the delegate-factory registry
12
 *
13
 *
13
 * </copyright>
14
 * </copyright>
14
 *
15
 *
Lines 17-23 Link Here
17
package org.eclipse.emf.ecore;
18
package org.eclipse.emf.ecore;
18
19
19
20
21
import java.util.HashMap;
22
20
import org.eclipse.emf.common.notify.NotificationChain;
23
import org.eclipse.emf.common.notify.NotificationChain;
24
import org.eclipse.emf.ecore.util.PathSettingDelegate;
21
import org.eclipse.emf.ecore.util.FeatureMap;
25
import org.eclipse.emf.ecore.util.FeatureMap;
22
26
23
27
Lines 365-370 Link Here
365
    interface SettingDelegate
369
    interface SettingDelegate
366
    {
370
    {
367
      /**
371
      /**
372
       * A factory for creating setting delegates.
373
       * @since 2.5
374
       */
375
      interface Factory
376
      {
377
        /**
378
         * Creates a setting delegate for the given feature.
379
         * @param eStructuralFeature the feature for which a setting delegate is to be created.
380
         * @return a new a setting delegate for the given feature.
381
         */
382
        SettingDelegate createSettingDelegate(EStructuralFeature eStructuralFeature);
383
384
        /**
385
         * A registry of factories for creating setting delegates.
386
         */
387
        interface Registry
388
        {
389
          Registry INSTANCE = new Impl();
390
391
          Factory getFactory(String key);
392
          
393
          void registerFactory(String key, Factory factory);
394
          
395
          void deregisterFactory(String key);
396
397
          class Impl extends HashMap<String, Factory> implements Registry
398
          {
399
            private static final long serialVersionUID = 1L;
400
401
            {
402
              put
403
                ("org.eclipse.emf.ecore.Path", 
404
                 new Factory() 
405
                 { 
406
                    public SettingDelegate createSettingDelegate(EStructuralFeature eStructuralFeature)
407
                    {
408
                      return new PathSettingDelegate(eStructuralFeature);
409
                    }
410
                 });
411
            }
412
413
            public Factory getFactory(String key)
414
            {
415
              return get(key);
416
            }
417
            
418
            public void registerFactory(String key, Factory factory)
419
            {
420
              put(key, factory);
421
            }
422
            
423
            public void deregisterFactory(String key)
424
            {
425
              remove(key);
426
            }
427
          }
428
        }
429
      }
430
431
      /**
368
       * Returns a setting that can be used to access the owner's feature.
432
       * Returns a setting that can be used to access the owner's feature.
369
       * @param owner the owner of the feature.
433
       * @param owner the owner of the feature.
370
       * @param settings the owner's array of cached values.
434
       * @param settings the owner's array of cached values.
(-)model/Ecore.ecore (+9 lines)
Lines 221-226 Link Here
221
    <eOperations name="eUnset">
221
    <eOperations name="eUnset">
222
      <eParameters name="feature" eType="#//EStructuralFeature"/>
222
      <eParameters name="feature" eType="#//EStructuralFeature"/>
223
    </eOperations>
223
    </eOperations>
224
    <eOperations name="eCall" eType="#//EJavaObject" eExceptions="#//EInvocationTargetException">
225
      <eParameters name="operation" eType="#//EOperation"/>
226
      <eParameters name="arguments">
227
        <eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEList">
228
          <eTypeArguments/>
229
        </eGenericType>
230
      </eParameters>
231
    </eOperations>
224
  </eClassifiers>
232
  </eClassifiers>
225
  <eClassifiers xsi:type="ecore:EClass" name="EOperation" eSuperTypes="#//ETypedElement">
233
  <eClassifiers xsi:type="ecore:EClass" name="EOperation" eSuperTypes="#//ETypedElement">
226
    <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
234
    <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
Lines 495-498 Link Here
495
    <eStructuralFeatures xsi:type="ecore:EReference" name="eBounds" upperBound="-1"
503
    <eStructuralFeatures xsi:type="ecore:EReference" name="eBounds" upperBound="-1"
496
        eType="#//EGenericType" containment="true" resolveProxies="false"/>
504
        eType="#//EGenericType" containment="true" resolveProxies="false"/>
497
  </eClassifiers>
505
  </eClassifiers>
506
  <eClassifiers xsi:type="ecore:EDataType" name="EInvocationTargetException" instanceClassName="java.lang.reflect.InvocationTargetException"/>
498
</ecore:EPackage>
507
</ecore:EPackage>
(-)model/EcoreAnnotations.ecorediag (-4 / +64 lines)
Lines 14-20 Link Here
14
    </children>
14
    </children>
15
    <styles xmi:type="notation:ShapeStyle" xmi:id="_sFlvLT-OEd2DT6rVsxRmdQ" fontName="Microsoft Sans Serif" fontHeight="10" fillColor="13761016" lineColor="0"/>
15
    <styles xmi:type="notation:ShapeStyle" xmi:id="_sFlvLT-OEd2DT6rVsxRmdQ" fontName="Microsoft Sans Serif" fontHeight="10" fillColor="13761016" lineColor="0"/>
16
    <element xmi:type="ecore:EClass" href="Ecore.ecore#//EAnnotation"/>
16
    <element xmi:type="ecore:EClass" href="Ecore.ecore#//EAnnotation"/>
17
    <layoutConstraint xmi:type="notation:Bounds" xmi:id="_sFlvLj-OEd2DT6rVsxRmdQ" x="114" y="312"/>
17
    <layoutConstraint xmi:type="notation:Bounds" xmi:id="_sFlvLj-OEd2DT6rVsxRmdQ" x="108" y="333"/>
18
  </children>
18
  </children>
19
  <children xmi:type="notation:Node" xmi:id="_sFlvLz-OEd2DT6rVsxRmdQ" type="1001">
19
  <children xmi:type="notation:Node" xmi:id="_sFlvLz-OEd2DT6rVsxRmdQ" type="1001">
20
    <children xmi:type="notation:Node" xmi:id="_sFlvMD-OEd2DT6rVsxRmdQ" type="4001"/>
20
    <children xmi:type="notation:Node" xmi:id="_sFlvMD-OEd2DT6rVsxRmdQ" type="4001"/>
Lines 30-36 Link Here
30
    </children>
30
    </children>
31
    <styles xmi:type="notation:ShapeStyle" xmi:id="_sFlvPT-OEd2DT6rVsxRmdQ" fontName="Microsoft Sans Serif" fontHeight="10" fillColor="13761016" lineColor="0"/>
31
    <styles xmi:type="notation:ShapeStyle" xmi:id="_sFlvPT-OEd2DT6rVsxRmdQ" fontName="Microsoft Sans Serif" fontHeight="10" fillColor="13761016" lineColor="0"/>
32
    <element xmi:type="ecore:EClass" href="Ecore.ecore#//EStringToStringMapEntry"/>
32
    <element xmi:type="ecore:EClass" href="Ecore.ecore#//EStringToStringMapEntry"/>
33
    <layoutConstraint xmi:type="notation:Bounds" xmi:id="_sFlvPj-OEd2DT6rVsxRmdQ" x="96" y="396"/>
33
    <layoutConstraint xmi:type="notation:Bounds" xmi:id="_sFlvPj-OEd2DT6rVsxRmdQ" x="90" y="423"/>
34
  </children>
34
  </children>
35
  <children xmi:type="notation:Node" xmi:id="_sFlvPz-OEd2DT6rVsxRmdQ" type="1001">
35
  <children xmi:type="notation:Node" xmi:id="_sFlvPz-OEd2DT6rVsxRmdQ" type="1001">
36
    <children xmi:type="notation:Node" xmi:id="_sFlvQD-OEd2DT6rVsxRmdQ" type="4001"/>
36
    <children xmi:type="notation:Node" xmi:id="_sFlvQD-OEd2DT6rVsxRmdQ" type="4001"/>
Lines 40-45 Link Here
40
      <styles xmi:type="notation:FilteringStyle" xmi:id="_sFlvRD-OEd2DT6rVsxRmdQ"/>
40
      <styles xmi:type="notation:FilteringStyle" xmi:id="_sFlvRD-OEd2DT6rVsxRmdQ"/>
41
    </children>
41
    </children>
42
    <children xmi:type="notation:Node" xmi:id="_sFlvRT-OEd2DT6rVsxRmdQ" type="5002">
42
    <children xmi:type="notation:Node" xmi:id="_sFlvRT-OEd2DT6rVsxRmdQ" type="5002">
43
      <children xmi:type="notation:Node" xmi:id="_qywyMLP2Ed2JrdFLh2Y_ww" type="2002">
44
        <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eClass"/>
45
        <layoutConstraint xmi:type="notation:Location" xmi:id="_qywyMbP2Ed2JrdFLh2Y_ww"/>
46
      </children>
47
      <children xmi:type="notation:Node" xmi:id="_qyxZQLP2Ed2JrdFLh2Y_ww" type="2002">
48
        <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eIsProxy"/>
49
        <layoutConstraint xmi:type="notation:Location" xmi:id="_qyxZQbP2Ed2JrdFLh2Y_ww"/>
50
      </children>
51
      <children xmi:type="notation:Node" xmi:id="_qyxZQrP2Ed2JrdFLh2Y_ww" type="2002">
52
        <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eResource"/>
53
        <layoutConstraint xmi:type="notation:Location" xmi:id="_qyxZQ7P2Ed2JrdFLh2Y_ww"/>
54
      </children>
55
      <children xmi:type="notation:Node" xmi:id="_qyxZRLP2Ed2JrdFLh2Y_ww" type="2002">
56
        <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eContainer"/>
57
        <layoutConstraint xmi:type="notation:Location" xmi:id="_qyxZRbP2Ed2JrdFLh2Y_ww"/>
58
      </children>
59
      <children xmi:type="notation:Node" xmi:id="_qyxZRrP2Ed2JrdFLh2Y_ww" type="2002">
60
        <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eContainingFeature"/>
61
        <layoutConstraint xmi:type="notation:Location" xmi:id="_qyxZR7P2Ed2JrdFLh2Y_ww"/>
62
      </children>
63
      <children xmi:type="notation:Node" xmi:id="_qyyAULP2Ed2JrdFLh2Y_ww" type="2002">
64
        <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eContainmentFeature"/>
65
        <layoutConstraint xmi:type="notation:Location" xmi:id="_qyyAUbP2Ed2JrdFLh2Y_ww"/>
66
      </children>
67
      <children xmi:type="notation:Node" xmi:id="_qyyAUrP2Ed2JrdFLh2Y_ww" type="2002">
68
        <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eContents"/>
69
        <layoutConstraint xmi:type="notation:Location" xmi:id="_qyyAU7P2Ed2JrdFLh2Y_ww"/>
70
      </children>
71
      <children xmi:type="notation:Node" xmi:id="_qyyAVLP2Ed2JrdFLh2Y_ww" type="2002">
72
        <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eAllContents"/>
73
        <layoutConstraint xmi:type="notation:Location" xmi:id="_qyyAVbP2Ed2JrdFLh2Y_ww"/>
74
      </children>
75
      <children xmi:type="notation:Node" xmi:id="_qyyAVrP2Ed2JrdFLh2Y_ww" type="2002">
76
        <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eCrossReferences"/>
77
        <layoutConstraint xmi:type="notation:Location" xmi:id="_qyyAV7P2Ed2JrdFLh2Y_ww"/>
78
      </children>
79
      <children xmi:type="notation:Node" xmi:id="_qyynYLP2Ed2JrdFLh2Y_ww" type="2002">
80
        <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eGet"/>
81
        <layoutConstraint xmi:type="notation:Location" xmi:id="_qyynYbP2Ed2JrdFLh2Y_ww"/>
82
      </children>
83
      <children xmi:type="notation:Node" xmi:id="_qyynYrP2Ed2JrdFLh2Y_ww" type="2002">
84
        <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eGet.1"/>
85
        <layoutConstraint xmi:type="notation:Location" xmi:id="_qyynY7P2Ed2JrdFLh2Y_ww"/>
86
      </children>
87
      <children xmi:type="notation:Node" xmi:id="_qyzOcLP2Ed2JrdFLh2Y_ww" type="2002">
88
        <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eSet"/>
89
        <layoutConstraint xmi:type="notation:Location" xmi:id="_qyzOcbP2Ed2JrdFLh2Y_ww"/>
90
      </children>
91
      <children xmi:type="notation:Node" xmi:id="_qyzOcrP2Ed2JrdFLh2Y_ww" type="2002">
92
        <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eIsSet"/>
93
        <layoutConstraint xmi:type="notation:Location" xmi:id="_qyzOc7P2Ed2JrdFLh2Y_ww"/>
94
      </children>
95
      <children xmi:type="notation:Node" xmi:id="_qyzOdLP2Ed2JrdFLh2Y_ww" type="2002">
96
        <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eUnset"/>
97
        <layoutConstraint xmi:type="notation:Location" xmi:id="_qyzOdbP2Ed2JrdFLh2Y_ww"/>
98
      </children>
99
      <children xmi:type="notation:Node" xmi:id="_xxmzoLP2Ed2JrdFLh2Y_ww" type="2002">
100
        <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eCall"/>
101
        <layoutConstraint xmi:type="notation:Location" xmi:id="_xxmzobP2Ed2JrdFLh2Y_ww"/>
102
      </children>
43
      <styles xmi:type="notation:DrawerStyle" xmi:id="_sFlvRj-OEd2DT6rVsxRmdQ"/>
103
      <styles xmi:type="notation:DrawerStyle" xmi:id="_sFlvRj-OEd2DT6rVsxRmdQ"/>
44
      <styles xmi:type="notation:SortingStyle" xmi:id="_sFlvRz-OEd2DT6rVsxRmdQ"/>
104
      <styles xmi:type="notation:SortingStyle" xmi:id="_sFlvRz-OEd2DT6rVsxRmdQ"/>
45
      <styles xmi:type="notation:FilteringStyle" xmi:id="_sFlvSD-OEd2DT6rVsxRmdQ"/>
105
      <styles xmi:type="notation:FilteringStyle" xmi:id="_sFlvSD-OEd2DT6rVsxRmdQ"/>
Lines 72-78 Link Here
72
    <styles xmi:type="notation:ConnectorStyle" xmi:id="_sFlvdT-OEd2DT6rVsxRmdQ" routing="Rectilinear" lineColor="0"/>
132
    <styles xmi:type="notation:ConnectorStyle" xmi:id="_sFlvdT-OEd2DT6rVsxRmdQ" routing="Rectilinear" lineColor="0"/>
73
    <styles xmi:type="notation:FontStyle" xmi:id="_sFlvdj-OEd2DT6rVsxRmdQ" fontName="Microsoft Sans Serif" fontHeight="10"/>
133
    <styles xmi:type="notation:FontStyle" xmi:id="_sFlvdj-OEd2DT6rVsxRmdQ" fontName="Microsoft Sans Serif" fontHeight="10"/>
74
    <element xmi:type="ecore:EReference" href="Ecore.ecore#//EAnnotation/contents"/>
134
    <element xmi:type="ecore:EReference" href="Ecore.ecore#//EAnnotation/contents"/>
75
    <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_sFlvdz-OEd2DT6rVsxRmdQ" points="[-43, -23, -43, 173]$[-43, -68, -43, 128]"/>
135
    <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_sFlvdz-OEd2DT6rVsxRmdQ" points="[-33, -23, -76, 186]$[-33, -73, -76, 136]"/>
76
  </edges>
136
  </edges>
77
  <edges xmi:type="notation:Edge" xmi:id="_sFlveD-OEd2DT6rVsxRmdQ" type="3002" source="_sFlvIT-OEd2DT6rVsxRmdQ" target="_sFlvPz-OEd2DT6rVsxRmdQ">
137
  <edges xmi:type="notation:Edge" xmi:id="_sFlveD-OEd2DT6rVsxRmdQ" type="3002" source="_sFlvIT-OEd2DT6rVsxRmdQ" target="_sFlvPz-OEd2DT6rVsxRmdQ">
78
    <children xmi:type="notation:Node" xmi:id="_sFlveT-OEd2DT6rVsxRmdQ" type="4011">
138
    <children xmi:type="notation:Node" xmi:id="_sFlveT-OEd2DT6rVsxRmdQ" type="4011">
Lines 84-89 Link Here
84
    <styles xmi:type="notation:ConnectorStyle" xmi:id="_sFlvfT-OEd2DT6rVsxRmdQ" routing="Rectilinear" lineColor="0"/>
144
    <styles xmi:type="notation:ConnectorStyle" xmi:id="_sFlvfT-OEd2DT6rVsxRmdQ" routing="Rectilinear" lineColor="0"/>
85
    <styles xmi:type="notation:FontStyle" xmi:id="_sFlvfj-OEd2DT6rVsxRmdQ" fontName="Microsoft Sans Serif" fontHeight="10"/>
145
    <styles xmi:type="notation:FontStyle" xmi:id="_sFlvfj-OEd2DT6rVsxRmdQ" fontName="Microsoft Sans Serif" fontHeight="10"/>
86
    <element xmi:type="ecore:EReference" href="Ecore.ecore#//EAnnotation/references"/>
146
    <element xmi:type="ecore:EReference" href="Ecore.ecore#//EAnnotation/references"/>
87
    <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_sFlvfz-OEd2DT6rVsxRmdQ" points="[41, -23, 41, 173]$[41, -68, 41, 128]"/>
147
    <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_sFlvfz-OEd2DT6rVsxRmdQ" points="[39, -23, -4, 186]$[39, -73, -4, 136]"/>
88
  </edges>
148
  </edges>
89
</notation:Diagram>
149
</notation:Diagram>
(-)model/EcoreDataTypes.ecorediag (+7 lines)
Lines 224-229 Link Here
224
    <element xmi:type="ecore:EDataType" href="Ecore.ecore#//ETreeIterator"/>
224
    <element xmi:type="ecore:EDataType" href="Ecore.ecore#//ETreeIterator"/>
225
    <layoutConstraint xmi:type="notation:Bounds" xmi:id="_n9W90D-IEd2DT6rVsxRmdQ" x="408" y="228"/>
225
    <layoutConstraint xmi:type="notation:Bounds" xmi:id="_n9W90D-IEd2DT6rVsxRmdQ" x="408" y="228"/>
226
  </children>
226
  </children>
227
  <children xmi:type="notation:Node" xmi:id="_z-RYILP5Ed2JrdFLh2Y_ww" type="1004">
228
    <children xmi:type="notation:Node" xmi:id="_z-VpkLP5Ed2JrdFLh2Y_ww" type="4008"/>
229
    <children xmi:type="notation:Node" xmi:id="_z-VpkbP5Ed2JrdFLh2Y_ww" type="4009"/>
230
    <styles xmi:type="notation:ShapeStyle" xmi:id="_z-RYIbP5Ed2JrdFLh2Y_ww" fontName="Lucida Grande" fontHeight="10" fillColor="13420443" lineColor="8421504"/>
231
    <element xmi:type="ecore:EDataType" href="Ecore.ecore#//EInvocationTargetException"/>
232
    <layoutConstraint xmi:type="notation:Bounds" xmi:id="_z-RYIrP5Ed2JrdFLh2Y_ww" x="-216" y="585"/>
233
  </children>
227
  <styles xmi:type="notation:DiagramStyle" xmi:id="_n9W90T-IEd2DT6rVsxRmdQ"/>
234
  <styles xmi:type="notation:DiagramStyle" xmi:id="_n9W90T-IEd2DT6rVsxRmdQ"/>
228
  <element xmi:type="ecore:EPackage" href="Ecore.ecore#/"/>
235
  <element xmi:type="ecore:EPackage" href="Ecore.ecore#/"/>
229
</notation:Diagram>
236
</notation:Diagram>
(-)src/org/eclipse/emf/ecore/impl/EcorePackageImpl.java (-1 / +30 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002-2007 IBM Corporation and others.
4
 * Copyright (c) 2002-2008 IBM Corporation, Zeligsoft Inc., and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 9-14 Link Here
9
 * 
9
 * 
10
 * Contributors: 
10
 * Contributors: 
11
 *   IBM - Initial API and implementation
11
 *   IBM - Initial API and implementation
12
 *   Zeligsoft - 255469 Implement basic eCall support
12
 *
13
 *
13
 * </copyright>
14
 * </copyright>
14
 *
15
 *
Lines 17-22 Link Here
17
package org.eclipse.emf.ecore.impl;
18
package org.eclipse.emf.ecore.impl;
18
19
19
20
21
import java.lang.reflect.InvocationTargetException;
20
import java.math.BigDecimal;
22
import java.math.BigDecimal;
21
import java.math.BigInteger;
23
import java.math.BigInteger;
22
import java.util.ArrayList;
24
import java.util.ArrayList;
Lines 410-415 Link Here
410
   * <!-- end-user-doc -->
412
   * <!-- end-user-doc -->
411
   * @generated
413
   * @generated
412
   */
414
   */
415
  private EDataType eInvocationTargetExceptionEDataType = null;
416
417
  /**
418
   * <!-- begin-user-doc -->
419
   * <!-- end-user-doc -->
420
   * @generated
421
   */
413
  private EDataType eFeatureMapEntryEDataType = null;
422
  private EDataType eFeatureMapEntryEDataType = null;
414
423
415
  /**
424
  /**
Lines 1835-1840 Link Here
1835
   * <!-- end-user-doc -->
1844
   * <!-- end-user-doc -->
1836
   * @generated
1845
   * @generated
1837
   */
1846
   */
1847
  public EDataType getEInvocationTargetException()
1848
  {
1849
    return eInvocationTargetExceptionEDataType;
1850
  }
1851
1852
  /**
1853
   * <!-- begin-user-doc -->
1854
   * <!-- end-user-doc -->
1855
   * @generated
1856
   */
1838
  public EDataType getEFeatureMapEntry()
1857
  public EDataType getEFeatureMapEntry()
1839
  {
1858
  {
1840
    return eFeatureMapEntryEDataType;
1859
    return eFeatureMapEntryEDataType;
Lines 2074-2079 Link Here
2074
    eShortObjectEDataType = createEDataType(ESHORT_OBJECT);
2093
    eShortObjectEDataType = createEDataType(ESHORT_OBJECT);
2075
    eStringEDataType = createEDataType(ESTRING);
2094
    eStringEDataType = createEDataType(ESTRING);
2076
    eTreeIteratorEDataType = createEDataType(ETREE_ITERATOR);
2095
    eTreeIteratorEDataType = createEDataType(ETREE_ITERATOR);
2096
    eInvocationTargetExceptionEDataType = createEDataType(EINVOCATION_TARGET_EXCEPTION);
2077
  }
2097
  }
2078
2098
2079
  /**
2099
  /**
Lines 2282-2287 Link Here
2282
    op = addEOperation(eObjectEClass, null, "eUnset", 0, 1, IS_UNIQUE, IS_ORDERED);
2302
    op = addEOperation(eObjectEClass, null, "eUnset", 0, 1, IS_UNIQUE, IS_ORDERED);
2283
    addEParameter(op, this.getEStructuralFeature(), "feature", 0, 1, IS_UNIQUE, IS_ORDERED);
2303
    addEParameter(op, this.getEStructuralFeature(), "feature", 0, 1, IS_UNIQUE, IS_ORDERED);
2284
2304
2305
    op = addEOperation(eObjectEClass, this.getEJavaObject(), "eCall", 0, 1, IS_UNIQUE, IS_ORDERED);
2306
    addEParameter(op, this.getEOperation(), "operation", 0, 1, IS_UNIQUE, IS_ORDERED);
2307
    g1 = createEGenericType(ecorePackage.getEEList());
2308
    g2 = createEGenericType();
2309
    g1.getETypeArguments().add(g2);
2310
    addEParameter(op, g1, "arguments", 0, 1, IS_UNIQUE, IS_ORDERED);
2311
    addEException(op, this.getEInvocationTargetException());
2312
2285
    initEClass(eOperationEClass, EOperation.class, "EOperation", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
2313
    initEClass(eOperationEClass, EOperation.class, "EOperation", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
2286
    initEReference(getEOperation_EContainingClass(), this.getEClass(), this.getEClass_EOperations(), "eContainingClass", null, 0, 1, EOperation.class, IS_TRANSIENT, !IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
2314
    initEReference(getEOperation_EContainingClass(), this.getEClass(), this.getEClass_EOperations(), "eContainingClass", null, 0, 1, EOperation.class, IS_TRANSIENT, !IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
2287
    initEReference(getEOperation_ETypeParameters(), this.getETypeParameter(), null, "eTypeParameters", null, 0, -1, EOperation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
2315
    initEReference(getEOperation_ETypeParameters(), this.getETypeParameter(), null, "eTypeParameters", null, 0, -1, EOperation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
Lines 2387-2392 Link Here
2387
    initEDataType(eShortObjectEDataType, Short.class, "EShortObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
2415
    initEDataType(eShortObjectEDataType, Short.class, "EShortObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
2388
    initEDataType(eStringEDataType, String.class, "EString", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
2416
    initEDataType(eStringEDataType, String.class, "EString", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
2389
    initEDataType(eTreeIteratorEDataType, TreeIterator.class, "ETreeIterator", !IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
2417
    initEDataType(eTreeIteratorEDataType, TreeIterator.class, "ETreeIterator", !IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
2418
    initEDataType(eInvocationTargetExceptionEDataType, InvocationTargetException.class, "EInvocationTargetException", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS);
2390
2419
2391
    // Create resource
2420
    // Create resource
2392
    createResource(eNS_URI);
2421
    createResource(eNS_URI);
(-)src/org/eclipse/emf/ecore/impl/EOperationImpl.java (-2 / +39 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002-2007 IBM Corporation and others.
4
 * Copyright (c) 2002-2008 IBM Corporation, Zeligsoft Inc., and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 9-14 Link Here
9
 * 
9
 * 
10
 * Contributors: 
10
 * Contributors: 
11
 *   IBM - Initial API and implementation
11
 *   IBM - Initial API and implementation
12
 *   Zeligsoft - 255469 Implement basic eCall support
12
 *
13
 *
13
 * </copyright>
14
 * </copyright>
14
 *
15
 *
Lines 28-33 Link Here
28
import org.eclipse.emf.common.notify.NotificationChain;
29
import org.eclipse.emf.common.notify.NotificationChain;
29
import org.eclipse.emf.common.notify.impl.NotificationImpl;
30
import org.eclipse.emf.common.notify.impl.NotificationImpl;
30
import org.eclipse.emf.common.util.EList;
31
import org.eclipse.emf.common.util.EList;
32
import org.eclipse.emf.common.util.URI;
31
import org.eclipse.emf.ecore.EAnnotation;
33
import org.eclipse.emf.ecore.EAnnotation;
32
import org.eclipse.emf.ecore.EClass;
34
import org.eclipse.emf.ecore.EClass;
33
import org.eclipse.emf.ecore.EClassifier;
35
import org.eclipse.emf.ecore.EClassifier;
Lines 38-46 Link Here
38
import org.eclipse.emf.ecore.EcoreFactory;
40
import org.eclipse.emf.ecore.EcoreFactory;
39
import org.eclipse.emf.ecore.EcorePackage;
41
import org.eclipse.emf.ecore.EcorePackage;
40
import org.eclipse.emf.ecore.InternalEObject;
42
import org.eclipse.emf.ecore.InternalEObject;
43
import org.eclipse.emf.ecore.util.BasicCallDelegate;
41
import org.eclipse.emf.ecore.util.DelegatingEcoreEList;
44
import org.eclipse.emf.ecore.util.DelegatingEcoreEList;
42
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
45
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
43
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
46
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
47
import org.eclipse.emf.ecore.util.EcoreUtil;
44
// import org.eclipse.emf.ecore.util.EObjectResolvingEList;
48
// import org.eclipse.emf.ecore.util.EObjectResolvingEList;
45
import org.eclipse.emf.ecore.util.InternalEList;
49
import org.eclipse.emf.ecore.util.InternalEList;
46
50
Lines 48-53 Link Here
48
/**
52
/**
49
 * <!-- begin-user-doc -->
53
 * <!-- begin-user-doc -->
50
 * An implementation of the model object '<em><b>EOperation</b></em>'.
54
 * An implementation of the model object '<em><b>EOperation</b></em>'.
55
 * @extends EOperation.Internal
51
 * <!-- end-user-doc -->
56
 * <!-- end-user-doc -->
52
 * <p>
57
 * <p>
53
 * The following features are implemented:
58
 * The following features are implemented:
Lines 62-68 Link Here
62
 *
67
 *
63
 * @generated
68
 * @generated
64
 */
69
 */
65
public class EOperationImpl extends ETypedElementImpl implements EOperation
70
public class EOperationImpl extends ETypedElementImpl implements EOperation, EOperation.Internal
66
{
71
{
67
  /**
72
  /**
68
   * The cached value of the '{@link #getETypeParameters() <em>EType Parameters</em>}' containment reference list.
73
   * The cached value of the '{@link #getETypeParameters() <em>EType Parameters</em>}' containment reference list.
Lines 1007-1010 Link Here
1007
    return eDynamicIsSet(featureID);
1012
    return eDynamicIsSet(featureID);
1008
  }
1013
  }
1009
1014
1015
  protected EOperation.Internal.CallDelegate callDelegate;
1016
  
1017
  public CallDelegate getCallDelegate()
1018
  {
1019
    if (callDelegate == null)
1020
    {
1021
      CallDelegate.Factory factory = null;
1022
      String callDelegateKey = EcoreUtil.getAnnotation(this, EcorePackage.eNS_URI,
1023
    	  "callDelegate");
1024
      if (callDelegateKey != null)
1025
      {
1026
        factory = CallDelegate.Factory.Registry.INSTANCE.getFactory(
1027
        	URI.createURI(callDelegateKey).trimFragment().trimQuery().toString());
1028
      }
1029
      if (factory != null)
1030
      {
1031
        callDelegate = factory.createCallDelegate(this);
1032
      }
1033
      if (callDelegate == null)
1034
      {
1035
         callDelegate = new BasicCallDelegate(this);
1036
      }
1037
    }
1038
    
1039
    return callDelegate;
1040
  }
1041
  
1042
  public void setCallDelegate(CallDelegate callDelegate)
1043
  {
1044
    this.callDelegate = callDelegate;
1045
  }
1046
  
1010
}
1047
}
(-)src/org/eclipse/emf/ecore/impl/EcoreFactoryImpl.java (-1 / +27 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002-2006 IBM Corporation and others.
4
 * Copyright (c) 2002-2008 IBM Corporation, Zeligsoft Inc., and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 9-14 Link Here
9
 * 
9
 * 
10
 * Contributors: 
10
 * Contributors: 
11
 *   IBM - Initial API and implementation
11
 *   IBM - Initial API and implementation
12
 *   Zeligsoft - 255469 Implement basic eCall support
12
 *
13
 *
13
 * </copyright>
14
 * </copyright>
14
 *
15
 *
Lines 17-22 Link Here
17
package org.eclipse.emf.ecore.impl;
18
package org.eclipse.emf.ecore.impl;
18
19
19
20
21
import java.lang.reflect.InvocationTargetException;
20
import java.math.BigDecimal;
22
import java.math.BigDecimal;
21
import java.math.BigInteger;
23
import java.math.BigInteger;
22
import java.text.ParseException;
24
import java.text.ParseException;
Lines 161-166 Link Here
161
        return createEShortObjectFromString(eDataType, initialValue);
163
        return createEShortObjectFromString(eDataType, initialValue);
162
      case EcorePackage.ESTRING:
164
      case EcorePackage.ESTRING:
163
        return createEStringFromString(eDataType, initialValue);
165
        return createEStringFromString(eDataType, initialValue);
166
      case EcorePackage.EINVOCATION_TARGET_EXCEPTION:
167
        return createEInvocationTargetExceptionFromString(eDataType, initialValue);
164
      default:
168
      default:
165
        throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
169
        throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
166
    }
170
    }
Lines 222-227 Link Here
222
        return convertEShortObjectToString(eDataType, instanceValue);
226
        return convertEShortObjectToString(eDataType, instanceValue);
223
      case EcorePackage.ESTRING:
227
      case EcorePackage.ESTRING:
224
        return convertEStringToString(eDataType, instanceValue);
228
        return convertEStringToString(eDataType, instanceValue);
229
      case EcorePackage.EINVOCATION_TARGET_EXCEPTION:
230
        return convertEInvocationTargetExceptionToString(eDataType, instanceValue);
225
      default:
231
      default:
226
        throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
232
        throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
227
    }
233
    }
Lines 657-662 Link Here
657
  /**
663
  /**
658
   * <!-- begin-user-doc -->
664
   * <!-- begin-user-doc -->
659
   * <!-- end-user-doc -->
665
   * <!-- end-user-doc -->
666
   * @generated
667
   */
668
  public InvocationTargetException createEInvocationTargetExceptionFromString(EDataType eDataType, String initialValue)
669
  {
670
    return (InvocationTargetException)super.createFromString(eDataType, initialValue);
671
  }
672
673
  /**
674
   * <!-- begin-user-doc -->
675
   * <!-- end-user-doc -->
676
   * @generated
677
   */
678
  public String convertEInvocationTargetExceptionToString(EDataType eDataType, Object instanceValue)
679
  {
680
    return super.convertToString(eDataType, instanceValue);
681
  }
682
683
		/**
684
   * <!-- begin-user-doc -->
685
   * <!-- end-user-doc -->
660
   * @generated NOT
686
   * @generated NOT
661
   */
687
   */
662
  public Integer createEIntFromString(EDataType metaObject, String initialValue) 
688
  public Integer createEIntFromString(EDataType metaObject, String initialValue) 
(-)src/org/eclipse/emf/ecore/impl/BasicEObjectImpl.java (-1 / +10 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2002-2007 IBM Corporation and others.
4
 * Copyright (c) 2002-2008 IBM Corporation, Zeligsoft Inc., and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 9-14 Link Here
9
 * 
9
 * 
10
 * Contributors: 
10
 * Contributors: 
11
 *   IBM - Initial API and implementation
11
 *   IBM - Initial API and implementation
12
 *   Zeligsoft - 255469 Implement basic eCall support
12
 *
13
 *
13
 * </copyright>
14
 * </copyright>
14
 *
15
 *
Lines 17-22 Link Here
17
package org.eclipse.emf.ecore.impl;
18
package org.eclipse.emf.ecore.impl;
18
19
19
20
21
import java.lang.reflect.InvocationTargetException;
20
import java.util.ArrayList;
22
import java.util.ArrayList;
21
import java.util.Iterator;
23
import java.util.Iterator;
22
import java.util.List;
24
import java.util.List;
Lines 35-40 Link Here
35
import org.eclipse.emf.ecore.EDataType;
37
import org.eclipse.emf.ecore.EDataType;
36
import org.eclipse.emf.ecore.EFactory;
38
import org.eclipse.emf.ecore.EFactory;
37
import org.eclipse.emf.ecore.EObject;
39
import org.eclipse.emf.ecore.EObject;
40
import org.eclipse.emf.ecore.EOperation;
38
import org.eclipse.emf.ecore.EReference;
41
import org.eclipse.emf.ecore.EReference;
39
import org.eclipse.emf.ecore.EStructuralFeature;
42
import org.eclipse.emf.ecore.EStructuralFeature;
40
import org.eclipse.emf.ecore.ETypedElement;
43
import org.eclipse.emf.ecore.ETypedElement;
Lines 1972-1977 Link Here
1972
    }
1975
    }
1973
  }
1976
  }
1974
  
1977
  
1978
  public Object eCall(EOperation operation, EList<?> arguments) throws InvocationTargetException
1979
  {
1980
	return ((EOperation.Internal) operation).getCallDelegate().dynamicCall(this,
1981
		arguments);
1982
  }
1983
  
1975
  @Override
1984
  @Override
1976
  public String toString()
1985
  public String toString()
1977
  {
1986
  {
(-)src/org/eclipse/emf/ecore/impl/EStructuralFeatureImpl.java (-5 / +71 lines)
Lines 17-22 Link Here
17
package org.eclipse.emf.ecore.impl;
17
package org.eclipse.emf.ecore.impl;
18
18
19
19
20
import java.io.Externalizable;
21
import java.io.IOException;
22
import java.io.ObjectInput;
23
import java.io.ObjectOutput;
24
import java.io.ObjectStreamException;
25
import java.io.Serializable;
20
import java.util.Collection;
26
import java.util.Collection;
21
import java.util.List;
27
import java.util.List;
22
import java.util.Map;
28
import java.util.Map;
Lines 26-31 Link Here
26
import org.eclipse.emf.common.notify.impl.NotificationChainImpl;
32
import org.eclipse.emf.common.notify.impl.NotificationChainImpl;
27
import org.eclipse.emf.common.util.BasicEMap;
33
import org.eclipse.emf.common.util.BasicEMap;
28
import org.eclipse.emf.common.util.EMap;
34
import org.eclipse.emf.common.util.EMap;
35
import org.eclipse.emf.common.util.URI;
29
import org.eclipse.emf.ecore.EAnnotation;
36
import org.eclipse.emf.ecore.EAnnotation;
30
import org.eclipse.emf.ecore.EClass;
37
import org.eclipse.emf.ecore.EClass;
31
import org.eclipse.emf.ecore.EClassifier;
38
import org.eclipse.emf.ecore.EClassifier;
Lines 33-38 Link Here
33
import org.eclipse.emf.ecore.EDataType;
40
import org.eclipse.emf.ecore.EDataType;
34
import org.eclipse.emf.ecore.EFactory;
41
import org.eclipse.emf.ecore.EFactory;
35
import org.eclipse.emf.ecore.EObject;
42
import org.eclipse.emf.ecore.EObject;
43
import org.eclipse.emf.ecore.EPackage;
36
import org.eclipse.emf.ecore.EReference;
44
import org.eclipse.emf.ecore.EReference;
37
import org.eclipse.emf.ecore.EStructuralFeature;
45
import org.eclipse.emf.ecore.EStructuralFeature;
38
import org.eclipse.emf.ecore.EcorePackage;
46
import org.eclipse.emf.ecore.EcorePackage;
Lines 52-57 Link Here
52
import org.eclipse.emf.ecore.util.EcoreUtil;
60
import org.eclipse.emf.ecore.util.EcoreUtil;
53
import org.eclipse.emf.ecore.util.ExtendedMetaData;
61
import org.eclipse.emf.ecore.util.ExtendedMetaData;
54
import org.eclipse.emf.ecore.util.FeatureMap;
62
import org.eclipse.emf.ecore.util.FeatureMap;
63
import org.eclipse.emf.ecore.util.FeatureMapUtil;
55
import org.eclipse.emf.ecore.util.InternalEList;
64
import org.eclipse.emf.ecore.util.InternalEList;
56
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
65
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
57
66
Lines 816-825 Link Here
816
      Object intrinsicDefaultValue = eType.getDefaultValue();
825
      Object intrinsicDefaultValue = eType.getDefaultValue();
817
826
818
      EStructuralFeature featureMapFeature;
827
      EStructuralFeature featureMapFeature;
819
      if (isDerived() && 
828
      EAnnotation eAnnotation;
820
            (((featureMapFeature = ExtendedMetaData.INSTANCE.getMixedFeature(eClass)) != null && 
829
      String settingDelegateKey;
821
               featureMapFeature != this) ||
830
      SettingDelegate.Factory settingDelegateFactory;
822
              ((featureMapFeature = ExtendedMetaData.INSTANCE.getGroup(this)) != null)))
831
      boolean derived = isDerived();
832
      if (derived && 
833
            (eAnnotation = getEAnnotation(EcorePackage.eNS_URI)) != null && 
834
            (settingDelegateKey = eAnnotation.getDetails().get("settingDelegate")) != null &&
835
            (settingDelegateFactory = 
836
               SettingDelegate.Factory.Registry.INSTANCE.getFactory
837
                 (URI.createURI(settingDelegateKey).trimFragment().trimQuery().toString())) != null)
838
      {
839
        settingDelegate = settingDelegateFactory.createSettingDelegate(this);
840
      }
841
      else if (derived && 
842
                 (((featureMapFeature = ExtendedMetaData.INSTANCE.getMixedFeature(eClass)) != null && 
843
                    featureMapFeature != this) ||
844
                    ((featureMapFeature = ExtendedMetaData.INSTANCE.getGroup(this)) != null)))
823
      {
845
      {
824
        settingDelegate = new InternalSettingDelegateFeatureMapDelegator(this, featureMapFeature);
846
        settingDelegate = new InternalSettingDelegateFeatureMapDelegator(this, featureMapFeature);
825
      }
847
      }
Lines 2886-2892 Link Here
2886
    return cachedIsFeatureMap;
2908
    return cachedIsFeatureMap;
2887
  }
2909
  }
2888
  
2910
  
2889
  public static abstract class BasicFeatureMapEntry implements FeatureMap.Entry.Internal
2911
  public static abstract class BasicFeatureMapEntry implements FeatureMap.Entry.Internal, Serializable
2890
  {
2912
  {
2891
    protected final EStructuralFeature.Internal eStructuralFeature;
2913
    protected final EStructuralFeature.Internal eStructuralFeature;
2892
2914
Lines 2967-2972 Link Here
2967
            eStructuralFeature.getName()) + 
2989
            eStructuralFeature.getName()) + 
2968
           "=" + getValue();
2990
           "=" + getValue();
2969
    }
2991
    }
2992
    
2993
    protected static class WriteReplacement implements Externalizable
2994
    {
2995
      FeatureMap.Entry featureMapEntry;
2996
2997
      public WriteReplacement()
2998
      {
2999
        super();
3000
      }
3001
3002
      public WriteReplacement(FeatureMap.Entry featureMapEntry)
3003
      {
3004
        this.featureMapEntry = featureMapEntry;
3005
      }
3006
          
3007
      public void writeExternal(ObjectOutput out) throws IOException
3008
      {
3009
        EStructuralFeature eStructuralFeature = featureMapEntry.getEStructuralFeature();
3010
        EClass eClass = eStructuralFeature.getEContainingClass();
3011
        out.writeUTF(eClass.getEPackage().getNsURI());
3012
        out.writeUTF(eClass.getName());
3013
        out.writeUTF(eStructuralFeature.getName());
3014
        out.writeObject(featureMapEntry.getValue());
3015
      }
3016
          
3017
      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
3018
      {
3019
        EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(in.readUTF());
3020
        EClass eClass =  (EClass)ePackage.getEClassifier(in.readUTF());
3021
        EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(in.readUTF());
3022
        Object value = in.readObject();
3023
        featureMapEntry = FeatureMapUtil.createRawEntry(eStructuralFeature, value);
3024
      }
3025
3026
      private Object readResolve()
3027
      {
3028
        return featureMapEntry;
3029
      }
3030
    }
3031
3032
    public Object writeReplace() throws ObjectStreamException
3033
    {
3034
      return  new WriteReplacement(this);
3035
    }
2970
  }
3036
  }
2971
3037
2972
  public final static class SimpleFeatureMapEntry extends BasicFeatureMapEntry
3038
  public final static class SimpleFeatureMapEntry extends BasicFeatureMapEntry
(-)src/org/eclipse/emf/ecore/util/EcoreValidator.java (-1 / +15 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006-2007 IBM Corporation and others.
4
 * Copyright (c) 2006-2008 IBM Corporation, Zeligsoft Inc., and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 9-14 Link Here
9
 *
9
 *
10
 * Contributors:
10
 * Contributors:
11
 *   IBM - Initial API and implementation
11
 *   IBM - Initial API and implementation
12
 *   Zeligsoft - 255469 Implement basic eCall support
12
 *
13
 *
13
 * </copyright>
14
 * </copyright>
14
 *
15
 *
Lines 16-21 Link Here
16
 */
17
 */
17
package org.eclipse.emf.ecore.util;
18
package org.eclipse.emf.ecore.util;
18
19
20
import java.lang.reflect.InvocationTargetException;
19
import java.math.BigDecimal;
21
import java.math.BigDecimal;
20
import java.math.BigInteger;
22
import java.math.BigInteger;
21
23
Lines 496-501 Link Here
496
        return validateEString((String)value, diagnostics, context);
498
        return validateEString((String)value, diagnostics, context);
497
      case EcorePackage.ETREE_ITERATOR:
499
      case EcorePackage.ETREE_ITERATOR:
498
        return validateETreeIterator((TreeIterator<?>)value, diagnostics, context);
500
        return validateETreeIterator((TreeIterator<?>)value, diagnostics, context);
501
      case EcorePackage.EINVOCATION_TARGET_EXCEPTION:
502
        return validateEInvocationTargetException((InvocationTargetException)value, diagnostics, context);
499
      default:
503
      default:
500
        return true;
504
        return true;
501
    }
505
    }
Lines 4044-4049 Link Here
4044
  }
4048
  }
4045
4049
4046
  /**
4050
  /**
4051
   * <!-- begin-user-doc -->
4052
   * <!-- end-user-doc -->
4053
   * @generated
4054
   */
4055
  public boolean validateEInvocationTargetException(InvocationTargetException eInvocationTargetException, DiagnosticChain diagnostics, Map<Object, Object> context)
4056
  {
4057
    return true;
4058
  }
4059
4060
  /**
4047
   * Returns the resource locator that will be used to fetch messages for this validator's diagnostics.
4061
   * Returns the resource locator that will be used to fetch messages for this validator's diagnostics.
4048
   * <!-- begin-user-doc -->
4062
   * <!-- begin-user-doc -->
4049
   * <!-- end-user-doc -->
4063
   * <!-- end-user-doc -->
(-)src/org/eclipse/emf/ecore/util/BasicSettingDelegate.java (+306 lines)
Added Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2008 IBM Corporation, Zeligsoft Inc., 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
 *   Zeligsoft - 216701 Removed redundant eStructuralFeature field from Stateless
13
 *
14
 * </copyright>
15
 *
16
 * $Id$
17
 */
18
package org.eclipse.emf.ecore.util;
19
20
import org.eclipse.emf.common.notify.NotificationChain;
21
import org.eclipse.emf.ecore.EObject;
22
import org.eclipse.emf.ecore.EStructuralFeature;
23
import org.eclipse.emf.ecore.InternalEObject;
24
import org.eclipse.emf.ecore.EStructuralFeature.Setting;
25
import org.eclipse.emf.ecore.EStructuralFeature.Internal.DynamicValueHolder;
26
27
/**
28
 * A basic implementation of a stateful setting delegate.
29
 * At least the first two of these methods needs to be overridden.
30
 * <ul>
31
 *   <li>{@link #dynamicGet(InternalEObject, DynamicValueHolder, int, boolean, boolean)}</li>
32
 *   <li>{@link #dynamicIsSet(InternalEObject, DynamicValueHolder, int)}</li>
33
 *   <li>{@link #dynamicSet(InternalEObject, DynamicValueHolder, int, Object)}</li>
34
 *   <li>{@link #dynamicUnset(InternalEObject, DynamicValueHolder, int)}</li>
35
 *   <li>{@link #dynamicInverseAdd(InternalEObject, DynamicValueHolder, int, InternalEObject, NotificationChain)}</li>
36
 *   <li>{@link #dynamicInverseRemove(InternalEObject, DynamicValueHolder, int, InternalEObject, NotificationChain)}</li>
37
 * </ul>
38
 */
39
public abstract class BasicSettingDelegate implements EStructuralFeature.Internal.SettingDelegate
40
{
41
  protected EStructuralFeature eStructuralFeature;
42
43
  public BasicSettingDelegate(EStructuralFeature eStructuralFeature)
44
  {
45
    this.eStructuralFeature = eStructuralFeature;
46
  }
47
48
  public Setting dynamicSetting(final InternalEObject owner, final DynamicValueHolder settings, final int dynamicFeatureID)
49
  {
50
    return 
51
      new EStructuralFeature.Setting()
52
      {
53
        public EObject getEObject()
54
        {
55
          return owner;
56
        }
57
58
        public EStructuralFeature getEStructuralFeature()
59
        {
60
          return eStructuralFeature;
61
        }
62
63
        public Object get(boolean resolve)
64
        {
65
          return BasicSettingDelegate.this.dynamicGet(owner, settings, dynamicFeatureID, resolve, true);
66
        }
67
68
        public boolean isSet()
69
        {
70
          return BasicSettingDelegate.this.dynamicIsSet(owner, settings, dynamicFeatureID);
71
        }
72
73
        public void set(Object newValue)
74
        {
75
          BasicSettingDelegate.this.dynamicSet(owner, settings, dynamicFeatureID, newValue);
76
        }
77
78
        public void unset()
79
        {
80
          BasicSettingDelegate.this.dynamicUnset(owner, settings, dynamicFeatureID);
81
        }
82
      };
83
  }
84
85
  public abstract Object dynamicGet(InternalEObject owner, DynamicValueHolder settings, int dynamicFeatureID, boolean resolve, boolean coreType);
86
87
88
  public abstract boolean dynamicIsSet(InternalEObject owner, DynamicValueHolder settings, int dynamicFeatureID);
89
  
90
91
  public void dynamicSet(InternalEObject owner, DynamicValueHolder settings, int dynamicFeatureID, Object newValue)
92
  {
93
    throw new UnsupportedOperationException();
94
  }
95
96
  public void dynamicUnset(InternalEObject owner, DynamicValueHolder settings, int dynamicFeatureID)
97
  {
98
    throw new UnsupportedOperationException();
99
  }
100
101
  public NotificationChain dynamicInverseAdd
102
   (InternalEObject owner,
103
    DynamicValueHolder settings,
104
    int dynamicFeatureID,
105
    InternalEObject otherEnd,
106
    NotificationChain notifications)
107
  {
108
    throw new UnsupportedOperationException();
109
  }
110
111
  public NotificationChain dynamicInverseRemove
112
   (InternalEObject owner,
113
    DynamicValueHolder settings,
114
    int dynamicFeatureID,
115
    InternalEObject otherEnd,
116
    NotificationChain notifications)
117
  {
118
    throw new UnsupportedOperationException();
119
  }
120
121
  /**
122
   * A basic implementation of a stateless setting delegate.
123
   * At least the first two of these methods should be overridden.
124
   * <ul>
125
   *   <li>{@link #setting(InternalEObject)}</li>
126
   *   <li>{@link #get(InternalEObject, boolean, boolean)}</li>
127
   *   <li>{@link #set(InternalEObject, Object)}</li>
128
   *   <li>{@link #isSet(InternalEObject)}</li>
129
   *   <li>{@link #unset(InternalEObject)}</li>
130
   *   <li>{@link #inverseAdd(InternalEObject, InternalEObject, NotificationChain)}</li>
131
   *   <li>{@link #inverseRemove(InternalEObject, InternalEObject, NotificationChain)}</li>
132
   * </ul>
133
   */
134
  public static abstract class Stateless extends BasicSettingDelegate
135
  {
136
    public Stateless(EStructuralFeature eStructuralFeature)
137
    {
138
      super(eStructuralFeature);
139
    }
140
141
    @Override
142
    public final Setting dynamicSetting(InternalEObject owner, DynamicValueHolder settings, int dynamicFeatureID)
143
    {
144
      return setting(owner);
145
    }
146
147
    /**
148
     * Creates a setting for the owner and this delegate's feature.
149
     * @param owner the owner for the setting.
150
     * @return a new setting.
151
     */
152
    protected Setting setting(final InternalEObject owner)
153
    {
154
      return 
155
        new EStructuralFeature.Setting()
156
        {
157
          public EObject getEObject()
158
          {
159
            return owner;
160
          }
161
  
162
          public EStructuralFeature getEStructuralFeature()
163
          {
164
            return eStructuralFeature;
165
          }
166
  
167
          public Object get(boolean resolve)
168
          {
169
            return Stateless.this.get(owner, resolve, true);
170
          }
171
  
172
          public boolean isSet()
173
          {
174
            return Stateless.this.isSet(owner);
175
          }
176
  
177
          public void set(Object newValue)
178
          {
179
            Stateless.this.set(owner, newValue);
180
          }
181
  
182
          public void unset()
183
          {
184
            Stateless.this.unset(owner);
185
          }
186
        };
187
    }
188
  
189
    @Override
190
    public final Object dynamicGet(InternalEObject owner, DynamicValueHolder settings, int dynamicFeatureID, boolean resolve, boolean coreType)
191
    {
192
      return get(owner, resolve, coreType);
193
    }
194
  
195
    /**
196
     * Returns the value of this delegate's feature for the owner.
197
     * @param owner the object for with to fetch the value.
198
     * @param resolve whether the returned object should be resolved it if is a proxy.
199
     * @param coreType whether to return the core type value or the API type value.
200
     * @return the value of this delegate's feature for the owner.
201
     * @see InternalEObject#eGet(EStructuralFeature, boolean, boolean)
202
     */
203
    protected abstract Object get(InternalEObject owner, boolean resolve, boolean coreType);
204
  
205
    @Override
206
    public final boolean dynamicIsSet(InternalEObject owner, DynamicValueHolder settings, int dynamicFeatureID)
207
    {
208
      return isSet(owner);
209
    }
210
  
211
    /**
212
     * Returns whether the value of this delegate's feature is considered set for the owner.
213
     * @param owner the object for with to test is set.
214
     * @return whether the value of this delegate's feature is considered set for the owner.
215
     * @see EObject#eIsSet(EStructuralFeature)
216
     */
217
    protected abstract boolean isSet(InternalEObject owner);
218
  
219
    @Override
220
    public final void dynamicSet(InternalEObject owner, DynamicValueHolder settings, int dynamicFeatureID, Object newValue)
221
    {
222
      set(owner, newValue);
223
    }
224
  
225
    /**
226
     * Sets this new value of this delegate's feature for the owner.
227
     * @param owner the owner for which to set the value
228
     * @param newValue the new value for the feature.
229
     * @see EObject#eSet(EStructuralFeature, Object)
230
     */
231
    protected void set(InternalEObject owner, Object newValue)
232
    {
233
      throw new UnsupportedOperationException();
234
    }
235
  
236
    @Override
237
    public final void dynamicUnset(InternalEObject owner, DynamicValueHolder settings, int dynamicFeatureID)
238
    {
239
      unset(owner);
240
    }
241
  
242
    /**
243
     * Unsets the values of this delegate's feature for the owner.
244
     * @param owner the owner for which to unset the value.
245
     * @see EObject#eUnset(EStructuralFeature)
246
     */
247
    protected void unset(InternalEObject owner)
248
    {
249
      throw new UnsupportedOperationException();
250
    }
251
  
252
    @Override
253
    public final NotificationChain dynamicInverseAdd
254
     (InternalEObject owner,
255
      DynamicValueHolder settings,
256
      int dynamicFeatureID,
257
      InternalEObject otherEnd,
258
      NotificationChain notifications)
259
    {
260
      return inverseAdd(owner, otherEnd, notifications);
261
    }
262
  
263
    /**
264
     * Adds the object at the other end of a bidirectional reference to this delegate's feature
265
     * and returns accumulated notifications.
266
     * @param owner the owner for which to do the inverse add.
267
     * @param otherEnd the object to inverse add.
268
     * @param notifications the notifications accumulated so far.
269
     * @return the accumulated notifications.
270
     */
271
    protected NotificationChain inverseAdd
272
     (InternalEObject owner,
273
      InternalEObject otherEnd,
274
      NotificationChain notifications)
275
    {
276
      throw new UnsupportedOperationException();
277
    }
278
  
279
    @Override
280
    public final NotificationChain dynamicInverseRemove
281
     (InternalEObject owner,
282
      DynamicValueHolder settings,
283
      int dynamicFeatureID,
284
      InternalEObject otherEnd,
285
      NotificationChain notifications)
286
    {
287
      return inverseRemove(owner, otherEnd, notifications);
288
    }
289
  
290
    /**
291
     * Remove the object at the other end of a bidirectional reference from this delegate's feature
292
     * and returns accumulated notifications.
293
     * @param owner the owner for which to do the inverse remove.
294
     * @param otherEnd the object to inverse remove.
295
     * @param notifications the notifications accumulated so far.
296
     * @return the accumulated notifications.
297
     */
298
    protected NotificationChain inverseRemove
299
     (InternalEObject owner,
300
      InternalEObject otherEnd,
301
      NotificationChain notifications)
302
    {
303
      throw new UnsupportedOperationException();
304
    }
305
  }
306
}
(-)src/org/eclipse/emf/ecore/util/PathSettingDelegate.java (+115 lines)
Added Link Here
1
/**
2
 * <copyright>
3
 *
4
 * Copyright (c) 2008 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$
16
 */
17
package org.eclipse.emf.ecore.util;
18
19
20
import java.util.ArrayList;
21
import java.util.List;
22
23
import org.eclipse.emf.common.util.URI;
24
import org.eclipse.emf.ecore.EClass;
25
import org.eclipse.emf.ecore.EObject;
26
import org.eclipse.emf.ecore.EStructuralFeature;
27
import org.eclipse.emf.ecore.EcorePackage;
28
import org.eclipse.emf.ecore.InternalEObject;
29
30
public class PathSettingDelegate extends BasicSettingDelegate.Stateless
31
{
32
  protected EStructuralFeature[] path;
33
34
  public PathSettingDelegate(EStructuralFeature eStructuralFeature)
35
  {
36
    super(eStructuralFeature);
37
    String namePath = URI.createURI(eStructuralFeature.getEAnnotation(EcorePackage.eNS_URI).getDetails().get("settingDelegate")).fragment();
38
    String[] segments = namePath.split("/");
39
    path = new EStructuralFeature[segments.length];
40
    for (int i = 0; i < segments.length; ++i)
41
    {
42
      String featureName = segments[i];
43
      EClass eClass = i == 0 ? eStructuralFeature.getEContainingClass() : (EClass)path[i - 1].getEType();
44
      path[i] = eClass.getEStructuralFeature(featureName);
45
    }
46
  }
47
48
  public PathSettingDelegate(EStructuralFeature eStructuralFeature, EStructuralFeature[] path)
49
  {
50
    super(eStructuralFeature);
51
    this.path = path;
52
  }
53
54
  @Override
55
  protected Object get(InternalEObject owner, boolean resolve, boolean coreType)
56
  {
57
    InternalEObject eObject = owner;
58
    for (int i = 0, limit = path.length - 1; i < limit; ++i)
59
    {
60
      EStructuralFeature feature = path[i];
61
      if (feature.isMany())
62
      {
63
        ArrayList<Object> result = new ArrayList<Object>();
64
        @SuppressWarnings("unchecked")
65
        List<EObject> elements = (List<EObject>)eObject.eGet(feature, resolve, coreType);
66
        for (EObject element : elements)
67
        {
68
          Object value = element.eGet(path[i + 1]);
69
          result.add(value);
70
        }
71
        return
72
          new EcoreEList.UnmodifiableEList.FastCompare<Object>
73
            (owner, eStructuralFeature, result.size(), result.toArray());
74
      }
75
      else
76
      {
77
        eObject = (InternalEObject)eObject.eGet(feature);
78
      }
79
    }
80
    return eObject.eGet(path[path.length - 1], resolve, coreType);
81
  }
82
83
  @Override
84
  protected boolean isSet(InternalEObject owner)
85
  {
86
    InternalEObject eObject = owner;
87
    for (int i = 0, limit = path.length - 1; i < limit; ++i)
88
    {
89
      eObject = (InternalEObject)eObject.eGet(path[i]);
90
    }
91
    return eObject.eIsSet(path[path.length - 1]);
92
  }
93
94
  @Override
95
  protected void set(InternalEObject owner, Object newValue)
96
  {
97
    InternalEObject eObject = owner;
98
    for (int i = 0, limit = path.length - 1; i < limit; ++i)
99
    {
100
      eObject = (InternalEObject)eObject.eGet(path[i]);
101
    }
102
    eObject.eSet(path[path.length - 1], newValue);
103
  }
104
105
  @Override
106
  protected void unset(InternalEObject owner)
107
  {
108
    InternalEObject eObject = owner;
109
    for (int i = 0, limit = path.length - 1; i < limit; ++i)
110
    {
111
      eObject = (InternalEObject)eObject.eGet(path[i]);
112
    }
113
    eObject.eUnset(path[path.length - 1]);
114
  }
115
}
(-)src/org/eclipse/emf/ecore/util/BasicCallDelegate.java (+99 lines)
Added Link Here
1
/**
2
 * <copyright>
3
 * 
4
 * Copyright (c) 2008 Zeligsoft Inc. 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
 *   Zeligsoft - Initial API and implementation
12
 * 
13
 * </copyright>
14
 *
15
 * $Id$
16
 */
17
18
package org.eclipse.emf.ecore.util;
19
20
import java.lang.reflect.InvocationTargetException;
21
22
import org.eclipse.emf.common.util.EList;
23
import org.eclipse.emf.ecore.EObject;
24
import org.eclipse.emf.ecore.EStructuralFeature;
25
import org.eclipse.emf.ecore.EcorePackage;
26
import org.eclipse.emf.ecore.InternalEObject;
27
import org.eclipse.emf.ecore.EOperation;
28
29
30
/**
31
 * A basic implementation of the dynamic operation-call delegate API.  In fact,
32
 * it is so basic that it isn't much an implementation at all, but merely
33
 * throws {@link UnsupportedOperationException} on every invocation, except for
34
 * the operations define for the {@link EObject} class.
35
 * Subclasses should override the {@link #dynamicCall(InternalEObject, EList)}
36
 * method to not do that.
37
 */
38
public class BasicCallDelegate implements EOperation.Internal.CallDelegate
39
{
40
  protected EOperation eOperation;
41
  
42
  /**
43
   * Initializes me with the operation that delegates calls to me.
44
   * 
45
   * @param operation my operation
46
   */
47
  public BasicCallDelegate(EOperation operation)
48
  {
49
    this.eOperation = operation;
50
  }
51
52
  public Object dynamicCall(InternalEObject target, EList<?> arguments)	throws InvocationTargetException
53
  {
54
    if (eOperation.getEContainingClass() == EcorePackage.Literals.EOBJECT)
55
    {
56
      //TODO: EOperations should have IDs, like structural features.
57
      // These IDs should be listed in the generated package interface
58
      int id = eOperation.getEContainingClass().getEAllOperations().indexOf(eOperation);
59
      
60
      switch (id) {
61
      case 0: // EcorePackage.EOBJECT___ECLASS
62
        return target.eClass();
63
      case 1: // EcorePackage.EOBJECT___EIS_PROXY
64
        return target.eIsProxy();
65
      case 2: // EcorePackage.EOBJECT___ERESOURCE
66
        return target.eResource();
67
      case 3: // EcorePackage.EOBJECT___ECONTAINER
68
        return target.eContainer();
69
      case 4: // EcorePackage.EOBJECT___ECONTAINING_FEATURE
70
        return target.eContainingFeature();
71
      case 5: // EcorePackage.EOBJECT___ECONTAINMENT_FEATURE
72
        return target.eContainmentFeature();
73
      case 6: // EcorePackage.EOBJECT___ECONTENTS
74
        return target.eContents();
75
      case 7: // EcorePackage.EOBJECT___EALL_CONTENTS
76
        return target.eAllContents();
77
      case 8: // EcorePackage.EOBJECT___ECROSS_REFERENCES
78
        return target.eCrossReferences();
79
      case 9: // EcorePackage.EOBJECT___EGET__FEATURE
80
        return target.eGet((EStructuralFeature) arguments.get(0));
81
      case 10: // EcorePackage.EOBJECT___EGET__FEATURE__RESOLVE
82
        return target.eGet((EStructuralFeature) arguments.get(0), (Boolean) arguments.get(1));
83
      case 11: // EcorePackage.EOBJECT___ESET__FEATURE__NEW_VALUE
84
        target.eSet((EStructuralFeature) arguments.get(0), arguments.get(1));
85
        return null;
86
      case 12: // EcorePackage.EOBJECT___EIS_SET__FEATURE
87
        return target.eIsSet((EStructuralFeature) arguments.get(0));
88
      case 13: // EcorePackage.EOBJECT___EUNSET__FEATURE
89
        target.eUnset((EStructuralFeature) arguments.get(0));
90
        return null;
91
      case 14: // EcorePackage.EOBJECT___ECALL__OPERATION__ARGUMENTS
92
        return target.eCall((EOperation) arguments.get(0), (EList<?>) arguments.get(1));
93
      }
94
    }
95
    
96
    throw new UnsupportedOperationException("eCall not implemented for " + eOperation.getName());
97
  }
98
99
}

Return to bug 255469