/** * Marshall a Genotype instance into an XML Element representation, including its population of * Chromosome instances as sub-elements. This may be useful in scenarios where representation as * an entire Document is undesirable, such as when the representation of this Genotype is to be * combined with other elements in a single Document. * * @param a_subject the genotype to represent as an XML element * @param a_xmlDocument a Document instance that will be used to create the Element instance. Note * that the element will NOT be added to the document by this method * @return an Element object representing the given Genotype * @author Neil Rotstan * @since 1.0 * @deprecated use XMLDocumentBuilder instead */ public static Element representGenotypeAsElement( final Genotype a_subject, final Document a_xmlDocument) { Population population = a_subject.getPopulation(); // Start by creating the genotype element and its size attribute, // which represents the number of chromosomes present in the // genotype. // -------------------------------------------------------------- Element genotypeTag = a_xmlDocument.createElement(GENOTYPE_TAG); genotypeTag.setAttribute(SIZE_ATTRIBUTE, Integer.toString(population.size())); // Next, add nested elements for each of the chromosomes in the // genotype. // ------------------------------------------------------------ for (int i = 0; i < population.size(); i++) { Element chromosomeElement = representChromosomeAsElement(population.getChromosome(i), a_xmlDocument); genotypeTag.appendChild(chromosomeElement); } return genotypeTag; }