Hi, On Mon, May 9, 2011 at 5:52 PM, Giridhar Jayavelu <sjg...@gmail.com> wrote: > Hi, > I'm experimenting Inline::Java package in perl. I'm able to create objects > of Java class and call methods in it. > But when a method returns a value whose datatype is defined in java, then > I'm not sure how to resolve to it to perl hash or to any datatype in perl. > It gets complicated when the attributes of returned object has different > java datatypes. > > Example: > In the following example, print $nw->getData() returns > jp::com::D::E::F=HASH(0xa09e918)
Basically this tells me that the getData() method of the com.X.Y.Z class returns an object of type com.D.E.F. From there you can do most of what you can do in Java: my $def = $nw->getData() ; # Call a method of the object: my $result = $def->somePublicMethodOfTheDEFClass() ; # Access a member my $oldvalue = $def->{somePublicMemberOfTheDEFClass} ; $def->{somePublicMemberOfTheDEFClass} = $newvalue ; You should also be able to call Java's toString() method if that helps you figure out what object you are dealing with: print $def->toString(), "\n" ; If you have more specific questions please post your com.X.Y.Z and com.D.E.F code as well, it will be easier to point you in the right direction. Patrick > I'd appreciate if someone can provide tips to resolve the complex > datastructures in java while using Inline::Java. > > jpl.pl > ------ > my $nw = jp->new("com.X.Y.Z"); > print $nw->getData() ."\n"; > > > jp.pm > ------- > package jp; > use strict; use warnings; > use Inline::Java; > BEGIN { > $ENV{CLASSPATH} .= "/storage/A.jar:/storage/B.jar"; > } > use Inline ( > Java => 'STUDY', > STUDY => ['com.X.Y.Z',], > AUTOSTUDY => 1, > ); > > > sub new { > my $class = shift; > my $name = shift; > $name =~ s/\./::/g; > my $temp = "jp::$name"; > return $temp->new(@_); > } > > 1; > -- ===================== Patrick LeBoutillier Rosemère, Québec, Canada