/** * Marshall a Chromosome instance to an XML Element representation, including its contained Genes * as sub-elements. This may be useful in scenarios where representation as an entire Document is * undesirable, such as when the representation of this Chromosome is to be combined with other * elements in a single Document. * * @param a_subject the chromosome 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 Chromosome * @author Neil Rotstan * @since 1.0 * @deprecated use XMLDocumentBuilder instead */ public static Element representChromosomeAsElement( final IChromosome a_subject, final Document a_xmlDocument) { // Start by creating an element for the chromosome and its size // attribute, which represents the number of genes in the chromosome. // ------------------------------------------------------------------ Element chromosomeElement = a_xmlDocument.createElement(CHROMOSOME_TAG); chromosomeElement.setAttribute(SIZE_ATTRIBUTE, Integer.toString(a_subject.size())); // Next create the genes element with its nested gene elements, // which will contain string representations of the alleles. // -------------------------------------------------------------- Element genesElement = representGenesAsElement(a_subject.getGenes(), a_xmlDocument); // Add the new genes element to the chromosome element and then // return the chromosome element. // ------------------------------------------------------------- chromosomeElement.appendChild(genesElement); return chromosomeElement; }