Jay,

To Perl, a Vector is just a regular Java object. You can manipulate it using
that same API as in Java:

=====
use Inline (
    Java => <<'END',
import java.util.* ;

class test {
       static public Vector v(){
               Vector v = new Vector() ;
               v.add("abc") ;
               v.add("123") ;
               return v ;
       }
}
END
       AUTOSTUDY => 1
) ;

my $v = test->v() ;
print $v->get(0) . "\n" ;
print $v->get(1) . "\n" ;
$v->add("perl") ;
print $v->get(2) . "\n" ;
=====

Patrick

On 11/7/06, Jay Strauss <[EMAIL PROTECTED]> wrote:
Hi,

I'm using Inline::Java 0.50_92 upon Linux

I can't seem to figure out how to access a java Vector.  I've searched
the archives and the doc but have found no crumbs.

An attribute within a class is defined like:
public Vector m_comboLegs = new Vector();

Each element in the Vector should be a comboLeg object (shown way below).

When I get the object back from Inline::Java I would have thought I'd
just access it like a regular ref to array but thats not working like:

$object->[0]

So how do I access each element of a vector from within Perl?

Thanks
Jay

package com.ib.client;
import java.util.Vector;

public class ComboLeg {
    public final static int   SAME = 0;   // open/close leg value is
same as combo
    public final static int   OPEN = 1;
    public final static int   CLOSE = 2;
    public final static int   UNKNOWN = 3;

    public int                m_conId;
    public int                m_ratio;
    public String             m_action; // BUY/SELL
    public String             m_exchange;
    public int                m_openClose;

    public ComboLeg() {
        m_conId = 0;
        m_ratio = 0;
        m_openClose = 0;
    }

    public ComboLeg(int p_ConId, int p_Ratio, String p_Action, String
p_exchange, int p_openClose) {
        m_conId = p_ConId;
        m_ratio = p_Ratio;
        m_action = p_Action;
        m_exchange = p_exchange;
        m_openClose = p_openClose;
    }
}



--
=====================
Patrick LeBoutillier
Laval, Québec, Canada

Reply via email to