<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
I would have thought that it should return some Collection
sub-class, e.g. List<br>
<br>
Since we're cleaning things up in JDOM2, now seems like a good time
to make a change like that.<br>
<br>
On 2012-03-15 23:59, Rolf Lear wrote:
<blockquote cite="mid:4F626651.1010705@tuis.net" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
Hi Craig.<br>
<br>
getDescendants returns an Iterator<Element> not an
Iterable<Element><br>
<br>
Now that I think about it, it is a mess, but, that's because JDOM
1.x returned an iterator.<br>
<br>
Technically your code should be:<br>
<br>
for (Iterator<Element> it =root.getDescendants(tableFilter);
it.hasNext(); ) {<br>
<div id=":126"> tableCount++;<br>
}<br>
<br>
I wonder whether I can make an 'Iterable' return value too....
it makes sense to, but I can't change the current return value
for getDescendants without breaking compatibility...<br>
<br>
<br>
suggestions?<br>
<br>
Rolf<br>
</div>
<br>
<br>
<br>
On 15/03/2012 3:59 PM, Craig Noah wrote:
<blockquote
cite="mid:CALi3K=Lkod5FdEZ2TCX7jj36AN_R5TYrgxUqco6GFNfxCt9LdQ@mail.gmail.com"
type="cite">I've downloaded the latest JDom2 beta today and am
working to incorporate it into some new code. I am developing
against Java6, so I would expect iterators to work. However,
the following code fails to compile (with JDom2 includes):<br>
<br>
SAXBuilder sax = new SAXBuilder();<br>
Document xml = sax.build (source); // source is a File object<br>
Element root = xml.getRootElement();<br>
ElementFilter tableFilter = new ElementFilter ("Table");<br>
int tableCount = 0;<br>
for (Element table : root.getDescendants(
<div id=":126">tableFilter)) {<br>
tableCount++;<br>
}<br>
<br>
The compile-time error that I get states, "Can only iterate
over an array or an instance of java.lang.Iterable". Since
Element.getDescendants (Filter<F>) returns a
java.util.Iterator<F>, I would expect my code to compile
and work. What am I missing?<br>
<br>
Sincerely,<br>
Craig</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
To control your jdom-interest membership:
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com">http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com</a></pre>
</blockquote>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
To control your jdom-interest membership:
<a class="moz-txt-link-freetext" href="http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com">http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com</a></pre>
</blockquote>
<br><br><br><hr><font size="-2" color=808080>Disclaimer: <a href="http://www.peralex.com/disclaimer.html">http://www.peralex.com/disclaimer.html</a><br><br>
</body>
</html>