Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to append an EObject to an AnyType containment reference.
How to append an EObject to an AnyType containment reference. [message #655478] Mon, 21 February 2011 10:40 Go to next message
Tom H is currently offline Tom HFriend
Messages: 139
Registered: July 2009
Senior Member
I have an ecore generated from an xsd schema with a zero or more containment element.

Is there an example of how I can add some other existing EObject to the list?

I have something like;
myEObject.getAny()

which returns a featureMap, but I am not clear on how to append to feagure maps.


I want to do something like this myEobject.getAny().add(myOtherEObject)

any suggestions?

Thanks
T
Re: How to append an EObject to an AnyType containment reference. [message #655614 is a reply to message #655478] Mon, 21 February 2011 23:38 Go to previous message
Tom H is currently offline Tom HFriend
Messages: 139
Registered: July 2009
Senior Member
Ok, so I have to retrieve the Featuremap from the AnyType and then add a new Object. I did this and it seems to work ;

//get an instance of the type that has a containment of AnyType
BodyType bt = EnvelopeFactory.eINSTANCE.createBodyType();

get the feature map
FeatureMap fm = bt.getAny();

demand create a structural feature
ExtendedMetaData emd = ExtendedMetaData.INSTANCE;
EStructuralFeature childNodeFeature = emd.demandFeature(
NAMESPACE_URI,
"CompanyDetailsRequest", true);

AnyType textChildTreeNode = XMLTypeFactory.eINSTANCE.createAnyType();
fm.add(childNodeFeature, getGovTalkBody().getRequest());
Previous Topic:EObject as reference type
Next Topic:Serializing EObject using Object handle
Goto Forum:
  


Current Time: Thu Apr 25 01:15:56 GMT 2024

Powered by FUDForum. Page generated in 0.03706 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top