[ 
http://issues.apache.org/jira/browse/BETWIXT-55?page=comments#action_12454754 ] 
            
Jesse Sweetland commented on BETWIXT-55:
----------------------------------------

The patch I submitted has a bug . . . 

// If the element is collective then the value should be null or an
// Iterator.  I'm not sure what to do if it's not an iterator.
// I guess we can default to the original behavior, which is to
// treat a collective descriptor as non-empty, although perhaps a
// warning should be issue here.
return false;

Should be:

// Both the wrapper and the element being wrapped are considered
// collective.  If the value is null, then we are probably looking
// at the element being wrapped, which might have child descriptors
// and so forth.  Let the control flow out of this condition and
// check for empty child descriptors and whatnot.

(Without return false)

I'm working on generating a new patch, but I have to revert my codebase to 0.7 
(or 0.8 if it's out) first to make sure it's clean.



> Suppress Empty Collection Wrapper Elements
> ------------------------------------------
>
>                 Key: BETWIXT-55
>                 URL: http://issues.apache.org/jira/browse/BETWIXT-55
>             Project: Commons Betwixt
>          Issue Type: Improvement
>         Environment: N/A
>            Reporter: Jesse Sweetland
>            Priority: Trivial
>         Attachments: AbstractBeanWriter.java.diff, 
> AbstractBeanWriter.java.diff, AbstractBeanWriter.java.diff
>
>
> Attached is a patch that modifies the isEmptyElement method of 
> AbstractBeanWriter to consider collective element descriptors as empty if the 
> collection properties they reference have no elements.  This suppresses the 
> output of empty wrapper elements.  For example, consider the following 
> .betwixt file for class Foo:
> <info> 
>   <element name="foo"> 
>     <element name="bars"> 
>       <element name="bar" property="bars"/> 
>     </element> 
>     <addDefaults/> 
>   </element> 
> </info> 
> Under Betwixt 0.7, an empty <bars/> element is written even if Foo.getBars() 
> returns a null or empty collection.  This patch determines that the 
> collection descriptor for the <bar> element is empty, so all of the children 
> elements of the <bars> wrapper element descriptor are empty, so the <bars> 
> element descriptor itself is empty, and is therefore ignored.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to