//
// 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.Cst;
import it.ramecera.screwdriver.Markup;
import it.ramecera.screwdriver.Skill;
import it.ramecera.screwdriver.Train;

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

	/** @param skill application main data
	 * @param snippetG name of the file containing the snippet */
	public Service_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 {

		Train t = markupE.get("hdefrail").recurrenceE.get(skill.railK);
		skill.springPropertiesG = skill.candies.snippetsYS + snippetG;
		producedMaterial = Equipment.oneString(
				skill.springPropertiesG) + Candies.LF;
		producedMaterial += Candies.TABS
				+ "<context:component-scan base-package=\""
				+ Candies.LF;
		producedMaterial += Candies.TABS + Candies.TABS + skill.pckg
				+ "." + Cst.RAIL + t.locomotor.text + ";" + Candies.LF;
		if (skill.springSecurity) {
			producedMaterial += Candies.TABS + Candies.TABS
					+ skill.pckg + ".web.authentication" + ";"
					+ Candies.LF;
		}
		producedMaterial += Candies.TABS + "\" />" + Candies.LF;
		producedMaterial += "</beans>";
	}

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

			throws ExactException {

	}
}
