Clover coverage report - JGAP 3.1
Coverage timestamp: Mo Dez 11 2006 21:16:18 CET
file stats: LOC: 66   Methods: 5
NCLOC: 31   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
XMLDocumentBuilder.java - 100% 100% 100%
coverage
 1    /*
 2    * This file is part of JGAP.
 3    *
 4    * JGAP offers a dual license model containing the LGPL as well as the MPL.
 5    *
 6    * For licencing information please see the file license.txt included with JGAP
 7    * or have a look at the top of class org.jgap.Chromosome which representatively
 8    * includes the JGAP license policy applicable for any file delivered with JGAP.
 9    */
 10    package org.jgap.xml;
 11   
 12    import org.jgap.data.*;
 13    import org.w3c.dom.*;
 14    import javax.xml.parsers.*;
 15   
 16    /**
 17    * Class building an XML file. Can be used to persist objects like Genotype,
 18    * Chromosome or Gene (or a list of them) to an XML file.
 19    *
 20    * @author Klaus Meffert
 21    * @since 2.0
 22    */
 23    public class XMLDocumentBuilder
 24    extends DocumentBuilderBase {
 25    /** String containing the CVS revision. Read out via reflection!*/
 26    private final static String CVS_REVISION = "$Revision: 1.8 $";
 27   
 28  6 protected void setAttribute(final Object a_xmlElement, final String a_key,
 29    final String a_value) {
 30  6 ( (Element) a_xmlElement).setAttribute(a_key, a_value);
 31    }
 32   
 33  2 protected Object documentAppendChild(final Object a_xmlDocument,
 34    final Object a_element) {
 35  2 return ( (Document) a_xmlDocument).appendChild( (Element) a_element);
 36    }
 37   
 38  5 protected Object elementAppendChild(final Object a_xmlElement,
 39    final Object a_element) {
 40  5 return ( (Element) a_xmlElement).appendChild( (Element) a_element);
 41    }
 42   
 43  7 protected Object createElement(final Object a_doc, final Object a_xmlElement,
 44    final String a_tagName) {
 45  7 return ( (Document) a_doc).createElement(a_tagName);
 46    }
 47   
 48    /**
 49    * Convenience method to build an XML document from a generic input structure
 50    * (of type IDataCreators)
 51    * @param a_document the input structure holding the data to be represented
 52    * as XML document
 53    * @throws Exception
 54    * @return Object the XML document
 55    *
 56    * @author Klaus Meffert
 57    * @since 2.0
 58    */
 59  2 public Object buildDocument(final IDataCreators a_document)
 60    throws Exception {
 61  2 DocumentBuilder m_documentCreator = DocumentBuilderFactory.newInstance().
 62    newDocumentBuilder();
 63  2 Document xmlDoc = m_documentCreator.newDocument();
 64  2 return super.buildDocument(a_document, xmlDoc);
 65    }
 66    }