|Re: EDataType creation [message #636827 is a reply to message #636770]
||Wed, 03 November 2010 01:33
| Ed Merks
Registered: July 2009
> Hi Guys,
> I have a strange problem. Probably, this was already solved in some
> previous thread (i checked through most of the forum discussion on
> this issue).
> I do the following in my code.
> EcoreFactory theCoreFactory = EcoreFactory.eINSTANCE;
Why would you do such a thing?
> EAttribute tempEAttribute = theCoreFactory.createEAttribute();
> EDataType tempEDataType = theCoreFactory.createEDataType();
> /*The method returns me a Class object*/
> Class<?> temp = getMetaGMEElementFieldType(ProjectTypeImpl.class,
Mystery method that returns an Class....
Setting the instance class petty much determines the instance type name,
Given that there are no type arguments, is there any point in setting both?
This is already the default.
What might tempNode be? Is it really the default value, or is it a literal?
> Now the setDefaultValue() method throws me a NullPointerException.
You know how to use the debugger, right?
> I researched a bit, and found that it is the following piece of code
> EFactory factory = eType.getEPackage().getEFactoryInstance();
> in the setDefaultValue() (defined in EStructuralFeatureImpl class)
> that throws the exception.
An EDataType that's not in an EPackage is not in a meaningful/complete
context where you should expect to be able to use it. Similarly an
EAttribute that's not in an EClass in an EPackage is also kind of a free
floating bit of meaninglessness.
> I inspected the eType (EClassifier object) and found that the
Yep, that's what I'd expect.
> How can I solve this problem?
What exactly are you trying to accomplish? A complete Ecore model will
definitely require everything to be rooted in an EPackage....
Powered by FUDForum
. Page generated in 0.01685 seconds