Thanks Jason,

Your example helped with coerce but the BO SDK problem I'm trying to
solve must not be about integer. The getID() method returns integer so
this whole thing looked odd to begin with. Maybe just to be extra sure
its an int?
I'll keep hacking at it.

Mike
-----Original Message-----
From: Jason Stelzer [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 18, 2008 6:37 PM
To: Vanole, Mike
Cc: inline@perl.org
Subject: Re: Inline Java Integer question

Inline::Java does a pretty good job of auto-marshalling primitive  
types (from java.lang.*) for you without you having to do much about  
it yourself. In fact, Integer is one of those types that should 'just  
work'. However, to illustrate how you'd go about coercing the type,  
this example seems to work (I just changed the example from the pod to  
use Integer rather than int):

use strict;
use Inline  Java => <<'END_OF_JAVA_CODE' ,STUDY =>  
['java.lang.Integer'],;
              class Pod_alu {
                 public Pod_alu(){
                 }

                 public Integer add(Integer i, Integer j){
                    return i + j ;
                 }

                 public int subtract(Integer i, Integer j){
                    return i - j ;
                 }
                public void showInteger(Integer i){
                  System.out.println("Integer is " + i);
                }
              }

END_OF_JAVA_CODE

my $alu = new Pod_alu() ;
print($alu->add(9, 16) . "\n") ; # prints 25
print($alu->subtract(9, 16) . "\n") ; # prints -7
my $int = Inline::Java::coerce('java.lang.Integer', 32);
print "Int is a $int\n";
$alu->showInteger($int);
$int = 400;
print "Int is a $int\n";
$alu->showInteger($int);





On Jul 18, 2008, at 5:00 PM, Vanole, Mike wrote:

> Was: (Inline Integer question)
>
> Re: Inline Java and the Business Objects SDK
>
> I'm stuck on what I think it an integer input problem.
>
> I need to make sure that I'm replicating this Java:
>
> Integer groupInt = new Integer(iGroup.getID());
>
> I can get a value from iGroup.getID(). That value is "2"
>
> And I make sure it's an integer (perl):
>
> $groupInt = int($iGroup->getID());
>
> But I don't think this is a correct way to translate the Java above
>
> I think I need coerce, but I couldn't make that work.
>
> What is the correct way to ensure $groupInt is a Java integer?
>
> Thanks,
> Mike
>

--
Jason Stelzer
[EMAIL PROTECTED]



Reply via email to