xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
Re: [XOM-interest] adding an iterator() method to nodes
- From: "Steve Loughran" <steve.loughran AT gmail.com>
- Cc: xom-interest AT lists.ibiblio.org
- Subject: Re: [XOM-interest] adding an iterator() method to nodes
- Date: Tue, 31 Oct 2006 14:40:17 +0000
On 31/10/06, Randall R Schulz <rschulz AT sonic.net> wrote:
Don't forget to add the "implements Iterable" clause to enable the
concise iteration syntax.
I'm not so sure about that; I think that's a real design error there.
Because an object can only have return one iterator, something like an
element has to decide if it will be iterable over its child nodes,
elements, attributes or namespaces.
I make my iterators implement iterable instead:
public Iterator<Node> iterator() {
return this;
}
This lets you
for(Element e:root.elementIterator() ) { ... }
and
for(Attribute e:root.attributeIterator() ) { ... }
This will probably be considered an abuse of the interface come the
next edition of Effective Java, but, well, tough.
-steve
-
[XOM-interest] adding an iterator() method to nodes,
Steve Loughran, 10/31/2006
-
Re: [XOM-interest] adding an iterator() method to nodes,
Randall R Schulz, 10/31/2006
-
Re: [XOM-interest] adding an iterator() method to nodes,
Steve Loughran, 10/31/2006
- Re: [XOM-interest] adding an iterator() method to nodes, Randall R Schulz, 10/31/2006
-
Re: [XOM-interest] adding an iterator() method to nodes,
Ed Davies, 10/31/2006
-
Re: [XOM-interest] adding an iterator() method to nodes,
Steve Loughran, 10/31/2006
-
Re: [XOM-interest] adding an iterator() method to nodes,
Christian Vest Hansen, 10/31/2006
- Re: [XOM-interest] adding an iterator() method to nodes, Michael Kay, 10/31/2006
- Re: [XOM-interest] adding an iterator() method to nodes, Steve Loughran, 10/31/2006
-
Re: [XOM-interest] adding an iterator() method to nodes,
Christian Vest Hansen, 10/31/2006
-
Re: [XOM-interest] adding an iterator() method to nodes,
Steve Loughran, 10/31/2006
-
Re: [XOM-interest] adding an iterator() method to nodes,
Steve Loughran, 10/31/2006
-
Re: [XOM-interest] adding an iterator() method to nodes,
Elliotte Harold, 10/31/2006
-
Re: [XOM-interest] adding an iterator() method to nodes,
Steve Loughran, 10/31/2006
-
[XOM-interest] adding NamespaceContext.getNamespaces(),
Wolfgang Hoschek, 10/31/2006
- Re: [XOM-interest] adding NamespaceContext.getNamespaces(), Elliotte Harold, 10/31/2006
-
[XOM-interest] adding NamespaceContext.getNamespaces(),
Wolfgang Hoschek, 10/31/2006
-
Re: [XOM-interest] adding an iterator() method to nodes,
Steve Loughran, 10/31/2006
-
Re: [XOM-interest] adding an iterator() method to nodes,
Randall R Schulz, 10/31/2006
Archive powered by MHonArc 2.6.24.