Class XMLExperiment

  • All Implemented Interfaces:
    RevisionHandler

    public class XMLExperiment
    extends XMLBasicSerialization
    This class serializes and deserializes an Experiment instance to and fro XML.
    It omits the options from the Experiment, since these are handled by the get/set-methods. For the Classifier class with all its derivative classes it stores only debug and options. For SplitEvaluator and ResultProducer only the options are retrieved. The PropertyNode is done manually since it has no get/set-methods for its public fields.
    Since there's no read-method for m_ClassFirst we always save it as false.
    Version:
    $Revision: 1.6 $
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Experiment.m_ClassFirst
    • Field Detail

      • NAME_CLASSFIRST

        public static final java.lang.String NAME_CLASSFIRST
        the name of the classFirst property
        See Also:
        Constant Field Values
      • NAME_PROPERTYNODE_VALUE

        public static final java.lang.String NAME_PROPERTYNODE_VALUE
        PropertyNode member
        See Also:
        Constant Field Values
      • NAME_PROPERTYNODE_PARENTCLASS

        public static final java.lang.String NAME_PROPERTYNODE_PARENTCLASS
        PropertyNode member
        See Also:
        Constant Field Values
      • NAME_PROPERTYNODE_PROPERTY

        public static final java.lang.String NAME_PROPERTYNODE_PROPERTY
        PropertyNode member
        See Also:
        Constant Field Values
    • Constructor Detail

      • XMLExperiment

        public XMLExperiment()
                      throws java.lang.Exception
        initializes the serialization
        Throws:
        java.lang.Exception - if initialization fails
    • Method Detail

      • clear

        public void clear()
                   throws java.lang.Exception
        generates internally a new XML document and clears also the IgnoreList and the mappings for the Read/Write-Methods
        Overrides:
        clear in class XMLBasicSerialization
        Throws:
        java.lang.Exception - if initializing fails
      • writePropertyNode

        public org.w3c.dom.Element writePropertyNode​(org.w3c.dom.Element parent,
                                                     java.lang.Object o,
                                                     java.lang.String name)
                                              throws java.lang.Exception
        adds the given PropertyNode to a DOM structure.
        Parameters:
        parent - the parent of this object, e.g. the class this object is a member of
        o - the Object to describe in XML
        name - the name of the object
        Returns:
        the node that was created
        Throws:
        java.lang.Exception - if the DOM creation fails
      • readPropertyNode

        public java.lang.Object readPropertyNode​(org.w3c.dom.Element node)
                                          throws java.lang.Exception
        builds the PropertyNode from the given DOM node.
        Parameters:
        node - the associated XML node
        Returns:
        the instance created from the XML description
        Throws:
        java.lang.Exception - if instantiation fails
        See Also:
        DefaultListModel
      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        for testing only. if the first argument is a filename with ".xml" as extension it tries to generate an instance from the XML description and does a toString() of the generated object. Otherwise it loads the binary file, saves the XML representation in a file with the original filename appended by ".xml" and once again in a binary file with the original filename appended by ".exp".
        Parameters:
        args - the commandline arguments
        Throws:
        java.lang.Exception - if something goes wrong, e.g., file not found