/**
 * $Id:MandelbrotImageConfigXMLExporterRuntime.java.tmp 139 2007-07-05 10:09:58Z andreamedeghini $
 *
 * Copyright (C) 2006 Andrea Medeghini
 * 
 */
package net.sf.jame.mandelbrot.extensions.image;

import net.sf.jame.core.xml.XMLExportException;
import net.sf.jame.core.xml.XMLExporter;
import net.sf.jame.core.xml.XMLNodeBuilder;
import net.sf.jame.mandelbrot.MandelbrotConfigXMLExporter;
import net.sf.jame.twister.xmlexport.extension.ExtensionConfigXMLExporterExtensionRuntime;
import org.w3c.dom.Element;

/**
 * @author Andrea Medeghini
 */
public class MandelbrotImageConfigXMLExporterRuntime extends ExtensionConfigXMLExporterExtensionRuntime {
	/**
	 * @see net.sf.jame.twister.xmlexport.extension.ExtensionConfigXMLExporterExtensionRuntime#createXMLExporter()
	 */
	@Override
	public XMLExporter<MandelbrotImageConfig> createXMLExporter() {
		return new MandelbrotImageConfigXMLExporter();
	}

	public class MandelbrotImageConfigXMLExporter extends XMLExporter<MandelbrotImageConfig> {
		/**
		 * @see net.sf.jame.core.xml.XMLExporter#exportToElement(java.lang.Object, net.sf.jame.core.xml.XMLNodeBuilder)
		 */
		@Override
		public Element exportToElement(final MandelbrotImageConfig config, final XMLNodeBuilder builder) throws XMLExportException {
			final Element element = this.createElement(builder, MandelbrotImageConfig.CLASS_ID);
			exportProperties(config, element, builder);
			return element;
		}

		/**
		 * @param config
		 * @param element
		 * @param builder
		 * @throws XMLExportException
		 */
		protected void exportProperties(final MandelbrotImageConfig config, final Element element, final XMLNodeBuilder builder) throws XMLExportException {
			exportMandelbrotConfig(config, createProperty(builder, element, "mandelbrotConfig"), builder);
		}

		/**
		 * @param config
		 * @param element
		 * @param builder
		 * @throws XMLExportException
		 */
		protected void exportMandelbrotConfig(final MandelbrotImageConfig config, final Element element, final XMLNodeBuilder builder) throws XMLExportException {
			element.appendChild(new MandelbrotConfigXMLExporter().exportToElement(config.getMandelbrotConfig(), builder));
		}
	}
}
