EMF Gurus,
Dynamically, I get hold of
an EPackage from the Ecore which is discovered during runtime ...
EPackage pkg = .......
EClass eClass = getDriverClass(pkg);
feature =
eClass.getEStructuralFeature(propertyName); // returns a correct
feature
// THE PROBLEM IS container
class of feature is null
// SO I get an exception
'Invalid feature xxx ..' when I do someEObject.eGet(feature) to extract
the value
// NOW
IF I STATICALLY TRY TO RETRIEVE THE FEATURE ... its container class is NOT NULL
and someEObject.eGet(feature) .. gives me correct value from xmi
file.
EStructuralFeature
feature = null;
if
(driverName.equalsIgnoreCase("jms")){
feature =
JMSDriverPackageImpl.eINSTANCE.getJMSDriver().getEStructuralFeature(propertyName);
}
//
private EClass getDriverClass()
{
EClass eClass =
null;
for (Iterator i =
pkg.getEClassifiers().iterator(); i.hasNext();) {
EClassifier eClassifier = (EClassifier) i.next();
if (eClassifier instanceof EClass) {
eClass = (EClass) eClassifier;
// Get the eClass whose super type is Driver
List eSuperTypes = eClass.getESuperTypes();
//
for (Iterator iter = eSuperTypes.iterator(); iter.hasNext();)
{
EClass eSuperType = (EClass)iter.next();
//
URI eClassURI = EcoreUtil.getURI(eSuperType);
String eClassURIFragment = eClassURI.fragment();
if (eClassURIFragment.contains("Driver")){
return eClass;
}
}
}
}
return eClass
;
}
What is the solution to this problem
? How do I get hold of the feature correctly ?
Rgds,
Kaniska