users@jax-rpc.java.net

Re: serialize and deserialize interfaces/abstract classes

From: John L. Fjellstad <john_at_PRODEXNET.COM>
Date: Tue, 22 Oct 2002 17:26:37 -0700

Doug Kohlert wrote:
> John, I have successfully used the following interface with wscompile.
> What does your Foo interface look like?
>
> public interface FooInterface {
>
> public long getL();
> public void setL(long l);
> public short getI2();
> public void setI2(short i2);
> public boolean equals(Object obj);
> }

public interface Foo
{
     public int getType();
     public int intValue();
     public double doubleValue();
     public long timeValue();
     public String stringValue();
     public boolean booleanValue();
     public boolean equals(Foo val);
     public Object clone();
}

so the subclasses would be
public class FooInt implements Foo
{
        private int val;

        public FooInt( int val )
        {
                this.val = val;
        }

        public int getType()
        {
                return FooConst.INTEGER;
        }

        public int intValue()
        {
                return val;
        }

        public double doubleValue()
        {
                throws InvalidValueType(); // some custom exception
        }
        ....
        public FooInt()
        {
        }

        public void setVal( int val )
        {
                this.val = val;
        }

        public int getVal()
        {
                return val;
        }
}


--
John L. Fjellstad,  Software Engineer
ProdEx Technologies
14471 Big Basin Way, Suite E
Saratoga, CA 95070
USA
Phone: (408) 872-3100