[Yanel-dev] SitetreeDOMImpl or rather NodeDOMImpl has an issue re isCollection

Guillaume Déflache guillaume.deflache at wyona.com
Thu Dec 17 10:37:27 CET 2009


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 &amp; 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?
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


Cheers,
    Guillaume


More information about the Yanel-development mailing list