//
// https://www.ramecera.it/myscrewdriver.html
// e-mail: screwdriver@ramecera.it
//
/* This program and the accompanying materials are made available under
 * the terms of the Eclipse Public License v1.0 which accompanies this
 * distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html */
package it.ramecera.screwdriver.component;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;

import it.ramecera.salad.everyday.Candies;
import it.ramecera.salad.everyday.ExactException;
import it.ramecera.salad.file.Equipment;
import it.ramecera.screwdriver.CandyScrew;
import it.ramecera.screwdriver.Markup;
import it.ramecera.screwdriver.Skill;
import it.ramecera.screwdriver.Train;

/** @author M. Maglioni */
final public class Tiles_xml extends FileComponent {

	/** @param skill together with the descriptive data of the
	 * @param snippetG application */
	public Tiles_xml(Skill skill, String snippetG) {
		super();
		this.skill = skill;
		this.snippetG = snippetG;
	}

	/** @throws ExactException exception specified by a numeric code */
	@Override
	public void synthesis(HashMap<String, Markup> markupE,
			List<Train> trainE, CandyScrew candyScrew)

			throws FileNotFoundException, IOException, ExactException {

		String[] qualifierE = skill.tilesVersion.split("\\x2e");
		String g = skill.candies.snippetsYS + "testaTiles_"
				+ qualifierE[0] + ".txt";
		producedMaterial = Equipment.oneString(g) + Candies.LF;
		for (int i = 0; i < markupE.get("edefn").recurrenceE
				.size(); i++) {
			String[] s = (String[]) markupE.get("edefn").recurrenceE
					.get(i).locomotor.substance;
			producedMaterial += Candies.TABS + "<definition name = \""
					+ s[0] + "/" + s[1]
					+ "\"  template=\"/WEB-INF/views/" + s[0] + "/"
					+ s[1] + "." + s[2] + "\">" + Candies.LF;
			producedMaterial += Candies.TABS + "</definition>"
					+ Candies.LF;
		}
		producedMaterial += "</tiles-definitions>";
	}

	/* written only to comply with the abstract class FileComponent */
	@SuppressWarnings("javadoc")
	@Override
	/** @param markupE the list of markups
	 * @param skill together with the descriptive data of the
	 *        application
	 * @param file basket where the deleted files are moved
	 * @throws ExactException exception specified by a numerical code */
	public void directory(HashMap<String, Markup> markupE)

			throws ExactException {

	}
}
