You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Timothy Larson <ti...@yahoo.com> on 2003/10/30 15:32:41 UTC

AggregateField.java fieldsHaveValues()

In AggregateField.java the method fieldsHaveValues() has a conflict
with its comment.  The code only returns true if every field has a
value.  The comment says differently.  Which is the desired behavior,
what the code currently does or what the comment says it does?

    /**
     * Returns true if their is at least one field which has a value.
     */
    private boolean fieldsHaveValues() {
        Iterator fieldsIt = fields.iterator();
        while (fieldsIt.hasNext()) {
            Field field = (Field)fieldsIt.next();
            if (field.getValue() == null)
                return false;
        }
        return true;
    }

--Tim Larson


__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/

Re: AggregateField.java fieldsHaveValues()

Posted by Marc Portier <mp...@outerthought.org>.
according to this tracable history in cvs:
http://cvs.apache.org/viewcvs.cgi/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/formmodel/AggregateField.java.diff?r1=1.4&r2=1.5&diff_format=h

I would go for changing the comment based on bruno's change-log:

modified the fieldsHaveValues() method to check the values of all 
fields; if the values have been set programatically (such as done by the 
binding) then it could be that some fields have values while others don't.

I'll make the change and commit. Thx for noticing!
-marc=

Timothy Larson wrote:

> In AggregateField.java the method fieldsHaveValues() has a conflict
> with its comment.  The code only returns true if every field has a
> value.  The comment says differently.  Which is the desired behavior,
> what the code currently does or what the comment says it does?
> 
>     /**
>      * Returns true if their is at least one field which has a value.
>      */
>     private boolean fieldsHaveValues() {
>         Iterator fieldsIt = fields.iterator();
>         while (fieldsIt.hasNext()) {
>             Field field = (Field)fieldsIt.next();
>             if (field.getValue() == null)
>                 return false;
>         }
>         return true;
>     }
> 
> --Tim Larson
> 
> 
> __________________________________
> Do you Yahoo!?
> Exclusive Video Premiere - Britney Spears
> http://launch.yahoo.com/promos/britneyspears/
> 

-- 
Marc Portier                            http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at              http://radio.weblogs.com/0116284/
mpo@outerthought.org                              mpo@apache.org