[ 
https://issues.apache.org/jira/browse/WODEN-141?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12513977
 ] 

Jeremy Hughes commented on WODEN-141:
-------------------------------------

Some time ago, we removed the 'createXXX' in favour of 'addXXX'. We resolved 
then that createXXX shouldn't have side-effects - so a createXXX method would 
create an XXX and nothing else. Then we would have needed addXXX methods to add 
the XXX onto the DescriptionElement. This seemed a bit cumbersome so we 
resolved to have addXXX create *and* add XXX which followed a pattern in a JSR 
(sorry forget the number/ technology ... I can dig it up if you like).

Since there can only be one types element we decided it wasn't the right thing 
to have an addTypesElement method. I can see the problem this JIRA is trying to 
solve - how to determine whether there's a types element and if there is one 
how to remove it. Clearly in checking whether there's one there we don't want 
to create one if we didn't want one. So IMO #1 getTypesElement should return 
null if one doesn't exist. This kinda mirrors the other getXXX methods (except 
those return empty array).

We're going to need removeXXX methods - there's a comment in DescriptionElement:

    /*
     * Element accessor and modifier methods
     * 
     * TODO removeXXX(obj), getXXX(key) methods
     * 
     */

so we're going to have a removeTypesElement() (note: doesn't need param as 
there is only 0 or 1 of them). So to have createTypesElement/removeTypesElement 
when everything else is addXXX/removeXXX doesn't feel so neat. So #2 I'd prefer 
createTypesElement() to be called addTypesElement() which would (#3) throw an 
exception if one is already there.

So
#1 getTypesElement() returns null if there is none
#2 addTypesElement() instead of createTypesElement() 
#3 addTypesElement() throws WSDLException if there is one already

What do you all think?

> DescriptionElement.getTypesElement() should not be a factory method
> -------------------------------------------------------------------
>
>                 Key: WODEN-141
>                 URL: https://issues.apache.org/jira/browse/WODEN-141
>             Project: Woden
>          Issue Type: Bug
>          Components: Parser
>            Reporter: John Kaputin
>            Assignee: John Kaputin
>             Fix For: M8
>
>
> The behaviour of the DescriptionElement.getTypesElement() method is to return 
> the types element if it exists or if not, create it and return it.  This 
> means that the model can never reflect an infoset that does not have a 
> <wsdl:types> element because this getter method will always create one even 
> if there isn't one in the WSDL. 
> Instead, this method should return null if there is no types element and a 
> new factory method is required - createTypesElement(), which will create a 
> TypesElement, set the DescriptionElement as its parent and return a reference 
> to it. This is similar behaviour to the addXXXXElement methods that create 
> sets of child elements, except that it acts on a single types element only 
> (hence the method name 'create' rather than 'add').

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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

Reply via email to