You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Marella, Purush" <pm...@ti.com> on 2003/12/18 00:27:56 UTC

Question about custom deserializer

I have a custom serializer and deserializer.  The serializer is working
fine, and I can see the XML for all my data.  For the deserialization
process, my onStartChild method is listed below.  I can successfully
deserialize the basic data types like String, int, boolean but am having
trouble with lists.  I have a list of "ClassPeriodImpl" objects and can hand
it off to its own deserializer, but once it is deserialized, how do I add it
back to the parent object?

 

Any help is appreciated.

 

Purush.

 

 

    public SOAPHandler onStartChild(String nameSpace, String localName,
String prefix, Attributes attributes, DeserializationContext context) throws
SAXException

    {

        System.out.println("onStartChild called " + localName);

 

        QName typeQName = null;

        Deserializer deser = null;

 

        if ("name".equals(localName))

        {

            typeQName = Constants.XSD_STRING;

        }

        else if ("id".equals(localName))

        {

            typeQName = Constants.XSD_INT;

        }

        else if ("active".equals(localName))

        {

            typeQName = Constants.XSD_BOOLEAN;

        }

        else if ("enabled".equals(localName))

        {

            typeQName = Constants.XSD_INT;

        }

        else if ("children".equals(localName))

        {

            typeQName = new QName("http://roster.pet.nav.com",
"RosterElement");

        }

        else if ("item".equals(localName))

        {

            // is a classperiod

            typeQName = new QName("http://ClientProxy.roster.pet.nav.com",
"ClassPeriodImpl");

        }

 

        deser = context.getDeserializerForType(typeQName);

        try

        {

            FieldTarget target = new FieldTarget(value, localName);

            deser.registerValueTarget(target);

        }

        catch (NoSuchFieldException nsfe)

        {

            System.out.println("Exception caught: " + nsfe);

            throw new SAXException(nsfe);

        }

 

        if (deser == null)

        {

            throw new SAXException("No deserializer for " + typeQName);

        }

 

        return (SOAPHandler) deser;

    }