|
Re: EClass.eSet method only takes collection? [message #524672 is a reply to message #524664] |
Thu, 01 April 2010 13:40 |
|
Hi, Aravind,
Your "id" attribute is multi-valued (upper bound more than 1). The
eSet() method replaces the *entire* value of a feature. For
multi-valued features, that requires a list.
Perhaps you actually wanted a single-valued "id" feature? In that case,
you need to fix your Ecore model.
HTH,
Christian
On 01/04/10 02:11 PM, aravind wrote:
> I am dynamically instantiating the model. When I try to set an attribute
> value like below, I am getting a ClassCastExcepption. Can someone
> explain what I am doing wrong?
>
> The "id" attribute is defined as EShort type in the EMF.
>
> Segment segment = respFactory.createSegment();
> EClass segmentMeta = segment.eClass();
> EAttribute attr = (EAttribute) segmentMeta.getEStructuralFeature("id");
> segmentMeta.eSet(attr, Short.valueOf("0"));
>
>
> But when I change the last line as below, it works
> segmentMeta.eSet(attr, new ArrayList(Short.valueOf("0")));
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02497 seconds