Pedro Izecksohn wrote:
> >And maybe we can share one instance of the EmptyNodeList
> >for the whole dom tree so if a tree contains lots of empty node list we
> >only allocate one.
> 
> I was thinking on this issue.
> 
> >The cast in getChildNode() isn't necessary since
> >EmptyNodeList already is a NodeList.
> 
> I wrongly typed that.
> 
> Add to gnu.xml.dom.DomCharacterData.java:
> 
> import org.w3c.dom.NodeList;
> 
>   /**
>    * Returns an EmptyNodeList.
>    */
>   public NodeList getChildNodes()
>   {
>     return EmptyNodeList.getInstance();
>   }
> 
> Add to gnu/xml/dom: EmptyNodeList.java:
> 
> package gnu.xml.dom;
> 
> import org.w3c.dom.Node;
> import org.w3c.dom.NodeList;
> 
> public final class EmptyNodeList implements NodeList
> {
> 
>   private static EmptyNodeList instance = new EmptyNodeList();
>   public static final EmptyNodeList getInstance() {return instance;}
> 
>   public EmptyNodeList () {}
> 
>   public final int getLength () {return 0;}
> 
>   public final Node item (int index) {return null;}
> 
> }

I would prefer:

final class EmptyNodeList implements NodeList
{
        static final EmptyNodeList instance = new EmptyNodeList();
        public final int getLength() {return 0;}
        public final Node item(int index) {return null;}
}

That way:
1. you avoid the unnecessary overhead of a method call (getInstance).
2. that which has no need to be public is not public.
-- 
Chris Burdess

Attachment: pgpfFzPe9eZ0b.pgp
Description: PGP signature

_______________________________________________
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath

Reply via email to