Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 118009 Details for
Bug 255469
Investigate support for dynamic EOperation call API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
The real eCall prototype patch
operation-call-elegate.patch (text/plain), 107.24 KB, created by
Christian Damus
on 2008-11-16 16:23:52 EST
(
hide
)
Description:
The real eCall prototype patch
Filename:
MIME Type:
Creator:
Christian Damus
Created:
2008-11-16 16:23:52 EST
Size:
107.24 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ocl.ecore.tests >Index: src/org/eclipse/ocl/ecore/tests/AbstractTestSuite.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.mdt/org.eclipse.ocl/tests/org.eclipse.ocl.ecore.tests/src/org/eclipse/ocl/ecore/tests/AbstractTestSuite.java,v >retrieving revision 1.16 >diff -u -r1.16 AbstractTestSuite.java >--- src/org/eclipse/ocl/ecore/tests/AbstractTestSuite.java 10 Oct 2008 15:23:39 -0000 1.16 >+++ src/org/eclipse/ocl/ecore/tests/AbstractTestSuite.java 16 Nov 2008 21:20:32 -0000 >@@ -9,7 +9,7 @@ > * > * Contributors: > * IBM - Initial API and implementation >- * Zeligsoft - Bugs 243079, 244948, 244886, 245619 >+ * Zeligsoft - Bugs 243079, 244948, 244886, 245619, 216701 > * > * </copyright> > * >@@ -162,6 +162,7 @@ > result.addTest(RegressionTest.suite()); > result.addTest(EcoreEnvironmentTest.suite()); > result.addTest(ExtensibilityTest.suite()); >+ result.addTest(OCLSettingDelegateTest.suite()); > result.addTest(ValidationTest.suite()); > result.addTest(ProblemOptionTest.suite()); > result.addTest(ParsingOptionsTest.suite()); >Index: src/org/eclipse/ocl/ecore/tests/OCLSettingDelegateTest.java >=================================================================== >RCS file: src/org/eclipse/ocl/ecore/tests/OCLSettingDelegateTest.java >diff -N src/org/eclipse/ocl/ecore/tests/OCLSettingDelegateTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ocl/ecore/tests/OCLSettingDelegateTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,331 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Zeligsoft Inc. and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Zeligsoft - Initial API and implementation >+ * >+ * </copyright> >+ * >+ * $Id$ >+ */ >+ >+package org.eclipse.ocl.ecore.tests; >+ >+import java.lang.reflect.InvocationTargetException; >+import java.util.Arrays; >+import java.util.Map; >+ >+import junit.framework.Test; >+import junit.framework.TestSuite; >+ >+import org.eclipse.emf.common.util.BasicEList; >+import org.eclipse.emf.common.util.ECollections; >+import org.eclipse.emf.common.util.EList; >+import org.eclipse.emf.common.util.Enumerator; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.EAttribute; >+import org.eclipse.emf.ecore.EClass; >+import org.eclipse.emf.ecore.EEnum; >+import org.eclipse.emf.ecore.EFactory; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EOperation; >+import org.eclipse.emf.ecore.EPackage; >+import org.eclipse.emf.ecore.EReference; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.emf.ecore.resource.ResourceSet; >+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >+import org.eclipse.ocl.ecore.dynamic.OCLCallDelegateFactory; >+import org.eclipse.ocl.ecore.dynamic.OCLSettingDelegateFactory; >+ >+/** >+ * Tests for the OCL setting delegate implementation. >+ * >+ * @author Christian W. Damus (cdamus) >+ */ >+@SuppressWarnings("nls") >+public class OCLSettingDelegateTest >+ extends AbstractTestSuite { >+ >+ private ResourceSet rset; >+ >+ private Resource testResource; >+ >+ private EPackage companyPackage; >+ >+ private EFactory companyFactory; >+ >+ private EClass companyClass; >+ >+ private EAttribute companyName; >+ >+ private EReference companyEmployees; >+ >+ private EAttribute companySize; >+ >+ private EClass employeeClass; >+ >+ private EAttribute employeeName; >+ >+ private EReference employeeManager; >+ >+ private EReference employeeDirectReports; >+ >+ private EReference employeeAllReports; >+ >+ private EOperation employeeReportsTo; >+ >+ private EEnum sizeKind; >+ >+ private Enumerator sizeSmall; >+ >+ private Enumerator sizeMedium; >+ >+ private Enumerator sizeLarge; >+ >+ private EObject acme; >+ >+ private Map<String, EObject> employees; >+ >+ public OCLSettingDelegateTest(String name) { >+ super(name); >+ } >+ >+ public static Test suite() { >+ return new TestSuite(OCLSettingDelegateTest.class, >+ "OCL Setting Delegate Tests"); >+ } >+ >+ public void test_eattributeDerivation() { >+ assertSame(sizeSmall, size(acme)); >+ >+ // add a load of employees >+ EList<EObject> emps = employees(acme); >+ for (int i = 0; i < 60; i++) { >+ emps.add(companyFactory.create(employeeClass)); >+ } >+ >+ assertSame(sizeMedium, size(acme)); >+ >+ // and another bunch >+ for (int i = 0; i < 1000; i++) { >+ emps.add(companyFactory.create(employeeClass)); >+ } >+ >+ assertSame(sizeLarge, size(acme)); >+ } >+ >+ public void test_ereferenceDerivation() { >+ EList<EObject> amyReports = directReports(employee("Amy")); >+ assertEquals(3, amyReports.size()); >+ assertTrue(amyReports.contains(employee("Bob"))); >+ assertTrue(amyReports.contains(employee("Jane"))); >+ assertTrue(amyReports.contains(employee("Fred"))); >+ >+ EList<EObject> bobReports = directReports(employee("Bob")); >+ assertEquals(2, bobReports.size()); >+ assertTrue(bobReports.contains(employee("Norbert"))); >+ assertTrue(bobReports.contains(employee("Sally"))); >+ >+ EList<EObject> sallyReports = directReports(employee("Sally")); >+ assertEquals(0, sallyReports.size()); >+ } >+ >+ public void test_allInstances() { >+ EList<EObject> amyAllReports = allReports(employee("Amy")); >+ assertEquals(5, amyAllReports.size()); >+ assertTrue(amyAllReports.contains(employee("Bob"))); >+ assertTrue(amyAllReports.contains(employee("Jane"))); >+ assertTrue(amyAllReports.contains(employee("Fred"))); >+ assertTrue(amyAllReports.contains(employee("Norbert"))); >+ assertTrue(amyAllReports.contains(employee("Sally"))); >+ >+ // change the set of all instances of Employee >+ set(create(acme, companyEmployees, employeeClass, "Manuel"), >+ employeeManager, employee("Bob")); >+ >+ amyAllReports = allReports(employee("Amy")); >+ assertEquals(6, amyAllReports.size()); >+ assertTrue(amyAllReports.contains(employee("Manuel"))); >+ } >+ >+ public void test_operationCall() { >+ EObject amy = employee("Amy"); >+ >+ // allReports is implemented using reportsTo() >+ EList<EObject> amyAllReports = allReports(amy); >+ assertEquals(5, amyAllReports.size()); >+ >+ for (EObject next : amyAllReports) { >+ assertTrue(this.<Boolean> call(next, employeeReportsTo, amy)); >+ } >+ } >+ >+ // >+ // Test framework >+ // >+ >+ @Override >+ protected void setUp() >+ throws Exception { >+ >+ super.setUp(); >+ >+ EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE >+ .registerFactory("org.eclipse.ocl.ecore.OCL", >+ new OCLSettingDelegateFactory()); >+ EOperation.Internal.CallDelegate.Factory.Registry.INSTANCE >+ .registerFactory("org.eclipse.ocl.ecore.OCL", >+ new OCLCallDelegateFactory()); >+ >+ rset = new ResourceSetImpl(); >+ testResource = rset.getResource(URI.createPlatformPluginURI( >+ "/org.eclipse.ocl.ecore.tests/model/TestCompany.xmi", true), true); >+ >+ acme = testResource.getContents().get(0); >+ >+ companyClass = acme.eClass(); >+ companyPackage = companyClass.getEPackage(); >+ companyFactory = companyPackage.getEFactoryInstance(); >+ >+ companyName = (EAttribute) companyClass.getEStructuralFeature("name"); >+ companyEmployees = (EReference) companyClass >+ .getEStructuralFeature("employees"); >+ companySize = (EAttribute) companyClass.getEStructuralFeature("size"); >+ >+ employeeClass = companyEmployees.getEReferenceType(); >+ employeeName = (EAttribute) employeeClass.getEStructuralFeature("name"); >+ employeeManager = (EReference) employeeClass >+ .getEStructuralFeature("manager"); >+ employeeDirectReports = (EReference) employeeClass >+ .getEStructuralFeature("directReports"); >+ employeeAllReports = (EReference) employeeClass >+ .getEStructuralFeature("allReports"); >+ employeeReportsTo = employeeClass.getEOperations().get(0); >+ >+ sizeKind = (EEnum) companySize.getEAttributeType(); >+ sizeSmall = sizeKind.getEEnumLiteral("small"); >+ sizeMedium = sizeKind.getEEnumLiteral("medium"); >+ sizeLarge = sizeKind.getEEnumLiteral("large"); >+ >+ employees = new java.util.HashMap<String, EObject>(); >+ } >+ >+ @Override >+ protected void tearDown() >+ throws Exception { >+ >+ for (Resource next : rset.getResources()) { >+ next.unload(); >+ } >+ rset.getResources().clear(); >+ rset = null; >+ testResource = null; >+ companyPackage = null; >+ companyFactory = null; >+ employees = null; >+ >+ EOperation.Internal.CallDelegate.Factory.Registry.INSTANCE >+ .deregisterFactory("org.eclipse.ocl.ecore.OCL"); >+ EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE >+ .deregisterFactory("org.eclipse.ocl.ecore.OCL"); >+ >+ super.tearDown(); >+ } >+ >+ EObject employee(String name) { >+ EObject result = employees.get(name); >+ if (result == null) { >+ EList<EObject> emps = get(acme, companyEmployees); >+ for (EObject next : emps) { >+ if (name.equals(name(next))) { >+ result = next; >+ employees.put(name, result); >+ break; >+ } >+ } >+ } >+ >+ return result; >+ } >+ >+ String name(EObject employeeOrCompany) { >+ EAttribute name = employeeClass.isInstance(employeeOrCompany) >+ ? employeeName >+ : companyName; >+ return get(employeeOrCompany, name); >+ } >+ >+ EObject manager(EObject employee) { >+ return get(employee, employeeManager); >+ } >+ >+ EList<EObject> directReports(EObject employee) { >+ return get(employee, employeeDirectReports); >+ } >+ >+ EList<EObject> allReports(EObject employee) { >+ return get(employee, employeeAllReports); >+ } >+ >+ EList<EObject> employees(EObject company) { >+ return get(company, companyEmployees); >+ } >+ >+ Enumerator size(EObject company) { >+ return get(company, companySize); >+ } >+ >+ @SuppressWarnings("unchecked") >+ <T> T get(EObject owner, EStructuralFeature feature) { >+ return (T) owner.eGet(feature); >+ } >+ >+ void set(EObject owner, EStructuralFeature feature, Object value) { >+ owner.eSet(feature, value); >+ } >+ >+ void add(EObject owner, EStructuralFeature feature, Object value) { >+ this.<EList<Object>> get(owner, feature).add(value); >+ } >+ >+ EObject create(EObject owner, EReference containment, EClass type, >+ String name) { >+ EObject result = companyFactory.create(type); >+ >+ if (containment.isMany()) { >+ add(owner, containment, result); >+ } else { >+ set(owner, containment, result); >+ } >+ >+ if (name != null) { >+ set(result, type.getEStructuralFeature("name"), name); >+ } >+ >+ return result; >+ } >+ >+ <T> EList<T> list(T... element) { >+ return new BasicEList<T>(Arrays.asList(element)); >+ } >+ >+ @SuppressWarnings("unchecked") >+ <T> T call(EObject target, EOperation operation, Object... arguments) { >+ try { >+ return (T) target.eCall(operation, (arguments.length == 0) >+ ? ECollections.<Object> emptyEList() >+ : new BasicEList.UnmodifiableEList<Object>(arguments.length, >+ arguments)); >+ } catch (InvocationTargetException e) { >+ fail("Failed to call operation: " + e.getLocalizedMessage()); >+ return null; >+ } >+ } >+} >Index: model/SettingDelegateTest.ecore >=================================================================== >RCS file: model/SettingDelegateTest.ecore >diff -N model/SettingDelegateTest.ecore >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ model/SettingDelegateTest.ecore 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,58 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<ecore:EPackage xmi:version="2.0" >+ xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="settingtest" >+ nsURI="http://www.eclipse.org/ocl/test/2008/SettingDelegate" nsPrefix="st"> >+ <eClassifiers xsi:type="ecore:EClass" name="Company"> >+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> >+ <eStructuralFeatures xsi:type="ecore:EReference" name="employees" upperBound="-1" >+ eType="#//Employee" containment="true" eOpposite="#//Employee/company"/> >+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="size" lowerBound="1" eType="#//CompanySizeKind" >+ changeable="false" volatile="true" transient="true" derived="true"> >+ <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore"> >+ <details key="settingDelegate" value="org.eclipse.ocl.ecore.OCL"/> >+ <details key="OCL" value="let table : Set(Tuple(range : Sequence(Integer), size : CompanySizeKind)) =
 Set{Tuple{range=Sequence{0..49}, size=CompanySizeKind::small},
 Tuple{range=Sequence{50..999}, size=CompanySizeKind::medium},
 Tuple{range=Sequence{1000..1000000}, size=CompanySizeKind::large}} in
table->any(range->includes(employees->size())).size"/> >+ </eAnnotations> >+ </eStructuralFeatures> >+ </eClassifiers> >+ <eClassifiers xsi:type="ecore:EClass" name="Employee"> >+ <eOperations name="reportsTo" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"> >+ <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore"> >+ <details key="callDelegate" value="org.eclipse.ocl.ecore.OCL"/> >+ <details key="OCL" value="self.reportingChain->includes(manager)"/> >+ </eAnnotations> >+ <eParameters name="manager" eType="#//Employee"/> >+ </eOperations> >+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> >+ <eStructuralFeatures xsi:type="ecore:EReference" name="manager" eType="#//Employee"/> >+ <eStructuralFeatures xsi:type="ecore:EReference" name="company" lowerBound="1" >+ eType="#//Company" eOpposite="#//Company/employees"/> >+ <eStructuralFeatures xsi:type="ecore:EReference" name="directReports" upperBound="-1" >+ eType="#//Employee" changeable="false" volatile="true" transient="true" derived="true"> >+ <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore"> >+ <details key="settingDelegate" value="org.eclipse.ocl.ecore.OCL"/> >+ <details key="OCL" value="company.employees->select(manager = self)"/> >+ </eAnnotations> >+ </eStructuralFeatures> >+ <eStructuralFeatures xsi:type="ecore:EReference" name="allReports" ordered="false" >+ upperBound="-1" eType="#//Employee" changeable="false" volatile="true" transient="true" >+ derived="true"> >+ <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore"> >+ <details key="settingDelegate" value="org.eclipse.ocl.ecore.OCL"/> >+ <details key="OCL" value="Employee.allInstances()->select(reportsTo(self))"/> >+ </eAnnotations> >+ </eStructuralFeatures> >+ <eStructuralFeatures xsi:type="ecore:EReference" name="reportingChain" upperBound="-1" >+ eType="#//Employee" changeable="false" volatile="true" transient="true" derived="true"> >+ <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore"> >+ <details key="settingDelegate" value="org.eclipse.ocl.ecore.OCL"/> >+ <details key="OCL" value="if (manager.oclIsUndefined()) then
 OrderedSet{}
else
 manager.reportingChain->prepend(manager)
endif"/> >+ </eAnnotations> >+ </eStructuralFeatures> >+ </eClassifiers> >+ <eClassifiers xsi:type="ecore:EEnum" name="CompanySizeKind"> >+ <eLiterals name="small"/> >+ <eLiterals name="medium" value="1"/> >+ <eLiterals name="large" value="2"/> >+ </eClassifiers> >+</ecore:EPackage> >Index: model/TestCompany.xmi >=================================================================== >RCS file: model/TestCompany.xmi >diff -N model/TestCompany.xmi >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ model/TestCompany.xmi 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,9 @@ >+<?xml version="1.0" encoding="ASCII"?> >+<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"> >+ <employees name="Bob" manager="//@employees.3"/> >+ <employees name="Jane" manager="//@employees.3"/> >+ <employees name="Fred" manager="//@employees.3"/> >+ <employees name="Amy"/> >+ <employees name="Norbert" manager="//@employees.0"/> >+ <employees name="Sally" manager="//@employees.0"/> >+</st:Company> >#P org.eclipse.ocl.ecore >Index: src/org/eclipse/ocl/ecore/EcoreEvaluationEnvironment.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.mdt/org.eclipse.ocl/plugins/org.eclipse.ocl.ecore/src/org/eclipse/ocl/ecore/EcoreEvaluationEnvironment.java,v >retrieving revision 1.7 >diff -u -r1.7 EcoreEvaluationEnvironment.java >--- src/org/eclipse/ocl/ecore/EcoreEvaluationEnvironment.java 16 Feb 2008 00:07:23 -0000 1.7 >+++ src/org/eclipse/ocl/ecore/EcoreEvaluationEnvironment.java 16 Nov 2008 21:20:34 -0000 >@@ -1,7 +1,7 @@ > /** > * <copyright> > * >- * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 IBM Corporation, Zeligsoft Inc., and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -9,6 +9,7 @@ > * > * Contributors: > * IBM - Initial API and implementation >+ * Zeligsoft - Bug 255469 > * > * </copyright> > * >@@ -17,6 +18,7 @@ > > package org.eclipse.ocl.ecore; > >+import java.lang.reflect.InvocationTargetException; > import java.lang.reflect.Method; > import java.util.Collection; > import java.util.Collections; >@@ -24,6 +26,8 @@ > import java.util.Map; > import java.util.Set; > >+import org.eclipse.emf.common.util.BasicEList; >+import org.eclipse.emf.common.util.ECollections; > import org.eclipse.emf.common.util.EList; > import org.eclipse.emf.common.util.Enumerator; > import org.eclipse.emf.ecore.EClass; >@@ -35,6 +39,7 @@ > import org.eclipse.emf.ecore.EReference; > import org.eclipse.emf.ecore.EStructuralFeature; > import org.eclipse.emf.ecore.ETypedElement; >+import org.eclipse.emf.ecore.impl.DynamicEObjectImpl; > import org.eclipse.ocl.AbstractEvaluationEnvironment; > import org.eclipse.ocl.EvaluationEnvironment; > import org.eclipse.ocl.LazyExtentMap; >@@ -84,6 +89,21 @@ > Object source, Object[] args) > throws IllegalArgumentException { > >+ // FIXME: Pull up so that UML environment can benefit. This is only here >+ // for now in order to avoid including org.eclipse.ocl in the patch >+ if (source instanceof DynamicEObjectImpl) { >+ EList<Object> arguments = (args.length == 0) >+ ? ECollections.emptyEList() >+ : new BasicEList.UnmodifiableEList<Object>(args.length, args); >+ >+ try { >+ return coerceValue(operation, ((EObject) source).eCall( >+ operation, arguments), true); >+ } catch (InvocationTargetException e) { >+ throw new IllegalArgumentException(e); >+ } >+ } >+ > // TODO: WBN to pull up createValue to the superclass as a pass-thru > // so that subclasses don't have to override callOperation > return coerceValue(operation, super.callOperation(operation, opcode, >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.mdt/org.eclipse.ocl/plugins/org.eclipse.ocl.ecore/META-INF/MANIFEST.MF,v >retrieving revision 1.9 >diff -u -r1.9 MANIFEST.MF >--- META-INF/MANIFEST.MF 21 Sep 2008 12:19:58 -0000 1.9 >+++ META-INF/MANIFEST.MF 16 Nov 2008 21:20:34 -0000 >@@ -14,7 +14,9 @@ > Eclipse-LazyStart: true > Bundle-ActivationPolicy: lazy > Export-Package: org.eclipse.ocl.ecore, >+ org.eclipse.ocl.ecore.dynamic, > org.eclipse.ocl.ecore.impl, > org.eclipse.ocl.ecore.internal;x-friends:="org.eclipse.ocl.ecore.tests,org.eclipse.emf.ocl", >+ org.eclipse.ocl.ecore.internal.l10n, > org.eclipse.ocl.ecore.util > Bundle-RequiredExecutionEnvironment: J2SE-1.5 >Index: src/org/eclipse/ocl/ecore/internal/l10n/OCLEcoreMessages.properties >=================================================================== >RCS file: src/org/eclipse/ocl/ecore/internal/l10n/OCLEcoreMessages.properties >diff -N src/org/eclipse/ocl/ecore/internal/l10n/OCLEcoreMessages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ocl/ecore/internal/l10n/OCLEcoreMessages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,31 @@ >+############################################################################### >+# Copyright (c) 2008 Zeligsoft Inc. and others. >+# All rights reserved. This program and the accompanying materials >+# are made available under the terms of the Eclipse Public License v1.0 >+# which accompanies this distribution, and is available at >+# http://www.eclipse.org/legal/epl-v10.html >+# >+# Contributors: >+# Zeligsoft - initial API and implementation >+# >+# $Id$ >+# >+############################################################################### >+ >+# >+# Indicates an invalid derivation expression for an EStructuralFeature >+# in the OCL setting delegate annotation >+# >+# 0 - the EClass name that owns the feature >+# 1 - the EStructuralFeature name >+# 2 - the OCL parser's error message >+bad_attribute_derivation = Invalid OCL attribute derivation for {0}.{1}: {2} >+ >+# >+# Indicates an invalid body expression for an EOperation >+# in the OCL call delegate annotation >+# >+# 0 - the EClass name that owns the operation >+# 1 - the EOperation name >+# 2 - the OCL parser's error message >+bad_operation_body = Invalid OCL operation body for {0}.{1}: {2} >Index: src/org/eclipse/ocl/ecore/dynamic/OCLCallDelegate.java >=================================================================== >RCS file: src/org/eclipse/ocl/ecore/dynamic/OCLCallDelegate.java >diff -N src/org/eclipse/ocl/ecore/dynamic/OCLCallDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ocl/ecore/dynamic/OCLCallDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,106 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Zeligsoft Inc. and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Zeligsoft - Initial API and implementation >+ * >+ * </copyright> >+ * >+ * $Id$ >+ */ >+ >+package org.eclipse.ocl.ecore.dynamic; >+ >+import java.lang.reflect.InvocationTargetException; >+ >+import org.eclipse.emf.common.util.EList; >+import org.eclipse.emf.ecore.EClass; >+import org.eclipse.emf.ecore.EClassifier; >+import org.eclipse.emf.ecore.EOperation; >+import org.eclipse.emf.ecore.EPackage; >+import org.eclipse.emf.ecore.EParameter; >+import org.eclipse.emf.ecore.EcorePackage; >+import org.eclipse.emf.ecore.InternalEObject; >+import org.eclipse.emf.ecore.util.BasicCallDelegate; >+import org.eclipse.emf.ecore.util.EcoreUtil; >+import org.eclipse.ocl.EvaluationEnvironment; >+import org.eclipse.ocl.ParserException; >+import org.eclipse.ocl.ecore.OCL; >+import org.eclipse.ocl.expressions.OCLExpression; >+ >+/** >+ * An implementation of an operation-call delegate for OCL body expressions. >+ * >+ * @author Christian W. Damus (cdamus) >+ * >+ * @since 1.3 >+ */ >+public class OCLCallDelegate >+ extends BasicCallDelegate { >+ >+ private OCL ocl; >+ >+ private OCLExpression<EClassifier> body; >+ >+ private ValueConverter converter; >+ >+ /** >+ * Initializes me with my operation. >+ * >+ * @param operation >+ * the operation that I handle >+ * >+ * @throws ParserException >+ * if the operation's OCL body expression is invalid >+ */ >+ protected OCLCallDelegate(EOperation operation, OCLCache oclCache) >+ throws ParserException { >+ >+ super(operation); >+ >+ EClass context = operation.getEContainingClass(); >+ EPackage ePackage = context.getEPackage(); >+ >+ this.ocl = oclCache.getOCL(ePackage); >+ >+ OCL.Helper helper = ocl.createOCLHelper(); >+ helper.setOperationContext(context, operation); >+ >+ String expr = EcoreUtil.getAnnotation(operation, EcorePackage.eNS_URI, >+ "OCL"); //$NON-NLS-1$ >+ >+ this.body = helper.createBodyCondition(expr).getSpecification() >+ .getBodyExpression(); >+ >+ this.converter = operation.isMany() >+ ? ValueConverter.LIST >+ : ValueConverter.VERBATIM; >+ } >+ >+ @Override >+ public Object dynamicCall(InternalEObject target, EList<?> arguments) >+ throws InvocationTargetException { >+ >+ OCL.Query query = ocl.createQuery(body); >+ >+ EList<EParameter> parms = eOperation.getEParameters(); >+ if (!parms.isEmpty()) { >+ // bind arguments to parameter names >+ EvaluationEnvironment<EClassifier, ?, ?, ?, ?> env = query >+ .getEvaluationEnvironment(); >+ >+ for (int i = 0; i < parms.size(); i++) { >+ env.add(parms.get(i).getName(), arguments.get(i)); >+ } >+ } >+ >+ return converter.convert(ocl, query.evaluate(target)); >+ } >+ >+} >Index: src/org/eclipse/ocl/ecore/dynamic/OCLCallDelegateFactory.java >=================================================================== >RCS file: src/org/eclipse/ocl/ecore/dynamic/OCLCallDelegateFactory.java >diff -N src/org/eclipse/ocl/ecore/dynamic/OCLCallDelegateFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ocl/ecore/dynamic/OCLCallDelegateFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,119 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Zeligsoft Inc. and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Zeligsoft - Initial API and implementation >+ * >+ * </copyright> >+ * >+ * $Id$ >+ */ >+ >+package org.eclipse.ocl.ecore.dynamic; >+ >+import java.lang.reflect.InvocationTargetException; >+ >+import org.eclipse.emf.common.notify.Notification; >+import org.eclipse.emf.common.notify.impl.AdapterImpl; >+import org.eclipse.emf.common.util.ECollections; >+import org.eclipse.emf.common.util.EList; >+import org.eclipse.emf.ecore.EOperation; >+import org.eclipse.emf.ecore.EPackage; >+import org.eclipse.emf.ecore.InternalEObject; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.emf.ecore.util.BasicCallDelegate; >+import org.eclipse.ocl.ParserException; >+import org.eclipse.ocl.ecore.EcoreEnvironmentFactory; >+import org.eclipse.ocl.ecore.OCL; >+import org.eclipse.ocl.ecore.internal.OCLEcorePlugin; >+import org.eclipse.ocl.ecore.internal.l10n.OCLEcoreMessages; >+ >+/** >+ * Factory for OCL operation-call delegates. >+ * >+ * @author Christian W. Damus (cdamus) >+ * >+ * @since 1.3 >+ */ >+public class OCLCallDelegateFactory >+ extends AbstractOCLDelegateFactory >+ implements EOperation.Internal.CallDelegate.Factory { >+ >+ public EOperation.Internal.CallDelegate createCallDelegate( >+ EOperation operation) { >+ >+ EOperation.Internal.CallDelegate result; >+ >+ try { >+ result = new OCLCallDelegate(operation, getCache()); >+ } catch (ParserException e) { >+ // I will not be able to return any values >+ OCLEcorePlugin.error(1, OCLEcoreMessages.bind( >+ OCLEcoreMessages.bad_operation_body, new Object[]{ >+ operation.getEContainingClass().getName(), >+ operation.getName(), e.getLocalizedMessage()})); >+ >+ // so, return a call delegate that has no value, ever >+ return new BasicCallDelegate(operation) { >+ >+ @Override >+ public Object dynamicCall(InternalEObject target, >+ EList<?> arguments) >+ throws InvocationTargetException { >+ >+ return eOperation.isMany() >+ ? ECollections.EMPTY_ELIST >+ : null; >+ } >+ >+ }; >+ } >+ >+ return result; >+ } >+ >+ /** >+ * Creates the OCL environment in which to parse setting delegates for the >+ * specified environment. Subclasses may override to create custom >+ * environments, but should note that the result is cached. >+ * >+ * @param ePackage >+ * an Ecore package for which to create a setting delegate >+ * environment >+ * @return the environment >+ */ >+ public OCL createOCL(final EPackage ePackage) { >+ Resource res = ePackage.eResource(); >+ EcoreEnvironmentFactory envFactory; >+ >+ if ((res != null) && (res.getResourceSet() != null)) { >+ // it's a dynamic package. Use the local package registry >+ envFactory = new EcoreEnvironmentFactory(res.getResourceSet() >+ .getPackageRegistry()); >+ >+ // and expunge when it's unloaded >+ res.eAdapters().add(new AdapterImpl() { >+ >+ @Override >+ public void notifyChanged(Notification msg) { >+ if ((msg.getFeatureID(Resource.class) == Resource.RESOURCE__IS_LOADED) >+ && !msg.getNewBooleanValue()) { >+ getCache().expunge(ePackage); >+ } >+ } >+ }); >+ } else { >+ // the shared instance uses the static package registry >+ envFactory = EcoreEnvironmentFactory.INSTANCE; >+ } >+ >+ return OCL.newInstance(envFactory); >+ } >+ >+} >Index: src/org/eclipse/ocl/ecore/dynamic/ValueConverter.java >=================================================================== >RCS file: src/org/eclipse/ocl/ecore/dynamic/ValueConverter.java >diff -N src/org/eclipse/ocl/ecore/dynamic/ValueConverter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ocl/ecore/dynamic/ValueConverter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,61 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Zeligsoft Inc. and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Zeligsoft - Initial API and implementation >+ * >+ * </copyright> >+ * >+ * $Id$ >+ */ >+ >+package org.eclipse.ocl.ecore.dynamic; >+ >+import java.util.Collection; >+ >+import org.eclipse.emf.common.util.BasicEList; >+import org.eclipse.emf.common.util.ECollections; >+import org.eclipse.ocl.ecore.OCL; >+ >+/** >+ * An object that converts values according to their declared multiplicities, >+ * as collections or not. >+ * >+ * @author Christian W. Damus (cdamus) >+ * >+ * @since 1.3 >+ */ >+interface ValueConverter { >+ >+ ValueConverter VERBATIM = new ValueConverter() { >+ >+ public Object convert(OCL ocl, Object value) { >+ // no way to report problem to the user in invalid case >+ return ocl.isInvalid(value) >+ ? null >+ : value; >+ } >+ }; >+ >+ ValueConverter LIST = new ValueConverter() { >+ >+ public Object convert(OCL ocl, Object value) { >+ if (ocl.isInvalid(value)) { >+ // no way to report specific problem to the user >+ return ECollections.EMPTY_ELIST; >+ } >+ >+ Collection<?> collection = (Collection<?>) value; >+ return new BasicEList.UnmodifiableEList<Object>(collection >+ .size(), collection.toArray()); >+ } >+ }; >+ >+ Object convert(OCL ocl, Object value); >+} >\ No newline at end of file >Index: src/org/eclipse/ocl/ecore/dynamic/OCLCache.java >=================================================================== >RCS file: src/org/eclipse/ocl/ecore/dynamic/OCLCache.java >diff -N src/org/eclipse/ocl/ecore/dynamic/OCLCache.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ocl/ecore/dynamic/OCLCache.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,86 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Zeligsoft Inc. and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Zeligsoft - Initial API and implementation >+ * >+ * </copyright> >+ * >+ * $Id$ >+ */ >+ >+package org.eclipse.ocl.ecore.dynamic; >+ >+import java.lang.ref.Reference; >+ >+import org.eclipse.emf.ecore.EPackage; >+import org.eclipse.ocl.ecore.OCL; >+ >+/** >+ * A doubly-weak-referenced cache of OCL environments created to handle Ecore >+ * packages. >+ * >+ * @author Christian W. Damus (cdamus) >+ * >+ * @since 1.3 >+ */ >+final class OCLCache >+ extends java.util.WeakHashMap<EPackage, Reference<OCL>> { >+ >+ /** >+ * My OCL factory. >+ */ >+ private final Factory oclFactory; >+ >+ /** >+ * Initializes me with a factory that I may use to create OCL environments. >+ * >+ * @param oclFactory >+ * my OCL environment factory >+ */ >+ OCLCache(Factory oclFactory) { >+ this.oclFactory = oclFactory; >+ } >+ >+ protected synchronized OCL getOCL(EPackage ePackage) { >+ Reference<OCL> result = get(ePackage); >+ >+ if ((result == null) || (result.get() == null)) { >+ result = new java.lang.ref.WeakReference<OCL>(oclFactory >+ .createOCL(ePackage)); >+ } >+ >+ put(ePackage, result); >+ >+ return result.get(); >+ } >+ >+ protected synchronized void expunge(EPackage ePackage) { >+ Reference<OCL> oclRef = get(ePackage); >+ if (oclRef != null) { >+ OCL ocl = oclRef.get(); >+ >+ if (ocl != null) { >+ ocl.dispose(); >+ } >+ >+ remove(ePackage); >+ } >+ } >+ >+ /** >+ * A factory of OCL environment objects. >+ * >+ * @author Christian W. Damus (cdamus) >+ */ >+ static interface Factory { >+ >+ OCL createOCL(EPackage ePackage); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/ocl/ecore/dynamic/AbstractOCLDelegateFactory.java >=================================================================== >RCS file: src/org/eclipse/ocl/ecore/dynamic/AbstractOCLDelegateFactory.java >diff -N src/org/eclipse/ocl/ecore/dynamic/AbstractOCLDelegateFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ocl/ecore/dynamic/AbstractOCLDelegateFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,81 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Zeligsoft Inc. and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Zeligsoft - Initial API and implementation >+ * >+ * </copyright> >+ * >+ * $Id$ >+ */ >+ >+package org.eclipse.ocl.ecore.dynamic; >+ >+import org.eclipse.emf.common.notify.Notification; >+import org.eclipse.emf.common.notify.impl.AdapterImpl; >+import org.eclipse.emf.ecore.EPackage; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.ocl.ecore.EcoreEnvironmentFactory; >+import org.eclipse.ocl.ecore.OCL; >+ >+/** >+ * Partial implementation of a factory of OCL delegates for Ecore features. >+ * >+ * @author Christian W. Damus (cdamus) >+ * >+ * @since 1.3 >+ */ >+abstract class AbstractOCLDelegateFactory >+ implements OCLCache.Factory { >+ >+ private OCLCache oclCache = new OCLCache(this); >+ >+ protected OCLCache getCache() { >+ return oclCache; >+ } >+ >+ /** >+ * Creates the OCL environment in which to parse setting delegates for the >+ * specified environment. Subclasses may override to create custom >+ * environments, but should note that the result is cached. >+ * >+ * @param ePackage >+ * an Ecore package for which to create a setting delegate >+ * environment >+ * @return the environment >+ */ >+ public OCL createOCL(final EPackage ePackage) { >+ Resource res = ePackage.eResource(); >+ EcoreEnvironmentFactory envFactory; >+ >+ if ((res != null) && (res.getResourceSet() != null)) { >+ // it's a dynamic package. Use the local package registry >+ envFactory = new EcoreEnvironmentFactory(res.getResourceSet() >+ .getPackageRegistry()); >+ >+ // and expunge when it's unloaded >+ res.eAdapters().add(new AdapterImpl() { >+ >+ @Override >+ public void notifyChanged(Notification msg) { >+ if ((msg.getFeatureID(Resource.class) == Resource.RESOURCE__IS_LOADED) >+ && !msg.getNewBooleanValue()) { >+ getCache().expunge(ePackage); >+ } >+ } >+ }); >+ } else { >+ // the shared instance uses the static package registry >+ envFactory = EcoreEnvironmentFactory.INSTANCE; >+ } >+ >+ return OCL.newInstance(envFactory); >+ } >+ >+} >Index: src/org/eclipse/ocl/ecore/internal/l10n/IMessages.java >=================================================================== >RCS file: src/org/eclipse/ocl/ecore/internal/l10n/IMessages.java >diff -N src/org/eclipse/ocl/ecore/internal/l10n/IMessages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ocl/ecore/internal/l10n/IMessages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,65 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2006, 2008 IBM Corporation, Zeligsoft Inc., and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ * Zeligsoft - Bug 216701 >+ * >+ * </copyright> >+ * >+ * $Id: IMessages.java,v 1.2 2007/02/14 14:46:07 cdamus Exp $ >+ */ >+package org.eclipse.ocl.ecore.internal.l10n; >+ >+import java.text.MessageFormat; >+ >+/** >+ * Abstraction of the OSGi runtime's NLS class, to abstract the dependency on >+ * Eclipse platform. >+ * >+ * @author Christian W. Damus (cdamus) >+ */ >+interface IMessages { >+ String bind(String message, Object arg); >+ String bind(String message, Object arg1, Object arg2); >+ String bind(String message, Object[] args); >+ >+ class Default implements IMessages { >+ public String bind(String message, Object arg) { >+ return MessageFormat.format(message, new Object[] {arg}); >+ } >+ >+ public String bind(String message, Object arg1, Object arg2) { >+ return MessageFormat.format(message, new Object[] {arg1, arg2}); >+ } >+ >+ public String bind(String message, Object[] args) { >+ return MessageFormat.format(message, args); >+ } >+ } >+ >+ class NLS implements IMessages { >+ public NLS() { >+ org.eclipse.osgi.util.NLS.initializeMessages( >+ OCLEcoreMessages.BUNDLE_NAME, OCLEcoreMessages.class); >+ } >+ >+ public String bind(String message, Object arg) { >+ return org.eclipse.osgi.util.NLS.bind(message, arg); >+ } >+ >+ public String bind(String message, Object arg1, Object arg2) { >+ return org.eclipse.osgi.util.NLS.bind(message, arg1, arg2); >+ } >+ >+ public String bind(String message, Object[] args) { >+ return org.eclipse.osgi.util.NLS.bind(message, args); >+ } >+ } >+} >Index: src/org/eclipse/ocl/ecore/dynamic/OCLSettingDelegate.java >=================================================================== >RCS file: src/org/eclipse/ocl/ecore/dynamic/OCLSettingDelegate.java >diff -N src/org/eclipse/ocl/ecore/dynamic/OCLSettingDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ocl/ecore/dynamic/OCLSettingDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,95 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Zeligsoft Inc. and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Zeligsoft - Initial API and implementation >+ * >+ * </copyright> >+ * >+ * $Id$ >+ */ >+ >+package org.eclipse.ocl.ecore.dynamic; >+ >+import org.eclipse.emf.ecore.EClass; >+import org.eclipse.emf.ecore.EClassifier; >+import org.eclipse.emf.ecore.EPackage; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.ecore.EcorePackage; >+import org.eclipse.emf.ecore.InternalEObject; >+import org.eclipse.emf.ecore.util.BasicSettingDelegate; >+import org.eclipse.emf.ecore.util.EcoreUtil; >+import org.eclipse.ocl.ParserException; >+import org.eclipse.ocl.ecore.OCL; >+import org.eclipse.ocl.expressions.OCLExpression; >+ >+/** >+ * An implementation of a setting delegate that computes OCL derived features. >+ * >+ * @author Christian W. Damus (cdamus) >+ * @since 1.3 >+ */ >+public class OCLSettingDelegate >+ extends BasicSettingDelegate.Stateless { >+ >+ private OCL ocl; >+ >+ private OCLExpression<EClassifier> derivation; >+ >+ private ValueConverter converter; >+ >+ /** >+ * Initializes me with my structural feature. >+ * >+ * @param structuralFeature >+ * the structural feature that I handle >+ * >+ * @throws ParserException >+ * if the structural feature's OCL derivation is invalid >+ */ >+ protected OCLSettingDelegate(EStructuralFeature structuralFeature, >+ OCLCache oclCache) >+ throws ParserException { >+ >+ super(structuralFeature); >+ >+ EClass context = structuralFeature.getEContainingClass(); >+ EPackage ePackage = context.getEPackage(); >+ >+ this.ocl = oclCache.getOCL(ePackage); >+ >+ OCL.Helper helper = ocl.createOCLHelper(); >+ helper.setAttributeContext(context, structuralFeature); >+ >+ String expr = EcoreUtil.getAnnotation(structuralFeature, >+ EcorePackage.eNS_URI, "OCL"); //$NON-NLS-1$ >+ >+ this.derivation = helper.createDerivedValueExpression(expr) >+ .getSpecification().getBodyExpression(); >+ >+ this.converter = structuralFeature.isMany() >+ ? ValueConverter.LIST >+ : ValueConverter.VERBATIM; >+ } >+ >+ @Override >+ protected Object get(InternalEObject owner, boolean resolve, >+ boolean coreType) { >+ >+ OCL.Query query = ocl.createQuery(derivation); >+ >+ return converter.convert(ocl, query.evaluate(owner)); >+ } >+ >+ @Override >+ protected boolean isSet(InternalEObject owner) { >+ return false; // derived features are, implicitly, never set >+ } >+ >+} >Index: src/org/eclipse/ocl/ecore/internal/l10n/OCLEcoreMessages.java >=================================================================== >RCS file: src/org/eclipse/ocl/ecore/internal/l10n/OCLEcoreMessages.java >diff -N src/org/eclipse/ocl/ecore/internal/l10n/OCLEcoreMessages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ocl/ecore/internal/l10n/OCLEcoreMessages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,103 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2005, 2008 IBM Corporation, Zeligsoft Inc., and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ * Zeligsoft - Bug 216701 >+ * >+ * </copyright> >+ * >+ * $Id: OCLMessages.java,v 1.6 2007/12/12 22:08:04 cdamus Exp $ >+ */ >+ >+package org.eclipse.ocl.ecore.internal.l10n; >+ >+import java.lang.reflect.Field; >+import java.lang.reflect.Modifier; >+import java.util.MissingResourceException; >+import java.util.ResourceBundle; >+ >+/** >+ * An accessor class for externalized strings. >+ * >+ * @author Christian Vogt (cvogt) >+ * @since 1.3 >+ */ >+public class OCLEcoreMessages { >+ >+ static final String BUNDLE_NAME = "org.eclipse.ocl.ecore.internal.l10n.OCLMessages"; //$NON-NLS-1$ >+ >+ public static String bad_attribute_derivation; >+ >+ public static String bad_operation_body; >+ >+ private static IMessages messagesImpl; >+ >+ public static String bind(String message, Object arg) { >+ return messagesImpl.bind(message, arg); >+ } >+ >+ public static String bind(String message, Object arg1, Object arg2) { >+ return messagesImpl.bind(message, arg1, arg2); >+ } >+ >+ public static String bind(String message, Object[] args) { >+ return messagesImpl.bind(message, args); >+ } >+ >+ static { >+ try { >+ @SuppressWarnings("unchecked") >+ Class<IMessages> nlsClass = (Class<IMessages>) Class.forName("org.eclipse.ocl.ecore.internal.l10n.IMessages$NLS"); //$NON-NLS-1$ >+ messagesImpl = nlsClass.newInstance(); >+ } catch (NoClassDefFoundError e) { >+ // expected in non-Eclipse environment >+ } catch (Exception e) { >+ // expected in non-Eclipse environment >+ } >+ >+ if (messagesImpl == null) { >+ // could not find the NLS class. Try initializing the messages, >+ // ourselves >+ initializeMessages(); >+ messagesImpl = new IMessages.Default(); >+ } >+ } >+ >+ private static void initializeMessages() { >+ ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_NAME); >+ int publicStatic = Modifier.PUBLIC | Modifier.STATIC; >+ >+ Class<OCLEcoreMessages> clazz = OCLEcoreMessages.class; >+ >+ if (bundle != null) { >+ Field[] fields = clazz.getDeclaredFields(); >+ >+ for (int i = 0; i < fields.length; i++) { >+ Field next = fields[i]; >+ >+ if (((next.getModifiers() & publicStatic) == publicStatic) >+ && (next.getType() == String.class)) { >+ String name = next.getName(); >+ >+ try { >+ try { >+ next.set(null, bundle.getString(name)); >+ } catch (MissingResourceException e) { >+ // just use its own name, then >+ next.set(null, "Missing message for key: " + name); //$NON-NLS-1$ >+ } >+ } catch (Exception e) { >+ // oh, well. Can't set a value for this one >+ } >+ } >+ } >+ } >+ } >+} >Index: src/org/eclipse/ocl/ecore/dynamic/OCLSettingDelegateFactory.java >=================================================================== >RCS file: src/org/eclipse/ocl/ecore/dynamic/OCLSettingDelegateFactory.java >diff -N src/org/eclipse/ocl/ecore/dynamic/OCLSettingDelegateFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ocl/ecore/dynamic/OCLSettingDelegateFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,76 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Zeligsoft Inc. and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Zeligsoft - Initial API and implementation >+ * >+ * </copyright> >+ * >+ * $Id$ >+ */ >+ >+package org.eclipse.ocl.ecore.dynamic; >+ >+import org.eclipse.emf.common.util.ECollections; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.ecore.InternalEObject; >+import org.eclipse.emf.ecore.util.BasicSettingDelegate; >+import org.eclipse.ocl.ParserException; >+import org.eclipse.ocl.ecore.internal.OCLEcorePlugin; >+import org.eclipse.ocl.ecore.internal.l10n.OCLEcoreMessages; >+ >+/** >+ * Factory for OCL derived-attribute setting delegates. >+ * >+ * @author Christian W. Damus (cdamus) >+ * >+ * @since 1.3 >+ */ >+public class OCLSettingDelegateFactory >+extends AbstractOCLDelegateFactory >+ implements EStructuralFeature.Internal.SettingDelegate.Factory { >+ >+ public EStructuralFeature.Internal.SettingDelegate createSettingDelegate( >+ EStructuralFeature structuralFeature) { >+ >+ EStructuralFeature.Internal.SettingDelegate result; >+ >+ try { >+ result = new OCLSettingDelegate(structuralFeature, getCache()); >+ } catch (ParserException e) { >+ // I will not be able to return any values >+ OCLEcorePlugin.error(1, OCLEcoreMessages.bind( >+ OCLEcoreMessages.bad_attribute_derivation, new Object[]{ >+ structuralFeature.getEContainingClass().getName(), >+ structuralFeature.getName(), e.getLocalizedMessage()})); >+ >+ // so, return a setting delegate that has no value, ever >+ return new BasicSettingDelegate.Stateless(structuralFeature) { >+ >+ @Override >+ protected Object get(InternalEObject owner, boolean resolve, >+ boolean coreType) { >+ >+ return eStructuralFeature.isMany() >+ ? ECollections.EMPTY_ELIST >+ : null; >+ } >+ >+ @Override >+ protected boolean isSet(InternalEObject owner) { >+ return false; >+ } >+ >+ }; >+ } >+ >+ return result; >+ } >+ >+} >#P org.eclipse.emf.ecore >Index: src/org/eclipse/emf/ecore/EObject.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/EObject.java,v >retrieving revision 1.11 >diff -u -r1.11 EObject.java >--- src/org/eclipse/emf/ecore/EObject.java 14 Jun 2007 18:32:46 -0000 1.11 >+++ src/org/eclipse/emf/ecore/EObject.java 16 Nov 2008 21:20:48 -0000 >@@ -1,7 +1,7 @@ > /** > * <copyright> > * >- * Copyright (c) 2002-2006 IBM Corporation and others. >+ * Copyright (c) 2002-2008 IBM Corporation, Zeligsoft Inc., and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -9,6 +9,7 @@ > * > * Contributors: > * IBM - Initial API and implementation >+ * Zeligsoft - 255469 Implement basic eCall support > * > * </copyright> > * >@@ -17,6 +18,8 @@ > package org.eclipse.emf.ecore; > > >+import java.lang.reflect.InvocationTargetException; >+ > import org.eclipse.emf.common.notify.Notifier; > import org.eclipse.emf.common.util.EList; > import org.eclipse.emf.common.util.TreeIterator; >@@ -427,4 +430,28 @@ > */ > void eUnset(EStructuralFeature feature); > >+ /** >+ * <!-- begin-user-doc --> >+ * <p> >+ * Calls the specified operation of the object. If the operation has >+ * parameters, then corresponding arguments must be supplied. There are no >+ * optional parameters in Ecore operations. >+ * </p><p> >+ * If the operation is a void operation, then on successful execution, the >+ * result of this call is <code>null</code>. Otherwise, if the operation is >+ * {@linkplain ETypedElement#isMany() nulti-valued}, then an {@link EList} >+ * is returned (possibly empty). If single-valued, then an instance of the >+ * operation's {@linkplain ETypedElement#getEType() type} is returned, or >+ * possibly <code>null</code>. >+ * </p><p> >+ * If the called operation fails with an >+ * {@linkplain EOperation#getEExceptions() exception}, then it is re-thrown, >+ * wrapped in an {@link InvocationTargetException}. >+ * </p> >+ * <!-- end-user-doc --> >+ * @model exceptions="org.eclipse.emf.ecore.EInvocationTargetException" argumentsMany="false" >+ * @generated >+ */ >+ Object eCall(EOperation operation, EList<?> arguments) throws InvocationTargetException; >+ > } >Index: src/org/eclipse/emf/ecore/EcorePackage.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/EcorePackage.java,v >retrieving revision 1.16 >diff -u -r1.16 EcorePackage.java >--- src/org/eclipse/emf/ecore/EcorePackage.java 27 Apr 2008 20:26:15 -0000 1.16 >+++ src/org/eclipse/emf/ecore/EcorePackage.java 16 Nov 2008 21:20:59 -0000 >@@ -1,7 +1,7 @@ > /** > * <copyright> > * >- * Copyright (c) 2002-2006 IBM Corporation and others. >+ * Copyright (c) 2002-2008 IBM Corporation, Zeligsoft Inc., and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -9,6 +9,7 @@ > * > * Contributors: > * IBM - Initial API and implementation >+ * Zeligsoft - 255469 Implement basic eCall support > * > * </copyright> > * >@@ -2389,6 +2390,16 @@ > > > /** >+ * The meta object id for the '<em>EInvocation Target Exception</em>' data type. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @see java.lang.reflect.InvocationTargetException >+ * @see org.eclipse.emf.ecore.impl.EcorePackageImpl#getEInvocationTargetException() >+ * @generated >+ */ >+ int EINVOCATION_TARGET_EXCEPTION = 52; >+ >+ /** > * The meta object id for the '<em>EFeature Map Entry</em>' data type. > * <!-- begin-user-doc --> > * <!-- end-user-doc --> >@@ -3877,6 +3888,17 @@ > EDataType getETreeIterator(); > > /** >+ * Returns the meta object for data type '{@link java.lang.reflect.InvocationTargetException <em>EInvocation Target Exception</em>}'. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @return the meta object for data type '<em>EInvocation Target Exception</em>'. >+ * @see java.lang.reflect.InvocationTargetException >+ * @model instanceClass="java.lang.reflect.InvocationTargetException" >+ * @generated >+ */ >+ EDataType getEInvocationTargetException(); >+ >+ /** > * Returns the meta object for data type '{@link org.eclipse.emf.ecore.util.FeatureMap.Entry <em>EFeature Map Entry</em>}'. > * <!-- begin-user-doc --> > * <!-- end-user-doc --> >@@ -5103,6 +5125,16 @@ > */ > EDataType ETREE_ITERATOR = eINSTANCE.getETreeIterator(); > >+ /** >+ * The meta object literal for the '<em>EInvocation Target Exception</em>' data type. >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @see java.lang.reflect.InvocationTargetException >+ * @see org.eclipse.emf.ecore.impl.EcorePackageImpl#getEInvocationTargetException() >+ * @generated >+ */ >+ EDataType EINVOCATION_TARGET_EXCEPTION = eINSTANCE.getEInvocationTargetException(); >+ > } > > // Internal bootstrap uses Literals constants, so we must force initialization this inner interface first. >Index: src/org/eclipse/emf/ecore/EOperation.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/EOperation.java,v >retrieving revision 1.8 >diff -u -r1.8 EOperation.java >--- src/org/eclipse/emf/ecore/EOperation.java 12 Jun 2007 15:07:48 -0000 1.8 >+++ src/org/eclipse/emf/ecore/EOperation.java 16 Nov 2008 21:20:48 -0000 >@@ -1,7 +1,7 @@ > /** > * <copyright> > * >- * Copyright (c) 2002-2006 IBM Corporation and others. >+ * Copyright (c) 2002-2008 IBM Corporation, Zeligsoft Inc., and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -9,6 +9,7 @@ > * > * Contributors: > * IBM - Initial API and implementation >+ * Zeligsoft - 255469 Implement basic eCall support > * > * </copyright> > * >@@ -17,6 +18,9 @@ > package org.eclipse.emf.ecore; > > >+import java.lang.reflect.InvocationTargetException; >+import java.util.HashMap; >+ > import org.eclipse.emf.common.util.EList; > > >@@ -126,4 +130,95 @@ > */ > EList<ETypeParameter> getETypeParameters(); > >+ /** >+ * Internal API implemented by all operations. >+ * >+ * @since 2.5 >+ */ >+ interface Internal extends EOperation, InternalEObject >+ { >+ /** >+ * A pluggable, dynamic implementation of operation behaviour. >+ */ >+ interface CallDelegate >+ { >+ /** >+ * A factory for creating call delegates. >+ */ >+ interface Factory >+ { >+ /** >+ * Creates the call delegate for the specified <tt>operation</tt>. >+ * >+ * @param operation the operation >+ * @return its call delegate >+ */ >+ CallDelegate createCallDelegate(EOperation operation); >+ >+ /** >+ * A registry of call-delegate factories. >+ */ >+ interface Registry >+ { >+ Registry INSTANCE = new Impl(); >+ >+ Factory getFactory(String key); >+ >+ void registerFactory(String key, Factory factory); >+ >+ void deregisterFactory(String key); >+ >+ class Impl extends HashMap<String, Factory> implements Registry >+ { >+ private static final long serialVersionUID = 1L; >+ >+ public Factory getFactory(String key) >+ { >+ return get(key); >+ } >+ >+ public void registerFactory(String key, Factory factory) >+ { >+ put(key, factory); >+ } >+ >+ public void deregisterFactory(String key) >+ { >+ remove(key); >+ } >+ } >+ } >+ } >+ >+ /** >+ * Invokes the operation behaviour for the specified <tt>target</tt> >+ * object. >+ * >+ * @param target the object on which to call the operation >+ * @param arguments the arguments for the operation parameters (an >+ * empty list if the operation has no parameters) >+ * @return the operation's return result, or <code>null</code> if it is >+ * a void operation >+ * @throws InvocationTargetException in case of failure to execute the >+ * operation behaviour, usually because of an exception >+ */ >+ Object dynamicCall(InternalEObject target, EList<?> arguments) throws InvocationTargetException; >+ } >+ >+ /** >+ * Obtains the delegate for this operation. >+ * A default delegate is always available, so this should not return >+ * <code>null</code>. >+ * >+ * @return the operation delegate >+ */ >+ CallDelegate getCallDelegate(); >+ >+ /** >+ * Assigns a delegate to this operation. >+ * >+ * @param callDelegate the new operation delegate >+ */ >+ void setCallDelegate(CallDelegate callDelegate); >+ } > } //EOperation >Index: src/org/eclipse/emf/ecore/EStructuralFeature.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/EStructuralFeature.java,v >retrieving revision 1.14 >diff -u -r1.14 EStructuralFeature.java >--- src/org/eclipse/emf/ecore/EStructuralFeature.java 14 Jun 2007 18:32:46 -0000 1.14 >+++ src/org/eclipse/emf/ecore/EStructuralFeature.java 16 Nov 2008 21:20:51 -0000 >@@ -1,7 +1,7 @@ > /** > * <copyright> > * >- * Copyright (c) 2002-2006 IBM Corporation and others. >+ * Copyright (c) 2002-2008 IBM Corporation, Zeligsoft Inc. and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -9,6 +9,7 @@ > * > * Contributors: > * IBM - Initial API and implementation >+ * Zeligsoft - 216701 Add support for mutating the delegate-factory registry > * > * </copyright> > * >@@ -17,7 +18,10 @@ > package org.eclipse.emf.ecore; > > >+import java.util.HashMap; >+ > import org.eclipse.emf.common.notify.NotificationChain; >+import org.eclipse.emf.ecore.util.PathSettingDelegate; > import org.eclipse.emf.ecore.util.FeatureMap; > > >@@ -365,6 +369,66 @@ > interface SettingDelegate > { > /** >+ * A factory for creating setting delegates. >+ * @since 2.5 >+ */ >+ interface Factory >+ { >+ /** >+ * Creates a setting delegate for the given feature. >+ * @param eStructuralFeature the feature for which a setting delegate is to be created. >+ * @return a new a setting delegate for the given feature. >+ */ >+ SettingDelegate createSettingDelegate(EStructuralFeature eStructuralFeature); >+ >+ /** >+ * A registry of factories for creating setting delegates. >+ */ >+ interface Registry >+ { >+ Registry INSTANCE = new Impl(); >+ >+ Factory getFactory(String key); >+ >+ void registerFactory(String key, Factory factory); >+ >+ void deregisterFactory(String key); >+ >+ class Impl extends HashMap<String, Factory> implements Registry >+ { >+ private static final long serialVersionUID = 1L; >+ >+ { >+ put >+ ("org.eclipse.emf.ecore.Path", >+ new Factory() >+ { >+ public SettingDelegate createSettingDelegate(EStructuralFeature eStructuralFeature) >+ { >+ return new PathSettingDelegate(eStructuralFeature); >+ } >+ }); >+ } >+ >+ public Factory getFactory(String key) >+ { >+ return get(key); >+ } >+ >+ public void registerFactory(String key, Factory factory) >+ { >+ put(key, factory); >+ } >+ >+ public void deregisterFactory(String key) >+ { >+ remove(key); >+ } >+ } >+ } >+ } >+ >+ /** > * Returns a setting that can be used to access the owner's feature. > * @param owner the owner of the feature. > * @param settings the owner's array of cached values. >Index: model/Ecore.ecore >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/model/Ecore.ecore,v >retrieving revision 1.15 >diff -u -r1.15 Ecore.ecore >--- model/Ecore.ecore 2 Aug 2008 15:22:20 -0000 1.15 >+++ model/Ecore.ecore 16 Nov 2008 21:20:43 -0000 >@@ -221,6 +221,14 @@ > <eOperations name="eUnset"> > <eParameters name="feature" eType="#//EStructuralFeature"/> > </eOperations> >+ <eOperations name="eCall" eType="#//EJavaObject" eExceptions="#//EInvocationTargetException"> >+ <eParameters name="operation" eType="#//EOperation"/> >+ <eParameters name="arguments"> >+ <eGenericType eClassifier="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EEList"> >+ <eTypeArguments/> >+ </eGenericType> >+ </eParameters> >+ </eOperations> > </eClassifiers> > <eClassifiers xsi:type="ecore:EClass" name="EOperation" eSuperTypes="#//ETypedElement"> > <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore"> >@@ -495,4 +503,5 @@ > <eStructuralFeatures xsi:type="ecore:EReference" name="eBounds" upperBound="-1" > eType="#//EGenericType" containment="true" resolveProxies="false"/> > </eClassifiers> >+ <eClassifiers xsi:type="ecore:EDataType" name="EInvocationTargetException" instanceClassName="java.lang.reflect.InvocationTargetException"/> > </ecore:EPackage> >Index: model/EcoreAnnotations.ecorediag >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/model/EcoreAnnotations.ecorediag,v >retrieving revision 1.1 >diff -u -r1.1 EcoreAnnotations.ecorediag >--- model/EcoreAnnotations.ecorediag 2 Aug 2008 15:22:20 -0000 1.1 >+++ model/EcoreAnnotations.ecorediag 16 Nov 2008 21:20:47 -0000 >@@ -14,7 +14,7 @@ > </children> > <styles xmi:type="notation:ShapeStyle" xmi:id="_sFlvLT-OEd2DT6rVsxRmdQ" fontName="Microsoft Sans Serif" fontHeight="10" fillColor="13761016" lineColor="0"/> > <element xmi:type="ecore:EClass" href="Ecore.ecore#//EAnnotation"/> >- <layoutConstraint xmi:type="notation:Bounds" xmi:id="_sFlvLj-OEd2DT6rVsxRmdQ" x="114" y="312"/> >+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_sFlvLj-OEd2DT6rVsxRmdQ" x="108" y="333"/> > </children> > <children xmi:type="notation:Node" xmi:id="_sFlvLz-OEd2DT6rVsxRmdQ" type="1001"> > <children xmi:type="notation:Node" xmi:id="_sFlvMD-OEd2DT6rVsxRmdQ" type="4001"/> >@@ -30,7 +30,7 @@ > </children> > <styles xmi:type="notation:ShapeStyle" xmi:id="_sFlvPT-OEd2DT6rVsxRmdQ" fontName="Microsoft Sans Serif" fontHeight="10" fillColor="13761016" lineColor="0"/> > <element xmi:type="ecore:EClass" href="Ecore.ecore#//EStringToStringMapEntry"/> >- <layoutConstraint xmi:type="notation:Bounds" xmi:id="_sFlvPj-OEd2DT6rVsxRmdQ" x="96" y="396"/> >+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_sFlvPj-OEd2DT6rVsxRmdQ" x="90" y="423"/> > </children> > <children xmi:type="notation:Node" xmi:id="_sFlvPz-OEd2DT6rVsxRmdQ" type="1001"> > <children xmi:type="notation:Node" xmi:id="_sFlvQD-OEd2DT6rVsxRmdQ" type="4001"/> >@@ -40,6 +40,66 @@ > <styles xmi:type="notation:FilteringStyle" xmi:id="_sFlvRD-OEd2DT6rVsxRmdQ"/> > </children> > <children xmi:type="notation:Node" xmi:id="_sFlvRT-OEd2DT6rVsxRmdQ" type="5002"> >+ <children xmi:type="notation:Node" xmi:id="_qywyMLP2Ed2JrdFLh2Y_ww" type="2002"> >+ <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eClass"/> >+ <layoutConstraint xmi:type="notation:Location" xmi:id="_qywyMbP2Ed2JrdFLh2Y_ww"/> >+ </children> >+ <children xmi:type="notation:Node" xmi:id="_qyxZQLP2Ed2JrdFLh2Y_ww" type="2002"> >+ <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eIsProxy"/> >+ <layoutConstraint xmi:type="notation:Location" xmi:id="_qyxZQbP2Ed2JrdFLh2Y_ww"/> >+ </children> >+ <children xmi:type="notation:Node" xmi:id="_qyxZQrP2Ed2JrdFLh2Y_ww" type="2002"> >+ <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eResource"/> >+ <layoutConstraint xmi:type="notation:Location" xmi:id="_qyxZQ7P2Ed2JrdFLh2Y_ww"/> >+ </children> >+ <children xmi:type="notation:Node" xmi:id="_qyxZRLP2Ed2JrdFLh2Y_ww" type="2002"> >+ <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eContainer"/> >+ <layoutConstraint xmi:type="notation:Location" xmi:id="_qyxZRbP2Ed2JrdFLh2Y_ww"/> >+ </children> >+ <children xmi:type="notation:Node" xmi:id="_qyxZRrP2Ed2JrdFLh2Y_ww" type="2002"> >+ <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eContainingFeature"/> >+ <layoutConstraint xmi:type="notation:Location" xmi:id="_qyxZR7P2Ed2JrdFLh2Y_ww"/> >+ </children> >+ <children xmi:type="notation:Node" xmi:id="_qyyAULP2Ed2JrdFLh2Y_ww" type="2002"> >+ <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eContainmentFeature"/> >+ <layoutConstraint xmi:type="notation:Location" xmi:id="_qyyAUbP2Ed2JrdFLh2Y_ww"/> >+ </children> >+ <children xmi:type="notation:Node" xmi:id="_qyyAUrP2Ed2JrdFLh2Y_ww" type="2002"> >+ <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eContents"/> >+ <layoutConstraint xmi:type="notation:Location" xmi:id="_qyyAU7P2Ed2JrdFLh2Y_ww"/> >+ </children> >+ <children xmi:type="notation:Node" xmi:id="_qyyAVLP2Ed2JrdFLh2Y_ww" type="2002"> >+ <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eAllContents"/> >+ <layoutConstraint xmi:type="notation:Location" xmi:id="_qyyAVbP2Ed2JrdFLh2Y_ww"/> >+ </children> >+ <children xmi:type="notation:Node" xmi:id="_qyyAVrP2Ed2JrdFLh2Y_ww" type="2002"> >+ <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eCrossReferences"/> >+ <layoutConstraint xmi:type="notation:Location" xmi:id="_qyyAV7P2Ed2JrdFLh2Y_ww"/> >+ </children> >+ <children xmi:type="notation:Node" xmi:id="_qyynYLP2Ed2JrdFLh2Y_ww" type="2002"> >+ <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eGet"/> >+ <layoutConstraint xmi:type="notation:Location" xmi:id="_qyynYbP2Ed2JrdFLh2Y_ww"/> >+ </children> >+ <children xmi:type="notation:Node" xmi:id="_qyynYrP2Ed2JrdFLh2Y_ww" type="2002"> >+ <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eGet.1"/> >+ <layoutConstraint xmi:type="notation:Location" xmi:id="_qyynY7P2Ed2JrdFLh2Y_ww"/> >+ </children> >+ <children xmi:type="notation:Node" xmi:id="_qyzOcLP2Ed2JrdFLh2Y_ww" type="2002"> >+ <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eSet"/> >+ <layoutConstraint xmi:type="notation:Location" xmi:id="_qyzOcbP2Ed2JrdFLh2Y_ww"/> >+ </children> >+ <children xmi:type="notation:Node" xmi:id="_qyzOcrP2Ed2JrdFLh2Y_ww" type="2002"> >+ <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eIsSet"/> >+ <layoutConstraint xmi:type="notation:Location" xmi:id="_qyzOc7P2Ed2JrdFLh2Y_ww"/> >+ </children> >+ <children xmi:type="notation:Node" xmi:id="_qyzOdLP2Ed2JrdFLh2Y_ww" type="2002"> >+ <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eUnset"/> >+ <layoutConstraint xmi:type="notation:Location" xmi:id="_qyzOdbP2Ed2JrdFLh2Y_ww"/> >+ </children> >+ <children xmi:type="notation:Node" xmi:id="_xxmzoLP2Ed2JrdFLh2Y_ww" type="2002"> >+ <element xmi:type="ecore:EOperation" href="Ecore.ecore#//EObject/eCall"/> >+ <layoutConstraint xmi:type="notation:Location" xmi:id="_xxmzobP2Ed2JrdFLh2Y_ww"/> >+ </children> > <styles xmi:type="notation:DrawerStyle" xmi:id="_sFlvRj-OEd2DT6rVsxRmdQ"/> > <styles xmi:type="notation:SortingStyle" xmi:id="_sFlvRz-OEd2DT6rVsxRmdQ"/> > <styles xmi:type="notation:FilteringStyle" xmi:id="_sFlvSD-OEd2DT6rVsxRmdQ"/> >@@ -72,7 +132,7 @@ > <styles xmi:type="notation:ConnectorStyle" xmi:id="_sFlvdT-OEd2DT6rVsxRmdQ" routing="Rectilinear" lineColor="0"/> > <styles xmi:type="notation:FontStyle" xmi:id="_sFlvdj-OEd2DT6rVsxRmdQ" fontName="Microsoft Sans Serif" fontHeight="10"/> > <element xmi:type="ecore:EReference" href="Ecore.ecore#//EAnnotation/contents"/> >- <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_sFlvdz-OEd2DT6rVsxRmdQ" points="[-43, -23, -43, 173]$[-43, -68, -43, 128]"/> >+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_sFlvdz-OEd2DT6rVsxRmdQ" points="[-33, -23, -76, 186]$[-33, -73, -76, 136]"/> > </edges> > <edges xmi:type="notation:Edge" xmi:id="_sFlveD-OEd2DT6rVsxRmdQ" type="3002" source="_sFlvIT-OEd2DT6rVsxRmdQ" target="_sFlvPz-OEd2DT6rVsxRmdQ"> > <children xmi:type="notation:Node" xmi:id="_sFlveT-OEd2DT6rVsxRmdQ" type="4011"> >@@ -84,6 +144,6 @@ > <styles xmi:type="notation:ConnectorStyle" xmi:id="_sFlvfT-OEd2DT6rVsxRmdQ" routing="Rectilinear" lineColor="0"/> > <styles xmi:type="notation:FontStyle" xmi:id="_sFlvfj-OEd2DT6rVsxRmdQ" fontName="Microsoft Sans Serif" fontHeight="10"/> > <element xmi:type="ecore:EReference" href="Ecore.ecore#//EAnnotation/references"/> >- <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_sFlvfz-OEd2DT6rVsxRmdQ" points="[41, -23, 41, 173]$[41, -68, 41, 128]"/> >+ <bendpoints xmi:type="notation:RelativeBendpoints" xmi:id="_sFlvfz-OEd2DT6rVsxRmdQ" points="[39, -23, -4, 186]$[39, -73, -4, 136]"/> > </edges> > </notation:Diagram> >Index: model/EcoreDataTypes.ecorediag >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/model/EcoreDataTypes.ecorediag,v >retrieving revision 1.1 >diff -u -r1.1 EcoreDataTypes.ecorediag >--- model/EcoreDataTypes.ecorediag 2 Aug 2008 15:22:20 -0000 1.1 >+++ model/EcoreDataTypes.ecorediag 16 Nov 2008 21:20:47 -0000 >@@ -224,6 +224,13 @@ > <element xmi:type="ecore:EDataType" href="Ecore.ecore#//ETreeIterator"/> > <layoutConstraint xmi:type="notation:Bounds" xmi:id="_n9W90D-IEd2DT6rVsxRmdQ" x="408" y="228"/> > </children> >+ <children xmi:type="notation:Node" xmi:id="_z-RYILP5Ed2JrdFLh2Y_ww" type="1004"> >+ <children xmi:type="notation:Node" xmi:id="_z-VpkLP5Ed2JrdFLh2Y_ww" type="4008"/> >+ <children xmi:type="notation:Node" xmi:id="_z-VpkbP5Ed2JrdFLh2Y_ww" type="4009"/> >+ <styles xmi:type="notation:ShapeStyle" xmi:id="_z-RYIbP5Ed2JrdFLh2Y_ww" fontName="Lucida Grande" fontHeight="10" fillColor="13420443" lineColor="8421504"/> >+ <element xmi:type="ecore:EDataType" href="Ecore.ecore#//EInvocationTargetException"/> >+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_z-RYIrP5Ed2JrdFLh2Y_ww" x="-216" y="585"/> >+ </children> > <styles xmi:type="notation:DiagramStyle" xmi:id="_n9W90T-IEd2DT6rVsxRmdQ"/> > <element xmi:type="ecore:EPackage" href="Ecore.ecore#/"/> > </notation:Diagram> >Index: src/org/eclipse/emf/ecore/impl/EcorePackageImpl.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EcorePackageImpl.java,v >retrieving revision 1.26 >diff -u -r1.26 EcorePackageImpl.java >--- src/org/eclipse/emf/ecore/impl/EcorePackageImpl.java 2 Aug 2008 15:22:20 -0000 1.26 >+++ src/org/eclipse/emf/ecore/impl/EcorePackageImpl.java 16 Nov 2008 21:21:30 -0000 >@@ -1,7 +1,7 @@ > /** > * <copyright> > * >- * Copyright (c) 2002-2007 IBM Corporation and others. >+ * Copyright (c) 2002-2008 IBM Corporation, Zeligsoft Inc., and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -9,6 +9,7 @@ > * > * Contributors: > * IBM - Initial API and implementation >+ * Zeligsoft - 255469 Implement basic eCall support > * > * </copyright> > * >@@ -17,6 +18,7 @@ > package org.eclipse.emf.ecore.impl; > > >+import java.lang.reflect.InvocationTargetException; > import java.math.BigDecimal; > import java.math.BigInteger; > import java.util.ArrayList; >@@ -410,6 +412,13 @@ > * <!-- end-user-doc --> > * @generated > */ >+ private EDataType eInvocationTargetExceptionEDataType = null; >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ > private EDataType eFeatureMapEntryEDataType = null; > > /** >@@ -1835,6 +1844,16 @@ > * <!-- end-user-doc --> > * @generated > */ >+ public EDataType getEInvocationTargetException() >+ { >+ return eInvocationTargetExceptionEDataType; >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ > public EDataType getEFeatureMapEntry() > { > return eFeatureMapEntryEDataType; >@@ -2074,6 +2093,7 @@ > eShortObjectEDataType = createEDataType(ESHORT_OBJECT); > eStringEDataType = createEDataType(ESTRING); > eTreeIteratorEDataType = createEDataType(ETREE_ITERATOR); >+ eInvocationTargetExceptionEDataType = createEDataType(EINVOCATION_TARGET_EXCEPTION); > } > > /** >@@ -2282,6 +2302,14 @@ > op = addEOperation(eObjectEClass, null, "eUnset", 0, 1, IS_UNIQUE, IS_ORDERED); > addEParameter(op, this.getEStructuralFeature(), "feature", 0, 1, IS_UNIQUE, IS_ORDERED); > >+ op = addEOperation(eObjectEClass, this.getEJavaObject(), "eCall", 0, 1, IS_UNIQUE, IS_ORDERED); >+ addEParameter(op, this.getEOperation(), "operation", 0, 1, IS_UNIQUE, IS_ORDERED); >+ g1 = createEGenericType(ecorePackage.getEEList()); >+ g2 = createEGenericType(); >+ g1.getETypeArguments().add(g2); >+ addEParameter(op, g1, "arguments", 0, 1, IS_UNIQUE, IS_ORDERED); >+ addEException(op, this.getEInvocationTargetException()); >+ > initEClass(eOperationEClass, EOperation.class, "EOperation", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); > 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); > 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); >@@ -2387,6 +2415,7 @@ > initEDataType(eShortObjectEDataType, Short.class, "EShortObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); > initEDataType(eStringEDataType, String.class, "EString", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); > initEDataType(eTreeIteratorEDataType, TreeIterator.class, "ETreeIterator", !IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); >+ initEDataType(eInvocationTargetExceptionEDataType, InvocationTargetException.class, "EInvocationTargetException", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); > > // Create resource > createResource(eNS_URI); >Index: src/org/eclipse/emf/ecore/impl/EOperationImpl.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EOperationImpl.java,v >retrieving revision 1.20 >diff -u -r1.20 EOperationImpl.java >--- src/org/eclipse/emf/ecore/impl/EOperationImpl.java 14 Dec 2007 23:04:55 -0000 1.20 >+++ src/org/eclipse/emf/ecore/impl/EOperationImpl.java 16 Nov 2008 21:21:04 -0000 >@@ -1,7 +1,7 @@ > /** > * <copyright> > * >- * Copyright (c) 2002-2007 IBM Corporation and others. >+ * Copyright (c) 2002-2008 IBM Corporation, Zeligsoft Inc., and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -9,6 +9,7 @@ > * > * Contributors: > * IBM - Initial API and implementation >+ * Zeligsoft - 255469 Implement basic eCall support > * > * </copyright> > * >@@ -28,6 +29,7 @@ > import org.eclipse.emf.common.notify.NotificationChain; > import org.eclipse.emf.common.notify.impl.NotificationImpl; > import org.eclipse.emf.common.util.EList; >+import org.eclipse.emf.common.util.URI; > import org.eclipse.emf.ecore.EAnnotation; > import org.eclipse.emf.ecore.EClass; > import org.eclipse.emf.ecore.EClassifier; >@@ -38,9 +40,11 @@ > import org.eclipse.emf.ecore.EcoreFactory; > import org.eclipse.emf.ecore.EcorePackage; > import org.eclipse.emf.ecore.InternalEObject; >+import org.eclipse.emf.ecore.util.BasicCallDelegate; > import org.eclipse.emf.ecore.util.DelegatingEcoreEList; > import org.eclipse.emf.ecore.util.EObjectContainmentEList; > import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; >+import org.eclipse.emf.ecore.util.EcoreUtil; > // import org.eclipse.emf.ecore.util.EObjectResolvingEList; > import org.eclipse.emf.ecore.util.InternalEList; > >@@ -48,6 +52,7 @@ > /** > * <!-- begin-user-doc --> > * An implementation of the model object '<em><b>EOperation</b></em>'. >+ * @extends EOperation.Internal > * <!-- end-user-doc --> > * <p> > * The following features are implemented: >@@ -62,7 +67,7 @@ > * > * @generated > */ >-public class EOperationImpl extends ETypedElementImpl implements EOperation >+public class EOperationImpl extends ETypedElementImpl implements EOperation, EOperation.Internal > { > /** > * The cached value of the '{@link #getETypeParameters() <em>EType Parameters</em>}' containment reference list. >@@ -1007,4 +1012,36 @@ > return eDynamicIsSet(featureID); > } > >+ protected EOperation.Internal.CallDelegate callDelegate; >+ >+ public CallDelegate getCallDelegate() >+ { >+ if (callDelegate == null) >+ { >+ CallDelegate.Factory factory = null; >+ String callDelegateKey = EcoreUtil.getAnnotation(this, EcorePackage.eNS_URI, >+ "callDelegate"); >+ if (callDelegateKey != null) >+ { >+ factory = CallDelegate.Factory.Registry.INSTANCE.getFactory( >+ URI.createURI(callDelegateKey).trimFragment().trimQuery().toString()); >+ } >+ if (factory != null) >+ { >+ callDelegate = factory.createCallDelegate(this); >+ } >+ if (callDelegate == null) >+ { >+ callDelegate = new BasicCallDelegate(this); >+ } >+ } >+ >+ return callDelegate; >+ } >+ >+ public void setCallDelegate(CallDelegate callDelegate) >+ { >+ this.callDelegate = callDelegate; >+ } >+ > } >Index: src/org/eclipse/emf/ecore/impl/EcoreFactoryImpl.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EcoreFactoryImpl.java,v >retrieving revision 1.15 >diff -u -r1.15 EcoreFactoryImpl.java >--- src/org/eclipse/emf/ecore/impl/EcoreFactoryImpl.java 9 Dec 2006 18:05:20 -0000 1.15 >+++ src/org/eclipse/emf/ecore/impl/EcoreFactoryImpl.java 16 Nov 2008 21:21:26 -0000 >@@ -1,7 +1,7 @@ > /** > * <copyright> > * >- * Copyright (c) 2002-2006 IBM Corporation and others. >+ * Copyright (c) 2002-2008 IBM Corporation, Zeligsoft Inc., and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -9,6 +9,7 @@ > * > * Contributors: > * IBM - Initial API and implementation >+ * Zeligsoft - 255469 Implement basic eCall support > * > * </copyright> > * >@@ -17,6 +18,7 @@ > package org.eclipse.emf.ecore.impl; > > >+import java.lang.reflect.InvocationTargetException; > import java.math.BigDecimal; > import java.math.BigInteger; > import java.text.ParseException; >@@ -161,6 +163,8 @@ > return createEShortObjectFromString(eDataType, initialValue); > case EcorePackage.ESTRING: > return createEStringFromString(eDataType, initialValue); >+ case EcorePackage.EINVOCATION_TARGET_EXCEPTION: >+ return createEInvocationTargetExceptionFromString(eDataType, initialValue); > default: > throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); > } >@@ -222,6 +226,8 @@ > return convertEShortObjectToString(eDataType, instanceValue); > case EcorePackage.ESTRING: > return convertEStringToString(eDataType, instanceValue); >+ case EcorePackage.EINVOCATION_TARGET_EXCEPTION: >+ return convertEInvocationTargetExceptionToString(eDataType, instanceValue); > default: > throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); > } >@@ -657,6 +663,26 @@ > /** > * <!-- begin-user-doc --> > * <!-- end-user-doc --> >+ * @generated >+ */ >+ public InvocationTargetException createEInvocationTargetExceptionFromString(EDataType eDataType, String initialValue) >+ { >+ return (InvocationTargetException)super.createFromString(eDataType, initialValue); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public String convertEInvocationTargetExceptionToString(EDataType eDataType, Object instanceValue) >+ { >+ return super.convertToString(eDataType, instanceValue); >+ } >+ >+ /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> > * @generated NOT > */ > public Integer createEIntFromString(EDataType metaObject, String initialValue) >Index: src/org/eclipse/emf/ecore/impl/BasicEObjectImpl.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/BasicEObjectImpl.java,v >retrieving revision 1.35 >diff -u -r1.35 BasicEObjectImpl.java >--- src/org/eclipse/emf/ecore/impl/BasicEObjectImpl.java 23 Dec 2007 18:29:25 -0000 1.35 >+++ src/org/eclipse/emf/ecore/impl/BasicEObjectImpl.java 16 Nov 2008 21:21:02 -0000 >@@ -1,7 +1,7 @@ > /** > * <copyright> > * >- * Copyright (c) 2002-2007 IBM Corporation and others. >+ * Copyright (c) 2002-2008 IBM Corporation, Zeligsoft Inc., and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -9,6 +9,7 @@ > * > * Contributors: > * IBM - Initial API and implementation >+ * Zeligsoft - 255469 Implement basic eCall support > * > * </copyright> > * >@@ -17,6 +18,7 @@ > package org.eclipse.emf.ecore.impl; > > >+import java.lang.reflect.InvocationTargetException; > import java.util.ArrayList; > import java.util.Iterator; > import java.util.List; >@@ -35,6 +37,7 @@ > import org.eclipse.emf.ecore.EDataType; > import org.eclipse.emf.ecore.EFactory; > import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EOperation; > import org.eclipse.emf.ecore.EReference; > import org.eclipse.emf.ecore.EStructuralFeature; > import org.eclipse.emf.ecore.ETypedElement; >@@ -1972,6 +1975,12 @@ > } > } > >+ public Object eCall(EOperation operation, EList<?> arguments) throws InvocationTargetException >+ { >+ return ((EOperation.Internal) operation).getCallDelegate().dynamicCall(this, >+ arguments); >+ } >+ > @Override > public String toString() > { >Index: src/org/eclipse/emf/ecore/impl/EStructuralFeatureImpl.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EStructuralFeatureImpl.java,v >retrieving revision 1.33 >diff -u -r1.33 EStructuralFeatureImpl.java >--- src/org/eclipse/emf/ecore/impl/EStructuralFeatureImpl.java 2 Jun 2008 14:44:43 -0000 1.33 >+++ src/org/eclipse/emf/ecore/impl/EStructuralFeatureImpl.java 16 Nov 2008 21:21:24 -0000 >@@ -17,6 +17,12 @@ > package org.eclipse.emf.ecore.impl; > > >+import java.io.Externalizable; >+import java.io.IOException; >+import java.io.ObjectInput; >+import java.io.ObjectOutput; >+import java.io.ObjectStreamException; >+import java.io.Serializable; > import java.util.Collection; > import java.util.List; > import java.util.Map; >@@ -26,6 +32,7 @@ > import org.eclipse.emf.common.notify.impl.NotificationChainImpl; > import org.eclipse.emf.common.util.BasicEMap; > import org.eclipse.emf.common.util.EMap; >+import org.eclipse.emf.common.util.URI; > import org.eclipse.emf.ecore.EAnnotation; > import org.eclipse.emf.ecore.EClass; > import org.eclipse.emf.ecore.EClassifier; >@@ -33,6 +40,7 @@ > import org.eclipse.emf.ecore.EDataType; > import org.eclipse.emf.ecore.EFactory; > import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EPackage; > import org.eclipse.emf.ecore.EReference; > import org.eclipse.emf.ecore.EStructuralFeature; > import org.eclipse.emf.ecore.EcorePackage; >@@ -52,6 +60,7 @@ > import org.eclipse.emf.ecore.util.EcoreUtil; > import org.eclipse.emf.ecore.util.ExtendedMetaData; > import org.eclipse.emf.ecore.util.FeatureMap; >+import org.eclipse.emf.ecore.util.FeatureMapUtil; > import org.eclipse.emf.ecore.util.InternalEList; > import org.eclipse.emf.ecore.xml.type.XMLTypePackage; > >@@ -816,10 +825,23 @@ > Object intrinsicDefaultValue = eType.getDefaultValue(); > > EStructuralFeature featureMapFeature; >- if (isDerived() && >- (((featureMapFeature = ExtendedMetaData.INSTANCE.getMixedFeature(eClass)) != null && >- featureMapFeature != this) || >- ((featureMapFeature = ExtendedMetaData.INSTANCE.getGroup(this)) != null))) >+ EAnnotation eAnnotation; >+ String settingDelegateKey; >+ SettingDelegate.Factory settingDelegateFactory; >+ boolean derived = isDerived(); >+ if (derived && >+ (eAnnotation = getEAnnotation(EcorePackage.eNS_URI)) != null && >+ (settingDelegateKey = eAnnotation.getDetails().get("settingDelegate")) != null && >+ (settingDelegateFactory = >+ SettingDelegate.Factory.Registry.INSTANCE.getFactory >+ (URI.createURI(settingDelegateKey).trimFragment().trimQuery().toString())) != null) >+ { >+ settingDelegate = settingDelegateFactory.createSettingDelegate(this); >+ } >+ else if (derived && >+ (((featureMapFeature = ExtendedMetaData.INSTANCE.getMixedFeature(eClass)) != null && >+ featureMapFeature != this) || >+ ((featureMapFeature = ExtendedMetaData.INSTANCE.getGroup(this)) != null))) > { > settingDelegate = new InternalSettingDelegateFeatureMapDelegator(this, featureMapFeature); > } >@@ -2886,7 +2908,7 @@ > return cachedIsFeatureMap; > } > >- public static abstract class BasicFeatureMapEntry implements FeatureMap.Entry.Internal >+ public static abstract class BasicFeatureMapEntry implements FeatureMap.Entry.Internal, Serializable > { > protected final EStructuralFeature.Internal eStructuralFeature; > >@@ -2967,6 +2989,50 @@ > eStructuralFeature.getName()) + > "=" + getValue(); > } >+ >+ protected static class WriteReplacement implements Externalizable >+ { >+ FeatureMap.Entry featureMapEntry; >+ >+ public WriteReplacement() >+ { >+ super(); >+ } >+ >+ public WriteReplacement(FeatureMap.Entry featureMapEntry) >+ { >+ this.featureMapEntry = featureMapEntry; >+ } >+ >+ public void writeExternal(ObjectOutput out) throws IOException >+ { >+ EStructuralFeature eStructuralFeature = featureMapEntry.getEStructuralFeature(); >+ EClass eClass = eStructuralFeature.getEContainingClass(); >+ out.writeUTF(eClass.getEPackage().getNsURI()); >+ out.writeUTF(eClass.getName()); >+ out.writeUTF(eStructuralFeature.getName()); >+ out.writeObject(featureMapEntry.getValue()); >+ } >+ >+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException >+ { >+ EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(in.readUTF()); >+ EClass eClass = (EClass)ePackage.getEClassifier(in.readUTF()); >+ EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(in.readUTF()); >+ Object value = in.readObject(); >+ featureMapEntry = FeatureMapUtil.createRawEntry(eStructuralFeature, value); >+ } >+ >+ private Object readResolve() >+ { >+ return featureMapEntry; >+ } >+ } >+ >+ public Object writeReplace() throws ObjectStreamException >+ { >+ return new WriteReplacement(this); >+ } > } > > public final static class SimpleFeatureMapEntry extends BasicFeatureMapEntry >Index: src/org/eclipse/emf/ecore/util/EcoreValidator.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/util/EcoreValidator.java,v >retrieving revision 1.34 >diff -u -r1.34 EcoreValidator.java >--- src/org/eclipse/emf/ecore/util/EcoreValidator.java 6 Sep 2008 12:41:48 -0000 1.34 >+++ src/org/eclipse/emf/ecore/util/EcoreValidator.java 16 Nov 2008 21:21:42 -0000 >@@ -1,7 +1,7 @@ > /** > * <copyright> > * >- * Copyright (c) 2006-2007 IBM Corporation and others. >+ * Copyright (c) 2006-2008 IBM Corporation, Zeligsoft Inc., and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -9,6 +9,7 @@ > * > * Contributors: > * IBM - Initial API and implementation >+ * Zeligsoft - 255469 Implement basic eCall support > * > * </copyright> > * >@@ -16,6 +17,7 @@ > */ > package org.eclipse.emf.ecore.util; > >+import java.lang.reflect.InvocationTargetException; > import java.math.BigDecimal; > import java.math.BigInteger; > >@@ -496,6 +498,8 @@ > return validateEString((String)value, diagnostics, context); > case EcorePackage.ETREE_ITERATOR: > return validateETreeIterator((TreeIterator<?>)value, diagnostics, context); >+ case EcorePackage.EINVOCATION_TARGET_EXCEPTION: >+ return validateEInvocationTargetException((InvocationTargetException)value, diagnostics, context); > default: > return true; > } >@@ -4044,6 +4048,16 @@ > } > > /** >+ * <!-- begin-user-doc --> >+ * <!-- end-user-doc --> >+ * @generated >+ */ >+ public boolean validateEInvocationTargetException(InvocationTargetException eInvocationTargetException, DiagnosticChain diagnostics, Map<Object, Object> context) >+ { >+ return true; >+ } >+ >+ /** > * Returns the resource locator that will be used to fetch messages for this validator's diagnostics. > * <!-- begin-user-doc --> > * <!-- end-user-doc --> >Index: src/org/eclipse/emf/ecore/util/BasicSettingDelegate.java >=================================================================== >RCS file: src/org/eclipse/emf/ecore/util/BasicSettingDelegate.java >diff -N src/org/eclipse/emf/ecore/util/BasicSettingDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/ecore/util/BasicSettingDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,306 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 IBM Corporation, Zeligsoft Inc., and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ * Zeligsoft - 216701 Removed redundant eStructuralFeature field from Stateless >+ * >+ * </copyright> >+ * >+ * $Id$ >+ */ >+package org.eclipse.emf.ecore.util; >+ >+import org.eclipse.emf.common.notify.NotificationChain; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.ecore.InternalEObject; >+import org.eclipse.emf.ecore.EStructuralFeature.Setting; >+import org.eclipse.emf.ecore.EStructuralFeature.Internal.DynamicValueHolder; >+ >+/** >+ * A basic implementation of a stateful setting delegate. >+ * At least the first two of these methods needs to be overridden. >+ * <ul> >+ * <li>{@link #dynamicGet(InternalEObject, DynamicValueHolder, int, boolean, boolean)}</li> >+ * <li>{@link #dynamicIsSet(InternalEObject, DynamicValueHolder, int)}</li> >+ * <li>{@link #dynamicSet(InternalEObject, DynamicValueHolder, int, Object)}</li> >+ * <li>{@link #dynamicUnset(InternalEObject, DynamicValueHolder, int)}</li> >+ * <li>{@link #dynamicInverseAdd(InternalEObject, DynamicValueHolder, int, InternalEObject, NotificationChain)}</li> >+ * <li>{@link #dynamicInverseRemove(InternalEObject, DynamicValueHolder, int, InternalEObject, NotificationChain)}</li> >+ * </ul> >+ */ >+public abstract class BasicSettingDelegate implements EStructuralFeature.Internal.SettingDelegate >+{ >+ protected EStructuralFeature eStructuralFeature; >+ >+ public BasicSettingDelegate(EStructuralFeature eStructuralFeature) >+ { >+ this.eStructuralFeature = eStructuralFeature; >+ } >+ >+ public Setting dynamicSetting(final InternalEObject owner, final DynamicValueHolder settings, final int dynamicFeatureID) >+ { >+ return >+ new EStructuralFeature.Setting() >+ { >+ public EObject getEObject() >+ { >+ return owner; >+ } >+ >+ public EStructuralFeature getEStructuralFeature() >+ { >+ return eStructuralFeature; >+ } >+ >+ public Object get(boolean resolve) >+ { >+ return BasicSettingDelegate.this.dynamicGet(owner, settings, dynamicFeatureID, resolve, true); >+ } >+ >+ public boolean isSet() >+ { >+ return BasicSettingDelegate.this.dynamicIsSet(owner, settings, dynamicFeatureID); >+ } >+ >+ public void set(Object newValue) >+ { >+ BasicSettingDelegate.this.dynamicSet(owner, settings, dynamicFeatureID, newValue); >+ } >+ >+ public void unset() >+ { >+ BasicSettingDelegate.this.dynamicUnset(owner, settings, dynamicFeatureID); >+ } >+ }; >+ } >+ >+ public abstract Object dynamicGet(InternalEObject owner, DynamicValueHolder settings, int dynamicFeatureID, boolean resolve, boolean coreType); >+ >+ >+ public abstract boolean dynamicIsSet(InternalEObject owner, DynamicValueHolder settings, int dynamicFeatureID); >+ >+ >+ public void dynamicSet(InternalEObject owner, DynamicValueHolder settings, int dynamicFeatureID, Object newValue) >+ { >+ throw new UnsupportedOperationException(); >+ } >+ >+ public void dynamicUnset(InternalEObject owner, DynamicValueHolder settings, int dynamicFeatureID) >+ { >+ throw new UnsupportedOperationException(); >+ } >+ >+ public NotificationChain dynamicInverseAdd >+ (InternalEObject owner, >+ DynamicValueHolder settings, >+ int dynamicFeatureID, >+ InternalEObject otherEnd, >+ NotificationChain notifications) >+ { >+ throw new UnsupportedOperationException(); >+ } >+ >+ public NotificationChain dynamicInverseRemove >+ (InternalEObject owner, >+ DynamicValueHolder settings, >+ int dynamicFeatureID, >+ InternalEObject otherEnd, >+ NotificationChain notifications) >+ { >+ throw new UnsupportedOperationException(); >+ } >+ >+ /** >+ * A basic implementation of a stateless setting delegate. >+ * At least the first two of these methods should be overridden. >+ * <ul> >+ * <li>{@link #setting(InternalEObject)}</li> >+ * <li>{@link #get(InternalEObject, boolean, boolean)}</li> >+ * <li>{@link #set(InternalEObject, Object)}</li> >+ * <li>{@link #isSet(InternalEObject)}</li> >+ * <li>{@link #unset(InternalEObject)}</li> >+ * <li>{@link #inverseAdd(InternalEObject, InternalEObject, NotificationChain)}</li> >+ * <li>{@link #inverseRemove(InternalEObject, InternalEObject, NotificationChain)}</li> >+ * </ul> >+ */ >+ public static abstract class Stateless extends BasicSettingDelegate >+ { >+ public Stateless(EStructuralFeature eStructuralFeature) >+ { >+ super(eStructuralFeature); >+ } >+ >+ @Override >+ public final Setting dynamicSetting(InternalEObject owner, DynamicValueHolder settings, int dynamicFeatureID) >+ { >+ return setting(owner); >+ } >+ >+ /** >+ * Creates a setting for the owner and this delegate's feature. >+ * @param owner the owner for the setting. >+ * @return a new setting. >+ */ >+ protected Setting setting(final InternalEObject owner) >+ { >+ return >+ new EStructuralFeature.Setting() >+ { >+ public EObject getEObject() >+ { >+ return owner; >+ } >+ >+ public EStructuralFeature getEStructuralFeature() >+ { >+ return eStructuralFeature; >+ } >+ >+ public Object get(boolean resolve) >+ { >+ return Stateless.this.get(owner, resolve, true); >+ } >+ >+ public boolean isSet() >+ { >+ return Stateless.this.isSet(owner); >+ } >+ >+ public void set(Object newValue) >+ { >+ Stateless.this.set(owner, newValue); >+ } >+ >+ public void unset() >+ { >+ Stateless.this.unset(owner); >+ } >+ }; >+ } >+ >+ @Override >+ public final Object dynamicGet(InternalEObject owner, DynamicValueHolder settings, int dynamicFeatureID, boolean resolve, boolean coreType) >+ { >+ return get(owner, resolve, coreType); >+ } >+ >+ /** >+ * Returns the value of this delegate's feature for the owner. >+ * @param owner the object for with to fetch the value. >+ * @param resolve whether the returned object should be resolved it if is a proxy. >+ * @param coreType whether to return the core type value or the API type value. >+ * @return the value of this delegate's feature for the owner. >+ * @see InternalEObject#eGet(EStructuralFeature, boolean, boolean) >+ */ >+ protected abstract Object get(InternalEObject owner, boolean resolve, boolean coreType); >+ >+ @Override >+ public final boolean dynamicIsSet(InternalEObject owner, DynamicValueHolder settings, int dynamicFeatureID) >+ { >+ return isSet(owner); >+ } >+ >+ /** >+ * Returns whether the value of this delegate's feature is considered set for the owner. >+ * @param owner the object for with to test is set. >+ * @return whether the value of this delegate's feature is considered set for the owner. >+ * @see EObject#eIsSet(EStructuralFeature) >+ */ >+ protected abstract boolean isSet(InternalEObject owner); >+ >+ @Override >+ public final void dynamicSet(InternalEObject owner, DynamicValueHolder settings, int dynamicFeatureID, Object newValue) >+ { >+ set(owner, newValue); >+ } >+ >+ /** >+ * Sets this new value of this delegate's feature for the owner. >+ * @param owner the owner for which to set the value >+ * @param newValue the new value for the feature. >+ * @see EObject#eSet(EStructuralFeature, Object) >+ */ >+ protected void set(InternalEObject owner, Object newValue) >+ { >+ throw new UnsupportedOperationException(); >+ } >+ >+ @Override >+ public final void dynamicUnset(InternalEObject owner, DynamicValueHolder settings, int dynamicFeatureID) >+ { >+ unset(owner); >+ } >+ >+ /** >+ * Unsets the values of this delegate's feature for the owner. >+ * @param owner the owner for which to unset the value. >+ * @see EObject#eUnset(EStructuralFeature) >+ */ >+ protected void unset(InternalEObject owner) >+ { >+ throw new UnsupportedOperationException(); >+ } >+ >+ @Override >+ public final NotificationChain dynamicInverseAdd >+ (InternalEObject owner, >+ DynamicValueHolder settings, >+ int dynamicFeatureID, >+ InternalEObject otherEnd, >+ NotificationChain notifications) >+ { >+ return inverseAdd(owner, otherEnd, notifications); >+ } >+ >+ /** >+ * Adds the object at the other end of a bidirectional reference to this delegate's feature >+ * and returns accumulated notifications. >+ * @param owner the owner for which to do the inverse add. >+ * @param otherEnd the object to inverse add. >+ * @param notifications the notifications accumulated so far. >+ * @return the accumulated notifications. >+ */ >+ protected NotificationChain inverseAdd >+ (InternalEObject owner, >+ InternalEObject otherEnd, >+ NotificationChain notifications) >+ { >+ throw new UnsupportedOperationException(); >+ } >+ >+ @Override >+ public final NotificationChain dynamicInverseRemove >+ (InternalEObject owner, >+ DynamicValueHolder settings, >+ int dynamicFeatureID, >+ InternalEObject otherEnd, >+ NotificationChain notifications) >+ { >+ return inverseRemove(owner, otherEnd, notifications); >+ } >+ >+ /** >+ * Remove the object at the other end of a bidirectional reference from this delegate's feature >+ * and returns accumulated notifications. >+ * @param owner the owner for which to do the inverse remove. >+ * @param otherEnd the object to inverse remove. >+ * @param notifications the notifications accumulated so far. >+ * @return the accumulated notifications. >+ */ >+ protected NotificationChain inverseRemove >+ (InternalEObject owner, >+ InternalEObject otherEnd, >+ NotificationChain notifications) >+ { >+ throw new UnsupportedOperationException(); >+ } >+ } >+} >Index: src/org/eclipse/emf/ecore/util/PathSettingDelegate.java >=================================================================== >RCS file: src/org/eclipse/emf/ecore/util/PathSettingDelegate.java >diff -N src/org/eclipse/emf/ecore/util/PathSettingDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/ecore/util/PathSettingDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,115 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ * >+ * </copyright> >+ * >+ * $Id$ >+ */ >+package org.eclipse.emf.ecore.util; >+ >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.EClass; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.ecore.EcorePackage; >+import org.eclipse.emf.ecore.InternalEObject; >+ >+public class PathSettingDelegate extends BasicSettingDelegate.Stateless >+{ >+ protected EStructuralFeature[] path; >+ >+ public PathSettingDelegate(EStructuralFeature eStructuralFeature) >+ { >+ super(eStructuralFeature); >+ String namePath = URI.createURI(eStructuralFeature.getEAnnotation(EcorePackage.eNS_URI).getDetails().get("settingDelegate")).fragment(); >+ String[] segments = namePath.split("/"); >+ path = new EStructuralFeature[segments.length]; >+ for (int i = 0; i < segments.length; ++i) >+ { >+ String featureName = segments[i]; >+ EClass eClass = i == 0 ? eStructuralFeature.getEContainingClass() : (EClass)path[i - 1].getEType(); >+ path[i] = eClass.getEStructuralFeature(featureName); >+ } >+ } >+ >+ public PathSettingDelegate(EStructuralFeature eStructuralFeature, EStructuralFeature[] path) >+ { >+ super(eStructuralFeature); >+ this.path = path; >+ } >+ >+ @Override >+ protected Object get(InternalEObject owner, boolean resolve, boolean coreType) >+ { >+ InternalEObject eObject = owner; >+ for (int i = 0, limit = path.length - 1; i < limit; ++i) >+ { >+ EStructuralFeature feature = path[i]; >+ if (feature.isMany()) >+ { >+ ArrayList<Object> result = new ArrayList<Object>(); >+ @SuppressWarnings("unchecked") >+ List<EObject> elements = (List<EObject>)eObject.eGet(feature, resolve, coreType); >+ for (EObject element : elements) >+ { >+ Object value = element.eGet(path[i + 1]); >+ result.add(value); >+ } >+ return >+ new EcoreEList.UnmodifiableEList.FastCompare<Object> >+ (owner, eStructuralFeature, result.size(), result.toArray()); >+ } >+ else >+ { >+ eObject = (InternalEObject)eObject.eGet(feature); >+ } >+ } >+ return eObject.eGet(path[path.length - 1], resolve, coreType); >+ } >+ >+ @Override >+ protected boolean isSet(InternalEObject owner) >+ { >+ InternalEObject eObject = owner; >+ for (int i = 0, limit = path.length - 1; i < limit; ++i) >+ { >+ eObject = (InternalEObject)eObject.eGet(path[i]); >+ } >+ return eObject.eIsSet(path[path.length - 1]); >+ } >+ >+ @Override >+ protected void set(InternalEObject owner, Object newValue) >+ { >+ InternalEObject eObject = owner; >+ for (int i = 0, limit = path.length - 1; i < limit; ++i) >+ { >+ eObject = (InternalEObject)eObject.eGet(path[i]); >+ } >+ eObject.eSet(path[path.length - 1], newValue); >+ } >+ >+ @Override >+ protected void unset(InternalEObject owner) >+ { >+ InternalEObject eObject = owner; >+ for (int i = 0, limit = path.length - 1; i < limit; ++i) >+ { >+ eObject = (InternalEObject)eObject.eGet(path[i]); >+ } >+ eObject.eUnset(path[path.length - 1]); >+ } >+} >Index: src/org/eclipse/emf/ecore/util/BasicCallDelegate.java >=================================================================== >RCS file: src/org/eclipse/emf/ecore/util/BasicCallDelegate.java >diff -N src/org/eclipse/emf/ecore/util/BasicCallDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/ecore/util/BasicCallDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,99 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2008 Zeligsoft Inc. and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Zeligsoft - Initial API and implementation >+ * >+ * </copyright> >+ * >+ * $Id$ >+ */ >+ >+package org.eclipse.emf.ecore.util; >+ >+import java.lang.reflect.InvocationTargetException; >+ >+import org.eclipse.emf.common.util.EList; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.ecore.EcorePackage; >+import org.eclipse.emf.ecore.InternalEObject; >+import org.eclipse.emf.ecore.EOperation; >+ >+ >+/** >+ * A basic implementation of the dynamic operation-call delegate API. In fact, >+ * it is so basic that it isn't much an implementation at all, but merely >+ * throws {@link UnsupportedOperationException} on every invocation, except for >+ * the operations define for the {@link EObject} class. >+ * Subclasses should override the {@link #dynamicCall(InternalEObject, EList)} >+ * method to not do that. >+ */ >+public class BasicCallDelegate implements EOperation.Internal.CallDelegate >+{ >+ protected EOperation eOperation; >+ >+ /** >+ * Initializes me with the operation that delegates calls to me. >+ * >+ * @param operation my operation >+ */ >+ public BasicCallDelegate(EOperation operation) >+ { >+ this.eOperation = operation; >+ } >+ >+ public Object dynamicCall(InternalEObject target, EList<?> arguments) throws InvocationTargetException >+ { >+ if (eOperation.getEContainingClass() == EcorePackage.Literals.EOBJECT) >+ { >+ //TODO: EOperations should have IDs, like structural features. >+ // These IDs should be listed in the generated package interface >+ int id = eOperation.getEContainingClass().getEAllOperations().indexOf(eOperation); >+ >+ switch (id) { >+ case 0: // EcorePackage.EOBJECT___ECLASS >+ return target.eClass(); >+ case 1: // EcorePackage.EOBJECT___EIS_PROXY >+ return target.eIsProxy(); >+ case 2: // EcorePackage.EOBJECT___ERESOURCE >+ return target.eResource(); >+ case 3: // EcorePackage.EOBJECT___ECONTAINER >+ return target.eContainer(); >+ case 4: // EcorePackage.EOBJECT___ECONTAINING_FEATURE >+ return target.eContainingFeature(); >+ case 5: // EcorePackage.EOBJECT___ECONTAINMENT_FEATURE >+ return target.eContainmentFeature(); >+ case 6: // EcorePackage.EOBJECT___ECONTENTS >+ return target.eContents(); >+ case 7: // EcorePackage.EOBJECT___EALL_CONTENTS >+ return target.eAllContents(); >+ case 8: // EcorePackage.EOBJECT___ECROSS_REFERENCES >+ return target.eCrossReferences(); >+ case 9: // EcorePackage.EOBJECT___EGET__FEATURE >+ return target.eGet((EStructuralFeature) arguments.get(0)); >+ case 10: // EcorePackage.EOBJECT___EGET__FEATURE__RESOLVE >+ return target.eGet((EStructuralFeature) arguments.get(0), (Boolean) arguments.get(1)); >+ case 11: // EcorePackage.EOBJECT___ESET__FEATURE__NEW_VALUE >+ target.eSet((EStructuralFeature) arguments.get(0), arguments.get(1)); >+ return null; >+ case 12: // EcorePackage.EOBJECT___EIS_SET__FEATURE >+ return target.eIsSet((EStructuralFeature) arguments.get(0)); >+ case 13: // EcorePackage.EOBJECT___EUNSET__FEATURE >+ target.eUnset((EStructuralFeature) arguments.get(0)); >+ return null; >+ case 14: // EcorePackage.EOBJECT___ECALL__OPERATION__ARGUMENTS >+ return target.eCall((EOperation) arguments.get(0), (EList<?>) arguments.get(1)); >+ } >+ } >+ >+ throw new UnsupportedOperationException("eCall not implemented for " + eOperation.getName()); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 255469
:
118008
|
118009
|
148791
|
149767
|
150408
|
150693
|
151088
|
155103