Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] [MOXy] empty string

Hi Blaise,

Wow, that was a fast reply!  I think I will go with option #1 since I don't
know who else might be calling the setter.  

Thanks!!
--Polly


Blaise Doughan wrote:
> 
> Hi Polly,
> 
> The relevant method is "setSetPerformedForAbsentNode(boolean)"
> http://www.eclipse.org/eclipselink/api/1.1/org/eclipse/persistence/oxm/mappings/nullpolicy/NullPolicy.html#setSetPerformedForAbsentNode(boolean)
> 
> You will want to configure this parameter to be false.  Then EclipseLink 
> will not perform a set operation for missing tags.  For the "" porting 
> you have two options:
> 
>    1. Use a converter with the mapping, if the field value is null then
>       return "" as the attribute value.
>    2. Use method accessing on the mapping (configure the mapping to use
>       the get/set methods instead of the attribute directly).  Then put
>       logic on the set method to convert null to "".  Since EclipseLink
>       won't perform a set for missing tags you'll know that the set to
>       null calls correspond only to empty tags.
> 
> -Blaise
> 
> polly.c.chang wrote:
>> Hi,
>>
>> I have a situation where we need to distinguish between empty tags vs.
>> missing tags.  The rules are:
>>
>> For all String types:
>> * If the XML has <description></description>, that is supposed to mean
>> empty
>> string ("").
>> * If the XML has no "description" tag, that is supposed to mean null.
>> * And vice versa for marshalling.
>>
>> I looked at the javadoc and found that I might need to set a NullPolicy:
>> http://www.eclipse.org/eclipselink/api/1.1/org/eclipse/persistence/oxm/mappings/nullpolicy/NullPolicy.html
>>
>> I am still confused after reading the documentation though.  How do I
>> tell
>> EclipseLink that empty string means empty tags?  
>>
>> Thanks!
>> --Polly
>>   
> 
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> 
> 

-- 
View this message in context: http://www.nabble.com/-MOXy--empty-string-tp22665748p22668606.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top