// copyright=> http://www.jxml.com/mdsax/License.txt

package com.jxml.quick.util.qdml2qjml;
import com.jxml.quick.*;
import com.jxml.quick.ocm.*;
import com.jxml.quick.model.qjml.*;
import java.util.*;

public class QDML2QJML extends OCMcontextSupport
{

	// implements an OCMbase method
	public OCMbase.SubBase spawn(HashMap prior)
	{
		OCMbase.SubBase rv=(OCMbase.SubBase)prior.get(this);
		if (rv!=null)
			return rv;
		OCMbase.SubBase base=new SubQdml2Qjml(prior);
		prior.put(this,base);
		return base;
	}

	public class SubQdml2Qjml extends OCMcontextSupport.SubContextSupport
	{
		public String pckg="";

		public int pID=1;
		
		public String currentCoinLabel;
			
		public int pos;

		public ArrayList coins;

		QMQJML orig=null;

		public SubQdml2Qjml(HashMap prior)
		{
			super(prior);
		}

		public Object dataModelRoot(QDoc inputDoc)
		{
			orig=(QMQJML)inputDoc.getRoot();
			return orig.clone();
		}

		public String tagToClass(String tag)
		{
			String s=tag.substring(0,1).toUpperCase()+tag.substring(1);
			s=s.replace('.','_');
			if("".equals(pckg))
				return s;
			else
				return pckg+"."+s;
		}

		public String labelToProperty(String label)
		{
			String s=label.replace('.','_')+"_"+(pID++);
			String s2=s.substring(1,2);
			if (!s2.equals(s2.toUpperCase()))
			{
				s=s.substring(0,1).toLowerCase()+s.substring(1);
			}
			return s;
		}

		/**
		 * Sets the config properties
		 */
		public void setProperties(Map properties)
		{
			super.setProperties(properties);
			Object p=properties.get("package");
			if (p!=null)
				pckg=p.toString();
		}
	}
}
