/*
 * CadXmlGenerator
 *
 *
 * Copyright (c) 2003 Kansas State University, Laboratory for the Specification,
 * Analysis, and Transformation of Software
 *
 * This software is licensed under the SAnToS Laboratory Open Academic License.  You
 * should have received a copy of the license with the distribution.  A copy can be
 * found at:
 * http://www.cis.ksu.edu/santos/license.html
 * or you can contact the lab at:
 * SAnToS Laboratory
 * 234 Nichols Hall
 * Manhattan, KS 66506, USA
 */
package edu.ksu.cis.cadena.xmlgen;

import edu.ksu.cis.cadena.frontend.cad.parser.*;

import java.io.*;

import java.util.*;


/**
 * This class starts to generate Boeing OEP XML file
 * @author Sue Li
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
public class CadXmlGenerator {
    private Scenario ast;
    private String directory;
    private String propertiesFilePath;
    private String projectName;
    private Properties display;
    private FileInputStream propertyFile;

    /**
     * Method CadXmlGenerator.
     * @param sc - current scenario
     * @param outputDir - path in which to create MC__<project name>.xml
     * @param projectName the name of the project
     * @param propertiesFile - reference of the property file
     * toDisplayNames.properties - for basicsp
     * toDisplayNamesModal.properties - for modalsp
     * toDisplayNamesBasicmp.properties - for basicmp
     * toDisplayNamesMultiratemp.properties - for multiratemp
     */
    public CadXmlGenerator(Scenario sc, String outputDir, String projectName,
        FileInputStream propertyFile) {
        ast = sc;
        directory = outputDir;
        this.projectName = projectName;
        this.propertyFile = propertyFile;
        display = new Properties();
    }

    public void start() {
        if (ast == null) {
            System.out.println("ast is null!");
            System.exit(0);
        }

        try {
            display.load(propertyFile);

            XMLGeneratorOld xml =
                new XMLGeneratorOld(directory + File.separator + "MC__"
                    + projectName + ".xml", display);
            ast.apply(xml, "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


syntax highlighted by Code2HTML, v. 0.9.1