Package weka.core.xml

Class XMLBasicSerialization

  • All Implemented Interfaces:
    RevisionHandler
    Direct Known Subclasses:
    XMLBeans, XMLClassifier, XMLExperiment

    public class XMLBasicSerialization
    extends XMLSerialization
    This serializer contains some read/write methods for common classes that are not beans-conform. Currently supported are:
    • java.util.HashMap
    • java.util.LinkedHashMap
    • java.util.HashSet
    • java.util.Hashtable
    • java.util.LinkedList
    • java.util.Properties
    • java.util.Stack
    • java.util.TreeMap
    • java.util.TreeSet
    • java.util.Vector
    • javax.swing.DefaultListModel
    • java.awt.Color
    Weka classes:
    • weka.core.Matrix
    • weka.core.matrix.Matrix
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • XMLBasicSerialization

        public XMLBasicSerialization()
                              throws Exception
        initializes the serialization
        Throws:
        Exception - if initialization fails
    • Method Detail

      • clear

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

        public Element writeColor​(Element parent,
                                  Object o,
                                  String name)
                           throws Exception
        adds the given Color 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:
        Exception - if the DOM creation fails
        See Also:
        Color
      • readColor

        public Object readColor​(Element node)
                         throws Exception
        builds the Color object from the given DOM node.
        Parameters:
        node - the associated XML node
        Returns:
        the instance created from the XML description
        Throws:
        Exception - if instantiation fails
        See Also:
        Color
      • writeDefaultListModel

        public Element writeDefaultListModel​(Element parent,
                                             Object o,
                                             String name)
                                      throws Exception
        adds the given DefaultListModel 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:
        Exception - if the DOM creation fails
        See Also:
        DefaultListModel
      • readDefaultListModel

        public Object readDefaultListModel​(Element node)
                                    throws Exception
        builds the DefaultListModel from the given DOM node.
        Parameters:
        node - the associated XML node
        Returns:
        the instance created from the XML description
        Throws:
        Exception - if instantiation fails
        See Also:
        DefaultListModel
      • writeCollection

        public Element writeCollection​(Element parent,
                                       Object o,
                                       String name)
                                throws Exception
        adds the given Collection 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:
        Exception - if the DOM creation fails
        See Also:
        Collection
      • readCollection

        public Object readCollection​(Element node)
                              throws Exception
        builds the Collection from the given DOM node.
        Parameters:
        node - the associated XML node
        Returns:
        the instance created from the XML description
        Throws:
        Exception - if instantiation fails
        See Also:
        Collection
      • writeMap

        public Element writeMap​(Element parent,
                                Object o,
                                String name)
                         throws Exception
        adds the given Map 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:
        Exception - if the DOM creation fails
        See Also:
        Map
      • readMap

        public Object readMap​(Element node)
                       throws Exception
        builds the Map from the given DOM node.
        Parameters:
        node - the associated XML node
        Returns:
        the instance created from the XML description
        Throws:
        Exception - if instantiation fails
        See Also:
        Map
      • writeCostMatrix

        public Element writeCostMatrix​(Element parent,
                                       Object o,
                                       String name)
                                throws Exception
        adds the given CostMatrix 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:
        Exception - if the DOM creation fails
        See Also:
        CostMatrix
      • readCostMatrix

        public Object readCostMatrix​(Element node)
                              throws Exception
        builds the Matrix from the given DOM node.
        Parameters:
        node - the associated XML node
        Returns:
        the instance created from the XML description
        Throws:
        Exception - if instantiation fails
        See Also:
        CostMatrix
      • writeMatrix

        public Element writeMatrix​(Element parent,
                                   Object o,
                                   String name)
                            throws Exception
        adds the given Matrix 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:
        Exception - if the DOM creation fails
        See Also:
        Matrix
      • readMatrix

        public Object readMatrix​(Element node)
                          throws Exception
        builds the Matrix from the given DOM node.
        Parameters:
        node - the associated XML node
        Returns:
        the instance created from the XML description
        Throws:
        Exception - if instantiation fails
        See Also:
        Matrix
      • writeMatrixOld

        public Element writeMatrixOld​(Element parent,
                                      Object o,
                                      String name)
                               throws Exception
        adds the given Matrix (old) 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:
        Exception - if the DOM creation fails
        See Also:
        Matrix
      • readMatrixOld

        public Object readMatrixOld​(Element node)
                             throws Exception
        builds the Matrix (old) from the given DOM node.
        Parameters:
        node - the associated XML node
        Returns:
        the instance created from the XML description
        Throws:
        Exception - if instantiation fails
        See Also:
        Matrix
      • writeCostMatrixOld

        public Element writeCostMatrixOld​(Element parent,
                                          Object o,
                                          String name)
                                   throws Exception
        adds the given CostMatrix (old) 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:
        Exception - if the DOM creation fails
        See Also:
        CostMatrix
      • readCostMatrixOld

        public Object readCostMatrixOld​(Element node)
                                 throws Exception
        builds the Matrix (old) from the given DOM node.
        Parameters:
        node - the associated XML node
        Returns:
        the instance created from the XML description
        Throws:
        Exception - if instantiation fails
        See Also:
        CostMatrix