I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2011-01-08 15:37:47.320402-08 by ninuzzo
iterate through a collection
I've read with interest about the necessity of type casting here:
http://search.cpan.org/~patl/Inline-Java-0.52/Java.pod#TYPE_CASTING
I am trying to apply the same recipe to traverse a collection returned by WWW::HtmlUnit but casting did not help. The problem lies in accessing a private inner class through an Inline::Java link. In fact the error I get is:
You are not allowed to invoke method toArray in class java.util.Collections$UnmodifiableRandomAcces +sList: Class InlineJavaUserClassLink can not access a member of class java.util.Collections$Unmodi +fiableCollection with modifiers "public"
Found below a bit of code to reproduce my problem. Is there any fix for that or an alternative way to implement something like the Java enhanced for loop with Inline::Java?
use WWW::HtmlUnit; use Inline::Java 'cast'; my $browser = WWW::HtmlUnit->new(); my $page = $browser->getPage( 'http://google.com/search?q=God' ); my $table = $page->getHtmlElementById('nav'); my $rows; # Here I get the above error... $rows = $table->getRows( )->toArray; # This does not work either. I think because UnmodifiableRandomAccessList # is defined as a private (not public) inner class of java.util.Collections. $rows = cast('java.util.Collections$UnmodifiableList', $table->getRows( ))->toArray;
Direct Responses: 13135 | 13136 | Write a response