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
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Classpath mailing list Classpath@gnu.org http://lists.gnu.org/mailman/listinfo/classpath