classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gnu.xml.dom.DomText implements Text and NodeList.


From: Mark Wielaard
Subject: Re: gnu.xml.dom.DomText implements Text and NodeList.
Date: Wed, 04 Jan 2006 10:14:02 +0100

Hi,

On Wed, 2006-01-04 at 07:16 +0000, Chris Burdess wrote:
> > My proposed solution is:
> > 
> > Add to gnu.xml.dom.DomText:
> > 
> > import org.w3c.dom.NodeList;
> > 
> >   /**
> >    * Returns an EmptyNodeList.
> >    *
> >    * @author Pedro Izecksohn
> >    */
> >   public NodeList getChildNodes()
> >   {
> >   return (NodeList) new EmptyNodeList();
> >   }
> > 
> > Add to gnu/xml/dom/ the file EmptyNodeList.java:
> > 
> > package gnu.xml.dom;
> > 
> > import org.w3c.dom.Node;
> > import org.w3c.dom.NodeList;
> > 
> > /**
> >  * @author Pedro Izecksohn
> >  */
> > 
> > public final class EmptyNodeList implements NodeList
> > {
> > 
> >   public EmptyNodeList () {}
> > 
> >   public final int getLength () {return 0;}
> > 
> >   public final Node item (int index) {return null;}
> > 
> > }
> 
> That looks absolutely correct.

Thanks Pedro. Some small suggestions for improvements.
It really should be a static inner class (since no state of the outer
class is used). 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. BTW. The cast in getChildNode() isn't necessary since
EmptyNodeList already is a NodeList.

Cheers,

Mark

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]