package com.jxml.quick.util.qjml2java;
import com.jxml.quick.*;
import com.jxml.quick.ocm.*;
import org.xml.sax.*;
import java.io.*;
import java.util.*;
import com.jxml.protocol.*;

public class Preferences extends OCMsinkSupport
{
    	public boolean printQAware = false;

    	public boolean setParents = false;

    	/**
    	 * useful for debugging
    	 */
    	public boolean printPrint = false;

    	public boolean printXPath = false;

    	public boolean printFullConst = true;

    	public boolean oneNewClass = false;
        
        /**
         * convenience methods (add, getXXX(i), ...)
         */
    	public boolean printMoreMethods = true;

	public String genPackage="";

	// 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 SubPreferences(prior);
		prior.put(this,base);
		return base;
	}

	public class SubPreferences extends OCMsinkSupport.SubSinkSupport
	{
		public SubPreferences(HashMap prior)
		{
			super(prior);
		}

		// Implement SubSink method.
		public String express()
			throws SAXException, IOException
		{
			expressFile();
			return "";
		}

		// Implement SubSink method.
	        public void expressFile()
	            throws SAXException,IOException
		{
			QDoc q2jDoc=getInputDoc();
            		Element root = (Element)q2jDoc.getRoot();
            		if ("".equals(properties.get("genPackage").toString()))
                		root.genPackage = null;
			else
                		root.genPackage = properties.get("genPackage").toString();
            		root.printClone = Boolean.valueOf(properties.get("printClone").toString()).booleanValue();
            		root.printQAware = Boolean.valueOf(properties.get("printClone").toString()).booleanValue();
            		root.setParents = Boolean.valueOf(properties.get("printQAware").toString()).booleanValue();
            		root.printPrint =Boolean.valueOf(properties.get("setParents").toString()).booleanValue();
            		root.printXPath =Boolean.valueOf(properties.get("printPrint").toString()).booleanValue();
            		root.printFullConst =Boolean.valueOf(properties.get("printFullConst").toString()).booleanValue();
            		root.printMoreMethods =Boolean.valueOf(properties.get("printMoreMethods").toString()).booleanValue();
            		root.oneNewClass =Boolean.valueOf(properties.get("oneNewClass").toString()).booleanValue();

			String folderPath=".";
			if (!"".equals (docName))
				folderPath=docName;
                        
                        root.init();
            		root.makeAllFiles(folderPath);
		}
	}
}
