× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi everyone,

I have a question regarding the ability to cast java objects via the RPG - Java interface.

Basically, I have a java program that performs xslt transforms on some xml. To do this you need to pass a javax.xml.transform.Source object to the transformer. Now this is actually an interface and can only be created by instantiating an object that implements the interface (I believe). You can then cast the object accordingly.

I cast during construction as below:

javax.xml.transform.Source xmlSource =
               new javax.xml.transform.stream.StreamSource(xmlFile);

To prototype this method in RPG would give you something like:

* new StreamSource( File )...
D new_StreamSource...
D                 pr              O   EXTPROC(*JAVA
D                                     :'javax.xml.transform-
D                                     .stream.StreamSource'
D                                     :*CONSTRUCTOR)
D                                     Class(*JAVA
D                                     :'javax.xml.transform-
D                                     .Source')
D File                            O   Class(*JAVA
D                                     :'java.io.File')

But, of course, I get the following message if I try this: 'The return value of a Java constructor must have the same class as the method.' (I'm trying to use the StreamSource constructor to create a StreamSource object cast as a Source object)

As javax.xml.transform.Source is an interface I can't simply instantiate it can I?

Does anybody have any ideas on how I can cast a concrete object to an abstract object in RPG?

Am I missing something really simple here?

Cheers

Larry Ducie



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.