jython/java inheritance question?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt Newcomb

    jython/java inheritance question?

    G'day,

    Hi, I've got a java class called ChannelIterator Algorithm which
    extends SampledChannelG roupIteratorAlg orithm.
    SampledChannelG roupIteratorAlg orithm has a stub method
    processSampledC hannelGroup(Obj ect[] in, Object[] out) that is
    overridden by a method in the ChannelIterator Algorithm class.

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

    class testalg(Channel IteratorAlgorit hm):
    def processSampledC hannelGroup(sel f, inGroups, outGroups):
    if (self.samplesTo Pass!=0):
    print "samples left: %d" % self.samplesToP ass
    ChannelIterator Algorithm.proce ssSampledChanne lGroup(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.handle Data() encountered a fatal
    Exception:Trace back (innermost last):
    File "<string>", line 187, in processSampledC hannelGroup
    AttributeError: class
    'gov.nasa.gsfc. irc.algorithms. ChannelIterator Algorithm' has no
    attribute 'processSampled ChannelGroup'

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

    protected void processSampledC hannelGroup
    (Object[] inputChannelDat aBuffersForGrou p,
    Object[] outputChannelDa taBuffersForGro up)

    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
  • Alan Kennedy

    #2
    Re: jython/java inheritance question?

    Matt Newcomb wrote:[color=blue]
    > I've got a jython script that contains a class that extends the
    > ChannelIterator Algorithm class ( are you having fun yet? ) and it's
    > got a processSampledC hannelGroup method that looks like this:
    >
    > class testalg(Channel IteratorAlgorit hm):
    > def processSampledC hannelGroup(sel f, inGroups, outGroups):
    > if (self.samplesTo Pass!=0):
    > print "samples left: %d" % self.samplesToP ass
    > ChannelIterator Algorithm.proce ssSampledChanne lGroup(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.handle Data() encountered a fatal
    > Exception:Trace back (innermost last):
    > File "<string>", line 187, in processSampledC hannelGroup
    > AttributeError: class
    > 'gov.nasa.gsfc. irc.algorithms. ChannelIterator Algorithm' has no
    > attribute 'processSampled ChannelGroup'
    >
    > What?!?!?! Why an attribute and not a method? And why, given that
    > yes there is an implementation of processSampledC hannelGroup in the
    > ChannelIterator Algorithm class and yes it really looks like:
    >
    > protected void processSampledC hannelGroup
    > (Object[] inputChannelDat aBuffersForGrou p,
    > Object[] outputChannelDa taBuffersForGro up)
    >
    > would there be an issue?[/color]

    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



    This might work

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

    class testalg(Channel IteratorAlgorit hm):

    def processSampledC hannelGroup(sel f, inGroups, outGroups):

    if (self.samplesTo Pass!=0):
    print "samples left: %d" % self.samplesToP ass
    self.super__pro cessSampledChan nelGroup(inGrou ps, outGroups)

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

    HTH,

    --
    alan kennedy
    -----------------------------------------------------
    check http headers here: http://xhaus.com/headers
    email alan: http://xhaus.com/mailto/alan

    Comment

    Working...