JGAP

org.jgap.xml
Class XMLDocumentBuilder

java.lang.Object
  extended by org.jgap.data.DocumentBuilderBase
      extended by org.jgap.xml.XMLDocumentBuilder

public class XMLDocumentBuilder
extends DocumentBuilderBase

Class building an XML file. Can be used to persist objects like Genotype, Chromosome or Gene (or a list of them) to an XML file.

Since:
2.0

Constructor Summary
XMLDocumentBuilder()
           
 
Method Summary
 java.lang.Object buildDocument(IDataCreators a_document)
          Convenience method to build an XML document from a generic input structure (of type IDataCreators)
protected  java.lang.Object createElement(java.lang.Object a_doc, java.lang.Object a_xmlElement, java.lang.String a_tagName)
          Creates an element with help for a given document.
protected  java.lang.Object documentAppendChild(java.lang.Object a_xmlDocument, java.lang.Object a_element)
          Append a child to a given document.
protected  java.lang.Object elementAppendChild(java.lang.Object a_xmlElement, java.lang.Object a_element)
          Append a child to a given element.
protected  void setAttribute(java.lang.Object a_xmlElement, java.lang.String a_key, java.lang.String a_value)
          Sets an attribute for a given Element.
 
Methods inherited from class org.jgap.data.DocumentBuilderBase
buildDocument
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLDocumentBuilder

public XMLDocumentBuilder()
Method Detail

setAttribute

protected void setAttribute(java.lang.Object a_xmlElement,
                            java.lang.String a_key,
                            java.lang.String a_value)
Description copied from class: DocumentBuilderBase
Sets an attribute for a given Element.

Specified by:
setAttribute in class DocumentBuilderBase
Parameters:
a_xmlElement - the Element to set an attribute for (e.g. org.w3c.com.Element)
a_key - the key of the attribute
a_value - the value of the attribute

documentAppendChild

protected java.lang.Object documentAppendChild(java.lang.Object a_xmlDocument,
                                               java.lang.Object a_element)
Description copied from class: DocumentBuilderBase
Append a child to a given document.

Specified by:
documentAppendChild in class DocumentBuilderBase
Parameters:
a_xmlDocument - to append element on (e.g. org.w3c.dom.Document)
a_element - to append to document (e.g. org.w3c.com.Element)
Returns:
a_document with appended element (e.g. org.w3c.dom.Document)

elementAppendChild

protected java.lang.Object elementAppendChild(java.lang.Object a_xmlElement,
                                              java.lang.Object a_element)
Description copied from class: DocumentBuilderBase
Append a child to a given element.

Specified by:
elementAppendChild in class DocumentBuilderBase
Parameters:
a_xmlElement - to append childElement on (e.g. org.w3c.com.Element)
a_element - to append to rootElement (e.g. org.w3c.com.Element)
Returns:
rootElement with appended childElement (e.g. org.w3c.com.Element)

createElement

protected java.lang.Object createElement(java.lang.Object a_doc,
                                         java.lang.Object a_xmlElement,
                                         java.lang.String a_tagName)
Description copied from class: DocumentBuilderBase
Creates an element with help for a given document.

Specified by:
createElement in class DocumentBuilderBase
Parameters:
a_doc - could be used as factory to create the element with
a_xmlElement - null or existing element as template
a_tagName - name of tag to create for the element
Returns:
created element

buildDocument

public java.lang.Object buildDocument(IDataCreators a_document)
                               throws java.lang.Exception
Convenience method to build an XML document from a generic input structure (of type IDataCreators)

Parameters:
a_document - the input structure holding the data to be represented as XML document
Returns:
Object the XML document
Throws:
java.lang.Exception
Since:
2.0

JGAP