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 15:59:06 +0000
On 31/10/06, Ed Davies <edavies AT nildram.co.uk> wrote:
Steve Loughran wrote:
> ...
> I make my iterators implement iterable instead:
> public Iterator<Node> iterator() {
> return this;
> }
> ...
Clever way to save garbage collection of a separate Iterable
object, but shouldn't an Iterable return a new Iterator each
time iterator() is called?
That's precisely why I think what I am doing consistutes an abuse. :)
I realise that's not likely to happen in your common usage
pattern but, still, wouldn't it be safer to at least throw an
exception if iterator() is called twice? That wouldn't guard
against a direct cast from Iterable to Iterator, of course,
but that would be cheating.
Good point. I could store a reference to myself in the constructor,
return that the first time and set it to null. Second time round:NPE.
-
[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
-
Re: [XOM-interest] adding NamespaceContext.getNamespaces(),
Wolfgang Hoschek, 10/31/2006
-
Re: [XOM-interest] adding NamespaceContext.getNamespaces(),
Elliotte Harold, 10/31/2006
- Re: [XOM-interest] adding NamespaceContext.getNamespaces(), Christian Vest Hansen, 10/31/2006
-
Re: [XOM-interest] adding NamespaceContext.getNamespaces(),
Elliotte Harold, 10/31/2006
-
Re: [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.