develooper Front page | perl.inline | Postings from May 2011

resolving java datatypes

Thread Next
From:
Giridhar Jayavelu
Date:
May 9, 2011 16:00
Subject:
resolving java datatypes
Message ID:
BANLkTimrTucjBrhuvdPgXau=AZgnP720ZQ@mail.gmail.com
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)

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;


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About