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.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
    Weka classes:
    • weka.core.Matrix
    • weka.core.matrix.Matrix
    Version:
    $Revision: 1.6 $
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Field Detail

      • VAL_MAPPING

        public static final java.lang.String VAL_MAPPING
        the value for mapping, e.g., Maps
        See Also:
        Constant Field Values
      • VAL_KEY

        public static final java.lang.String VAL_KEY
        the value for a mapping-key, e.g., Maps
        See Also:
        Constant Field Values
      • VAL_VALUE

        public static final java.lang.String VAL_VALUE
        the value for mapping-value, e.g., Maps
        See Also:
        Constant Field Values
      • VAL_CELLS

        public static final java.lang.String VAL_CELLS
        the matrix cells
        See Also:
        Constant Field Values
    • Constructor Detail

      • XMLBasicSerialization

        public XMLBasicSerialization()
                              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 XMLSerialization
        Throws:
        java.lang.Exception - if initializing fails
      • writeDefaultListModel

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

        public java.lang.Object readDefaultListModel​(org.w3c.dom.Element node)
                                              throws java.lang.Exception
        builds the DefaultListModel 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
      • writeCollection

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

        public java.lang.Object readCollection​(org.w3c.dom.Element node)
                                        throws java.lang.Exception
        builds the Collection 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:
        Collection
      • writeMap

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

        public java.lang.Object readMap​(org.w3c.dom.Element node)
                                 throws java.lang.Exception
        builds the Map 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:
        Map
      • writeMatrix

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

        public java.lang.Object readMatrix​(org.w3c.dom.Element node)
                                    throws java.lang.Exception
        builds the Matrix 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:
        Matrix
      • writeMatrixOld

        public org.w3c.dom.Element writeMatrixOld​(org.w3c.dom.Element parent,
                                                  java.lang.Object o,
                                                  java.lang.String name)
                                           throws java.lang.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:
        java.lang.Exception - if the DOM creation fails
        See Also:
        Matrix
      • readMatrixOld

        public java.lang.Object readMatrixOld​(org.w3c.dom.Element node)
                                       throws java.lang.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:
        java.lang.Exception - if instantiation fails
        See Also:
        Matrix
      • writeCostMatrixOld

        public org.w3c.dom.Element writeCostMatrixOld​(org.w3c.dom.Element parent,
                                                      java.lang.Object o,
                                                      java.lang.String name)
                                               throws java.lang.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:
        java.lang.Exception - if the DOM creation fails
        See Also:
        CostMatrix
      • readCostMatrixOld

        public java.lang.Object readCostMatrixOld​(org.w3c.dom.Element node)
                                           throws java.lang.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:
        java.lang.Exception - if instantiation fails
        See Also:
        CostMatrix