jython/java inheritance question?

M

Matt Newcomb

G'day,

Hi, I've got a java class called ChannelIteratorAlgorithm which
extends SampledChannelGroupIteratorAlgorithm.
SampledChannelGroupIteratorAlgorithm has a stub method
processSampledChannelGroup(Object[] in, Object[] out) that is
overridden by a method in the ChannelIteratorAlgorithm class.

Now, I've got a jython script that contains a class that extends the
ChannelIteratorAlgorithm class ( are you having fun yet? ) and it's
got a processSampledChannelGroup method that looks like this:

class testalg(ChannelIteratorAlgorithm):
def processSampledChannelGroup(self, inGroups, outGroups):
if (self.samplesToPass!=0):
print "samples left: %d" % self.samplesToPass
ChannelIteratorAlgorithm.processSampledChannelGroup(self,
inGroups,
outGroups)

However, each time I try to run this script I get this exception:

2003-10-29 05:26:29 ERROR:: spigot_1.handleData() encountered a fatal
Exception:Traceback (innermost last):
File "<string>", line 187, in processSampledChannelGroup
AttributeError: class
'gov.nasa.gsfc.irc.algorithms.ChannelIteratorAlgorithm' has no
attribute 'processSampledChannelGroup'

What?!?!?! Why an attribute and not a method? And why, given that
yes there is an implementation of processSampledChannelGroup in the
ChannelIteratorAlgorithm class and yes it really looks like:

protected void processSampledChannelGroup
(Object[] inputChannelDataBuffersForGroup,
Object[] outputChannelDataBuffersForGroup)

would there be an issue?

Is this a feature that I'm unaware of?

Thanks for any suggestions,

Matt Newcomb
Yerkes Observatory
Williams Bay, WI 53191
 
A

Alan Kennedy

Matt said:
I've got a jython script that contains a class that extends the
ChannelIteratorAlgorithm class ( are you having fun yet? ) and it's
got a processSampledChannelGroup method that looks like this:

class testalg(ChannelIteratorAlgorithm):
def processSampledChannelGroup(self, inGroups, outGroups):
if (self.samplesToPass!=0):
print "samples left: %d" % self.samplesToPass
ChannelIteratorAlgorithm.processSampledChannelGroup(self,
inGroups,
outGroups)

However, each time I try to run this script I get this exception:

2003-10-29 05:26:29 ERROR:: spigot_1.handleData() encountered a fatal
Exception:Traceback (innermost last):
File "<string>", line 187, in processSampledChannelGroup
AttributeError: class
'gov.nasa.gsfc.irc.algorithms.ChannelIteratorAlgorithm' has no
attribute 'processSampledChannelGroup'

What?!?!?! Why an attribute and not a method? And why, given that
yes there is an implementation of processSampledChannelGroup in the
ChannelIteratorAlgorithm class and yes it really looks like:

protected void processSampledChannelGroup
(Object[] inputChannelDataBuffersForGroup,
Object[] outputChannelDataBuffersForGroup)

would there be an issue?

Yes: The method is protected, meaning that you cannot call it directly
as you are trying to above. See the following jython doc page for more
information

http://www.jython.org/docs/subclassing.html

This might work

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

class testalg(ChannelIteratorAlgorithm):

def processSampledChannelGroup(self, inGroups, outGroups):

if (self.samplesToPass!=0):
print "samples left: %d" % self.samplesToPass
self.super__processSampledChannelGroup(inGroups, outGroups)

#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top