Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Override behavior of KEEP_DEFAULT_CONTENT
Override behavior of KEEP_DEFAULT_CONTENT [message #430548] Wed, 27 May 2009 04:16 Go to next message
John T.E. Timm is currently offline John T.E. TimmFriend
Messages: 161
Registered: July 2009
Senior Member
I would like to override the behavior of the "keep default content" option
such that the default value for an attribute is serialized if and only if
the attribute is required (lower bound > 0). Where is the best place to do
this?

Thanks,

JT
Re: Override behavior of KEEP_DEFAULT_CONTENT [message #430554 is a reply to message #430548] Wed, 27 May 2009 10:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
John,

This method in XMLSaveImpl makes the decision:

protected boolean shouldSaveFeature(EObject o, EStructuralFeature f)
{
return o.eIsSet(f) || keepDefaults && f.getDefaultValueLiteral() !=
null;
}

I'm not sure you'll ever want to serialize null though...


John T.E. Timm wrote:
> I would like to override the behavior of the "keep default content"
> option such that the default value for an attribute is serialized if
> and only if the attribute is required (lower bound > 0). Where is the
> best place to do this?
>
> Thanks,
>
> JT
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Override behavior of KEEP_DEFAULT_CONTENT [message #430573 is a reply to message #430554] Wed, 27 May 2009 15:38 Go to previous message
John T.E. Timm is currently offline John T.E. TimmFriend
Messages: 161
Registered: July 2009
Senior Member
Thanks Ed. This is exactly what I was looking for.

JT

Ed Merks wrote:

> John,

> This method in XMLSaveImpl makes the decision:

> protected boolean shouldSaveFeature(EObject o, EStructuralFeature f)
> {
> return o.eIsSet(f) || keepDefaults && f.getDefaultValueLiteral() !=
> null;
> }

> I'm not sure you'll ever want to serialize null though...


> John T.E. Timm wrote:
>> I would like to override the behavior of the "keep default content"
>> option such that the default value for an attribute is serialized if
>> and only if the attribute is required (lower bound > 0). Where is the
>> best place to do this?
>>
>> Thanks,
>>
>> JT
>>
Previous Topic:why some Ecore EReferences are now changeable=false ?
Next Topic:loading XML without namepace declaration
Goto Forum:
  


Current Time: Fri Apr 19 20:08:15 GMT 2024

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

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

Back to the top