Package weka.core.xml

# Class XMLBasicSerialization

java.lang.Object
weka.core.xml.XMLSerialization
weka.core.xml.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 Summary

Fields
Modifier and Type
Field
Description
`static final String`
`VAL_CELLS`
the matrix cells
`static final String`
`VAL_KEY`
the value for a mapping-key, e.g., Maps
`static final String`
`VAL_MAPPING`
the value for mapping, e.g., Maps
`static final String`
`VAL_VALUE`
the value for mapping-value, e.g., Maps

### Fields inherited from class weka.core.xml.XMLSerialization

`ATT_ARRAY, ATT_ARRAY_DEFAULT, ATT_CLASS, ATT_NAME, ATT_NULL, ATT_NULL_DEFAULT, ATT_PRIMITIVE, ATT_PRIMITIVE_DEFAULT, ATT_VERSION, DOCTYPE, ROOT_NODE, TAG_OBJECT, VAL_NO, VAL_ROOT, VAL_YES`

## Constructor Summary

Constructors
Constructor
Description
`XMLBasicSerialization()`
initializes the serialization

## Method Summary

Modifier and Type
Method
Description
`void`
`clear()`
generates internally a new XML document and clears also the IgnoreList and the mappings for the Read/Write-Methods
`String`
`getRevision()`
Returns the revision string.
`Object`
`readCollection(Element node)`
builds the Collection from the given DOM node.
`Object`
`readCostMatrixOld(Element node)`
builds the Matrix (old) from the given DOM node.
`Object`
`readDefaultListModel(Element node)`
builds the DefaultListModel from the given DOM node.
`Object`
`readMap(Element node)`
builds the Map from the given DOM node.
`Object`
`readMatrix(Element node)`
builds the Matrix from the given DOM node.
`Object`
`readMatrixOld(Element node)`
builds the Matrix (old) from the given DOM node.
`Element`
`writeCollection(Element parent, Object o, String name)`
adds the given Collection to a DOM structure.
`Element`
`writeCostMatrixOld(Element parent, Object o, String name)`
adds the given CostMatrix (old) to a DOM structure.
`Element`
`writeDefaultListModel(Element parent, Object o, String name)`
adds the given DefaultListModel to a DOM structure.
`Element`
`writeMap(Element parent, Object o, String name)`
adds the given Map to a DOM structure.
`Element`
`writeMatrix(Element parent, Object o, String name)`
adds the given Matrix to a DOM structure.
`Element`
`writeMatrixOld(Element parent, Object o, String name)`
adds the given Matrix (old) to a DOM structure.

### Methods inherited from class weka.core.xml.XMLSerialization

`fromXML, getVersion, main, read, read, read, read, readBooleanFromXML, readByteFromXML, readCharFromXML, readDoubleFromXML, readFloatFromXML, readFromXML, readFromXML, readIntFromXML, readLongFromXML, readShortFromXML, toXML, write, write, write, write, writeToXML`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### VAL_MAPPING

public static final String VAL_MAPPING
the value for mapping, e.g., Maps

See Also:
  - Constant Field Values

### VAL_KEY

public static final String VAL_KEY
the value for a mapping-key, e.g., Maps

See Also:
  - Constant Field Values

### VAL_VALUE

public static final String VAL_VALUE
the value for mapping-value, e.g., Maps

See Also:
  - Constant Field Values

### VAL_CELLS

public static final String VAL_CELLS
the matrix cells

See Also:
  - Constant Field Values

## Constructor Details

### XMLBasicSerialization

public XMLBasicSerialization() throws Exception
initializes the serialization

Throws:
  `Exception` - if initialization fails

## Method Details

### 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

### 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`

### 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`

### getRevision

public String getRevision()
Returns the revision string.

Specified by:
  `getRevision` in interface `RevisionHandler`
Overrides:
  `getRevision` in class `XMLSerialization`
Returns:
  the revision