type casting

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

type casting

rvjansen
Hi there!

After hundreds of lines of netrexx I am still not really secure on the
subject of typecasting. I know about type concatenation - it just does
not always work

This is the kind of problem that I have:

I want to subclass a StringTableModel from VisualCafe (which works great
with netrexx generated java code).

In java, the line is:

 ((Vector)dataVector.elementAt(row)).addElement(rowItem);

If I  convert this to:

 this.dataVector.elementAt(row).addElement(rowItem)

I get:

 37 +++    this.dataVector.elementAt(row).addElement(rowItem);
    +++                                   ^^^^^^^^^^
    +++ Error: The method 'addElement(netrexx.lang.Rexx)' cannot be
found in class 'java.lang
.Object' or a superclass

For some reason Netrexx does not see dataVector as a Vector, but is
declared as such in the superclass.

If I try:

   Vector this.editableVector.elementAt(row).addElement(Boolean.TRUE);

I get: Error: keyword expected.

When I try:

Vector(this.editableVector.elementAt(row)).addElement(Boolean.TRUE)

it compiles OK but does not seem to do much.

Your help will be much appreciated.

René Jansen

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

Re: type casting

Mike Cowlishaw-2


Hi ... just as in Java, you have to tell the compiler that the object
retrieved is of type Vector, not Object.   In Java, you'd write:

  ((Vector)dataVector.elementAt(row)).addElement(rowItem);

In NetRexx it's almost the same:

  (Vector dataVector.elementAt(row)).addElement(rowItem)

NetRexx uses the same notation for type conversions everywhere.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Mike Cowlishaw, IBM Fellow
mailto:[hidden email]  --  http://www2.hursley.ibm.com


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>