/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

// $Id: MBeanParameterInfoSer.java,v 1.4.8.1 2005/03/02 14:19:55 tdiesler Exp $

package org.jboss.net.jmx.adaptor;

import org.jboss.axis.Constants;
import org.jboss.axis.encoding.SerializationContext;
import org.jboss.axis.encoding.Serializer;
import org.jboss.axis.wsdl.fromJava.Types;
import org.w3c.dom.Element;
import org.xml.sax.Attributes;

import javax.management.MBeanParameterInfo;
import javax.xml.namespace.QName;
import java.io.IOException;


/**
 * An <code>MBeanParameterInfoSer</code> is be used to serialize
 * MBeanParameterInfo using the <code>SOAP-ENC</code>
 * encoding style.<p>
 *
 * @author <a href="mailto:a_taherkordi@users.sourceforge.net">Alireza Taherkordi</a>
 * @version $Revision: 1.4.8.1 $
 */
public class MBeanParameterInfoSer
        implements Serializer
{

   public void serialize(QName name,
                         Attributes attributes,
                         Object value,
                         SerializationContext context)
           throws IOException
   {
      if (!(value instanceof MBeanParameterInfo))
         throw new IOException("Can't serialize a " + value.getClass().getName() + " instance with a MBeanParameterInfo Serializer.");
      context.startElement(name, attributes);

      context.serialize(new QName("", "name"), null, ((MBeanParameterInfo)value).getName());
      context.serialize(new QName("", "type"), null, ((MBeanParameterInfo)value).getType());
      context.serialize(new QName("", "description"), null, ((MBeanParameterInfo)value).getDescription());

      context.endElement();
      return;


   }

   public Element writeSchema(Class aClass, Types types) throws Exception
   {
      return null;
   }

   public String getMechanismType()
   {
      return Constants.AXIS_SAX;
   }

}