help with constructors

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

help with constructors

eric.olander
Here's a fragment of code I'm playing with:

package Soap;

import scala.xml.{Elem, Node, NamespaceBinding};

object SoapNamespace extends NamespaceBinding("env",
"http://www.w3.org/2003/05/soap-envelope", scala.xml.TopScope)

class SoapElement(label : String, attributes : scala.xml.MetaData, children :
scala.xml.Node*) extends Elem("env", label, attributes, SoapNamespace, children)
{
 
}


I get a type mismatch error (found scala.xml.Node* required: scala.xml.Node) on
the definition of SoapElement.  I understand the problem, but I'm sort of stuck
for a better way to code this.  I can do away with the SoapElement class
entirely - it's just a convenience class my other classes extend so all the soap
elements will have the same prefix and namespace, but I'd like to avoid code
duplication as much as possible.  Anyway, in general, is it possible for a
subclass constructor to pass a type of someobject* to its superclass?  Thanks
for any help.

-Eric

Reply | Threaded
Open this post in threaded view
|

Re: help with constructors

Michal Politowski
On Mon, 15 May 2006 02:20:44 +0000, Eric Olander wrote:
[...]
> duplication as much as possible.  Anyway, in general, is it possible for a
> subclass constructor to pass a type of someobject* to its superclass?

I think it is possible in the same way as when callling a method with *-parameter using an explicit
sequence object. Namely:

class SoapElement(label: String, attributes: scala.xml.MetaData, children: scala.xml.Node*)
      extends Elem("env", label, attributes, SoapNamespace, children:_*)

Note the _* type annotation.

--
Michał Politowski
Talking has been known to lead to communication if practiced carelessly.
Reply | Threaded
Open this post in threaded view
|

Re: help with constructors

eric.olander
Michal Politowski <mpol <at> charybda.icm.edu.pl> writes:


> class SoapElement(label: String, attributes: scala.xml.MetaData, children:
scala.xml.Node*)
>       extends Elem("env", label, attributes, SoapNamespace, children:_*)
>
> Note the _* type annotation.
>


That fixed it.  Thanks a lot!  Any interest out there in a Soap handling module
once I get this finished?

-Eric

Reply | Threaded
Open this post in threaded view
|

RE: Re: help with constructors

Judson, Ross
In reply to this post by eric.olander
I would be.  Over the weekend I used Axis to create some Java stubs,
which I then compiled and invoked from Scala.  It would be nice to have
a pure Scala solution to that problem instead...

RJ

-----Original Message-----
From: news [mailto:[hidden email]] On Behalf Of Eric Olander
Sent: Monday, May 15, 2006 10:15 AM
To: [hidden email]
Subject: Re: help with constructors

That fixed it.  Thanks a lot!  Any interest out there in a Soap handling
module once I get this finished?

-Eric

Reply | Threaded
Open this post in threaded view
|

Re: help with constructors

Burak Emir
In reply to this post by eric.olander
Hi Eric,

yes please do share your stuff! It might also provide some hints on
where to go with the data-binding tool (schema2src).

cheers,
Burak

Eric Olander wrote:

>
>That fixed it.  Thanks a lot!  Any interest out there in a Soap handling module
>once I get this finished?
>
>-Eric
>
>  
>


--
Burak Emir

http://lamp.epfl.ch/~emir