[Yanel-dev] SitetreeDOMImpl or rather NodeDOMImpl has an issue
re isCollection
Michael Wechner
michael.wechner at wyona.com
Thu Dec 17 10:59:02 CET 2009
Guillaume Déflache wrote:
> Hi!
>
> Michael Wechner schrieb:
>> Michael Wechner wrote:
>>> Hi
>>>
>>> I just realized that the Sitetree/Node DOM implementation
>>>
>>> src/impl/java/org/wyona/yanel/impl/navigation/NodeDOMImpl.java
>>>
>>> has an issue re the isCollection()/isResource() method. It is based
>>> on an XML, e.g.
>>>
>>> <node name="brands" url="/brands.html">
>>> <label>List of all brands</label>
>>>
>>> <node name="scotch-and-soda">
>>> <label>Scoth & Soda</label>
>>> </node>
>>> <node name="diesel"><label>Diesel</label></node></node>
>>>
>>> and when creating a new child and one should have to specify the
>>> node type (either collection or resource), then
>>> it's not clear what node type, because the method appendChild(Node)
>>> has no such argument
>>> and the methods isCollection() of the DOM implementation is just
>>> checking if there children.
>>>
>>> Of course there is the workaround that if it is supposed to be a
>>> collection, then create a child for this node, which
>>> will make it implicitely a collection. But that's not very nice :-(
>>>
>>> Hence I would suggest to change the API by introducing a method
>>> appendChild(Node, NodeType)
>>
>> I have fixed this now by changing appendChild(Node) to
>> appendChild(Node, int)
>>
>> whereas int is for example Node.COLLECTION or Node.RESOURCE
>
> Why use an int instead of an enum?
because src/core/java/org/wyona/yarep/core/Node.java also uses an int
and to be honest I didn't think much about it ;-)
What would be the advantage of enum? (Since we broke the backwards
compatibility yesterday I would say we can break
it once again today if there is a good reason to use enum)
> In case you wondered binary backward-compatibility rules of enums and
> their values are the same as those of classes and their methods, cf.
> http://java.sun.com/docs/books/jls/third_edition/html/binaryComp.html#78657
>
I am not sure I understand. Can you explain this?
Thanks
Michi
>
>
> Cheers,
> Guillaume
More information about the Yanel-development
mailing list