/*
 * JBoss, Home of Professional Open Source
 * Copyright 2005, JBoss Inc., and individual contributors as indicated
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
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.6.3 $
 */
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;
   }

}