All Downloads are FREE. Search and download functionalities are using the official Maven repository.

es.ucm.fdi.gaia.jcolibri.connector.xmlutils.CaseComponentSerializer Maven / Gradle / Ivy

Go to download

jCOLIBRI is a java framework for the development of Case-Based Reasoning systems.

There is a newer version: 3.2
Show newest version
/**
 * CaseComponentSerializer.java
 * jCOLIBRI2 framework. 
 * @author Juan A. Recio-Garc�a.
 * GAIA - Group for Artificial Intelligence Applications
 * http://gaia.fdi.ucm.es
 * 04/11/2007
 */
package es.ucm.fdi.gaia.jcolibri.connector.xmlutils;

import java.io.StringWriter;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.apache.logging.log4j.LogManager;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import es.ucm.fdi.gaia.jcolibri.cbrcore.Attribute;
import es.ucm.fdi.gaia.jcolibri.cbrcore.CaseComponent;
import es.ucm.fdi.gaia.jcolibri.connector.plaintextutils.PlainTextTypeConverter;
import es.ucm.fdi.gaia.jcolibri.util.AttributeUtils;

/**
 * Utility class to serialize CaseComponents into xml files.
 * This class will be used in future versions to implement the xml connector.
 * @author Juan A. Recio-Garcia
 * @version 1.0
 *
 */
public class CaseComponentSerializer {

    
    public static CaseComponent deserializeCaseComponent(Node node)
    {
	    try
	    {
		NamedNodeMap nodemap = node.getAttributes();
		String className = nodemap.getNamedItem("Class").getTextContent();
		CaseComponent cc = (CaseComponent)Class.forName(className).newInstance();
		
		NodeList nl = node.getChildNodes();
		for(int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy