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

/**
 * Extracts QJML data.
 */
public class QCSequence extends OCMpeerSupport
{
    /**
     * User-provided code to perform the conversion.
     */
    public void cvt(Object param) throws SAXException, IOException {
        QMSequence dm=(QMSequence)dataModel;
        //System.out.println("QCSequence");
	Conv.SubConv conv=(Conv.SubConv)context;

        QMAccess access = dm.access;
        String fieldName;
        boolean property;
        String targetClass = null;
        if (access instanceof QMField) {
            fieldName = ((QMField)access).name;
            property = false;
            if ("list".equals(((QMField)access).kind))
                targetClass = "java.util.ArrayList";
        } else if (access instanceof QMProperty) {
            fieldName = ((QMProperty)access).name;
            property = true;
            if ("list".equals(((QMProperty)access).kind))
                targetClass = "java.util.ArrayList";
        } else {// id identity ignore accessClass 
            fieldName = null;
            property = false;
        }
        addStringAttribute("fieldName",fieldName);
        // targetClass has to be initialized later if it's not a list
        // (with recursive calls on the children)
        addStringAttribute("targetClass",targetClass);
        addBooleanAttribute("property",property);
        addBooleanAttribute("typedList",false);
        // no childTargetClass
        // newClass has to be initialized later (with recursive calls
        // on the children)
        // hasAClass depends on targetClass -> initialized later
        // no childName
        addBooleanAttribute("optional",dm.optional);

        startElement("listInList");

        doCvt(dm.contentList,null);

        endElement("listInList");
    }
}
