org.jgap.xml
Class XMLManager
- java.lang.Object
-
- org.jgap.xml.XMLManager
-
public class XMLManager extends java.lang.ObjectThe XMLManager performs marshalling of genetic entity instances (such as Chromosomes and Genotypes) to XML representations of those entities, as well as unmarshalling. All of the methods in this class are static, so no construction is required (or allowed).- Since:
- 1.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description static ChromosomegetChromosomeFromDocument(Configuration a_activeConfiguration, org.w3c.dom.Document a_xmlDocument)Unmarshall a Chromosome instance from a given XML Document representation.static ChromosomegetChromosomeFromElement(Configuration a_activeConfiguration, org.w3c.dom.Element a_xmlElement)Unmarshall a Chromosome instance from a given XML Element representation.static Gene[]getGenesFromElement(Configuration a_activeConfiguration, org.w3c.dom.Element a_xmlElement)Unmarshall a Chromosome instance from a given XML Element representation.static GenotypegetGenotypeFromDocument(Configuration a_activeConfiguration, org.w3c.dom.Document a_xmlDocument)Unmarshall a Genotype instance from a given XML Document representation.static GenotypegetGenotypeFromElement(Configuration a_activeConfiguration, org.w3c.dom.Element a_xmlElement)Unmarshall a Genotype instance from a given XML Element representation.static org.w3c.dom.DocumentreadFile(java.io.File file)Reads in an XML file and returns a Document object.static org.w3c.dom.DocumentrepresentChromosomeAsDocument(IChromosome a_subject)Deprecated.use XMLDocumentBuilder insteadstatic org.w3c.dom.ElementrepresentChromosomeAsElement(IChromosome a_subject, org.w3c.dom.Document a_xmlDocument)Deprecated.use XMLDocumentBuilder insteadstatic org.w3c.dom.ElementrepresentGenesAsElement(Gene[] a_geneValues, org.w3c.dom.Document a_xmlDocument)Deprecated.use XMLDocumentBuilder insteadstatic org.w3c.dom.DocumentrepresentGenotypeAsDocument(Genotype a_subject)Deprecated.use XMLDocumentBuilder insteadstatic org.w3c.dom.ElementrepresentGenotypeAsElement(Genotype a_subject, org.w3c.dom.Document a_xmlDocument)Deprecated.use XMLDocumentBuilder insteadstatic voidwriteFile(org.w3c.dom.Document doc, java.io.File file)Writes an XML file from a Document object.
-
-
-
Method Detail
-
representChromosomeAsDocument
public static org.w3c.dom.Document representChromosomeAsDocument(IChromosome a_subject)
Deprecated. use XMLDocumentBuilder insteadMarshall a Chromosome instance to an XML Document representation, including its contained Gene instances.- Parameters:
a_subject- the chromosome to represent as an XML document- Returns:
- a Document object representing the given Chromosome
- Since:
- 1.0
-
representGenotypeAsDocument
public static org.w3c.dom.Document representGenotypeAsDocument(Genotype a_subject)
Deprecated. use XMLDocumentBuilder insteadMarshall a Genotype to an XML Document representation, including its population of Chromosome instances.- Parameters:
a_subject- the genotype to represent as an XML document- Returns:
- a Document object representing the given Genotype
- Since:
- 1.0
-
representGenesAsElement
public static org.w3c.dom.Element representGenesAsElement(Gene[] a_geneValues, org.w3c.dom.Document a_xmlDocument)
Deprecated. use XMLDocumentBuilder insteadMarshall an array of Genes to an XML Element representation.- Parameters:
a_geneValues- the genes to represent as an XML elementa_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- Returns:
- an Element object representing the given genes
- Since:
- 1.0
-
representChromosomeAsElement
public static org.w3c.dom.Element representChromosomeAsElement(IChromosome a_subject, org.w3c.dom.Document a_xmlDocument)
Deprecated. use XMLDocumentBuilder insteadMarshall 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.- Parameters:
a_subject- the chromosome to represent as an XML elementa_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- Returns:
- an Element object representing the given Chromosome
- Since:
- 1.0
-
representGenotypeAsElement
public static org.w3c.dom.Element representGenotypeAsElement(Genotype a_subject, org.w3c.dom.Document a_xmlDocument)
Deprecated. use XMLDocumentBuilder insteadMarshall 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.- Parameters:
a_subject- the genotype to represent as an XML elementa_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- Returns:
- an Element object representing the given Genotype
- Since:
- 1.0
-
getGenesFromElement
public static Gene[] getGenesFromElement(Configuration a_activeConfiguration, org.w3c.dom.Element a_xmlElement) throws ImproperXMLException, UnsupportedRepresentationException, GeneCreationException
Unmarshall a Chromosome instance from a given XML Element representation.- Parameters:
a_activeConfiguration- current Configuration objecta_xmlElement- the XML Element representation of the Chromosome- Returns:
- a new Chromosome instance setup with the data from the XML Element representation
- Throws:
ImproperXMLException- if the given Element is improperly structured or missing dataUnsupportedRepresentationException- if the actively configured Gene implementation does not support the string representation of the alleles used in the given XML documentGeneCreationException- if there is a problem creating or populating a Gene instance- Since:
- 1.0
-
getChromosomeFromElement
public static Chromosome getChromosomeFromElement(Configuration a_activeConfiguration, org.w3c.dom.Element a_xmlElement) throws ImproperXMLException, InvalidConfigurationException, UnsupportedRepresentationException, GeneCreationException
Unmarshall a Chromosome instance from a given XML Element representation.- Parameters:
a_activeConfiguration- the current active Configuration object that is to be used during construction of the Chromosomea_xmlElement- the XML Element representation of the Chromosome- Returns:
- a new Chromosome instance setup with the data from the XML Element representation
- Throws:
ImproperXMLException- if the given Element is improperly structured or missing dataInvalidConfigurationException- if the given Configuration is in an inconsistent stateUnsupportedRepresentationException- if the actively configured Gene implementation does not support the string representation of the alleles used in the given XML documentGeneCreationException- if there is a problem creating or populating a Gene instance- Since:
- 1.0
-
getGenotypeFromElement
public static Genotype getGenotypeFromElement(Configuration a_activeConfiguration, org.w3c.dom.Element a_xmlElement) throws ImproperXMLException, InvalidConfigurationException, UnsupportedRepresentationException, GeneCreationException
Unmarshall a Genotype instance from a given XML Element representation. Its population of Chromosomes will be unmarshalled from the Chromosome sub-elements.- Parameters:
a_activeConfiguration- the current active Configuration object that is to be used during construction of the Genotype and Chromosome instancesa_xmlElement- the XML Element representation of the Genotype- Returns:
- a new Genotype instance, complete with a population of Chromosomes, setup with the data from the XML Element representation
- Throws:
ImproperXMLException- if the given Element is improperly structured or missing dataInvalidConfigurationException- if the given Configuration is in an inconsistent stateUnsupportedRepresentationException- if the actively configured Gene implementation does not support the string representation of the alleles used in the given XML documentGeneCreationException- if there is a problem creating or populating a Gene instance- Since:
- 1.0
-
getGenotypeFromDocument
public static Genotype getGenotypeFromDocument(Configuration a_activeConfiguration, org.w3c.dom.Document a_xmlDocument) throws ImproperXMLException, InvalidConfigurationException, UnsupportedRepresentationException, GeneCreationException
Unmarshall a Genotype instance from a given XML Document representation. Its population of Chromosomes will be unmarshalled from the Chromosome sub-elements.- Parameters:
a_activeConfiguration- the current active Configuration object that is to be used during construction of the Genotype and Chromosome instancesa_xmlDocument- the XML Document representation of the Genotype- Returns:
- A new Genotype instance, complete with a population of Chromosomes, setup with the data from the XML Document representation
- Throws:
ImproperXMLException- if the given Document is improperly structured or missing dataInvalidConfigurationException- if the given Configuration is in an inconsistent stateUnsupportedRepresentationException- if the actively configured Gene implementation does not support the string representation of the alleles used in the given XML documentGeneCreationException- if there is a problem creating or populating a Gene instance- Since:
- 1.0
-
getChromosomeFromDocument
public static Chromosome getChromosomeFromDocument(Configuration a_activeConfiguration, org.w3c.dom.Document a_xmlDocument) throws ImproperXMLException, InvalidConfigurationException, UnsupportedRepresentationException, GeneCreationException
Unmarshall a Chromosome instance from a given XML Document representation. Its genes will be unmarshalled from the gene sub-elements.- Parameters:
a_activeConfiguration- the current active Configuration object that is to be used during construction of the Chromosome instancesa_xmlDocument- the XML Document representation of the Chromosome- Returns:
- a new Chromosome instance setup with the data from the XML Document representation
- Throws:
ImproperXMLException- if the given Document is improperly structured or missing dataInvalidConfigurationException- if the given Configuration is in an inconsistent stateUnsupportedRepresentationException- if the actively configured Gene implementation does not support the string representation of the alleles used in the given XML documentGeneCreationException- if there is a problem creating or populating a Gene instance- Since:
- 1.0
-
readFile
public static org.w3c.dom.Document readFile(java.io.File file) throws java.io.IOException, org.xml.sax.SAXExceptionReads in an XML file and returns a Document object.- Parameters:
file- the file to be read in- Returns:
- Document
- Throws:
java.io.IOExceptionSAXException- Since:
- 2.0
-
writeFile
public static void writeFile(org.w3c.dom.Document doc, java.io.File file) throws java.io.IOExceptionWrites an XML file from a Document object.- Parameters:
doc- the Document object to be written to filefile- the file to be written- Throws:
java.io.IOException- Since:
- 2.0
-
-
DMelt 3.0 © DataMelt by jWork.ORG