Your method is the way I’ve always looped Java iterators in the past, with one 
exception:  I’ve always created the variable for the iterator before using it 
in the loop.  What happens with:

<cfset resultIterator = result.iterator()>
<cfloop condition="resultIterator.hasNext()">
   <cfdump var="#result.iterator().next()#">
</cfloop>

I’m not good with the “under-the-hood” java of what is happening here, but it 
seems to me that by placing the your result variable in the loop, you are 
re-starting the loop with each sequence.

HTH,
Jon

On Dec 4, 2013, at 6:19 PM, Tom McNeer <[email protected]> wrote:

> 
> Hi,
> 
> I am attempting to use Google's libphonenumber library to find, match and
> parse phone numbers within text strings.
> 
> I load the libphonenumber jar using Javaloader and create an instance of
> the PhoneUtil class.
> 
> I create a test string of:
> 
> "Here is one phone number (212) 555-1212 and here is a second 312-555-1212
> and a third +1 404 555 1212"
> 
> I then call PhoneUtil.findNumbers(testString,"US"). This should return
> matches of phone numbers in pretty much any recognized US format within the
> string.
> 
> The return from the findNumbers() method has an iterator() method. So it
> seems to me I should be able to loop and dump the matched objects, with
> something like:
> 
> <cfloop condition="result.iterator().hasNext()">
>    <cfdump var="#result.iterator().next()#">
> </cfloop>
> 
> However, this creates what appears to be an infinite loop. I'm guessing
> it's because the loop isn't really looping through the iterator's
> collection, but rather simply reading a static "true" from the hasNext()
> initial value, and always dumping the first entry in the iterator's
> collection.
> 
> Of course, I know so little about Java, I could be completely wrong.
> 
> But if one of you folks who understands better than I how to manipulate
> Java within ColdFusion could point out the error of my ways, I'd certainly
> appreciate it.
> 
> 
> 
> -- 
> Thanks,
> 
> Tom
> 
> Tom McNeer
> MediumCool
> http://www.mediumcool.com
> 1735 Johnson Road NE
> Atlanta, GA 30306
> 404.589.0560
> 
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:357284
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to