/*
 * 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.axis;

import org.jboss.axis.deployment.wsdd.WSDDException;
import org.jboss.axis.deployment.wsdd.WSDDTypeMapping;
import org.jboss.axis.utils.LockableHashtable;
import org.w3c.dom.Element;

import java.util.Map;

/**
 * A parameterizable typemapping.
 * @author <a href="mailto:Christoph.Jung@infor.de">Christoph G. Jung</a>
 * @created 06.04.2002
 * @version $Revision: 1.2.2.4 $
 */


public class TypeMapping extends WSDDTypeMapping
{

   //
   // Attributes
   //
	
   /** carries the options */
   protected LockableHashtable parameters = new LockableHashtable();

   //
   // Constructors 
   //
	
   /**
    * Constructor for TypeMapping.
    */
   public TypeMapping()
   {
      super();
   }

   /**
    * Constructor for TypeMapping.
    * @param e
    * @throws WSDDException
    */
   public TypeMapping(Element e) throws WSDDException
   {
      super(e);
      readParams(e);
   }

   //
   // protected helpers
   //
	
   /** reads out the additional parameter elements */
   protected void readParams(Element e)
   {
      Element[] paramElements = getChildElements(e, "parameter");

      for (int i = 0; i < paramElements.length; i++)
      {
         Element param = paramElements[i];
         String pname = param.getAttribute("name");
         String value = param.getAttribute("value");
         String locked = param.getAttribute("locked");
         parameters.put(pname,
                 value,
                 (locked != null && locked.equalsIgnoreCase("true")));
      }

   }

   //
   // public API
   //
	
   /** returns the set of parameters */
   public Map getParametersTable()
   {
      return parameters;
   }

} // TypeMapping
