Package weka.core.xml

# Class XMLSerializationMethodHandler

java.lang.Object
weka.core.xml.XMLSerializationMethodHandler

All Implemented Interfaces:
  `RevisionHandler`

public class XMLSerializationMethodHandler extends Object implements RevisionHandler
This class handles relationships between display names of properties (or classes) and Methods that are associated with them. It differentiates between read and write methods. It automatically stores public methods that have the same signature as the `readFromXML()` and `writeToXML()` methods in the `XMLSerialization` class.

Version:
  $Revision: 10203 $
Author:
  FracPete (fracpete at waikato dot ac dot nz)
See Also:
  - `MethodHandler`
  - `XMLSerialization`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `XMLSerializationMethodHandler(Object owner)`
  initializes the method handling, executes also `clear()`, which adds initial methods automatically.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `clear()`
  removes all current methods and adds the methods according to the
  `static Method`
  `findReadMethod(Object o, String name)`
  returns the method with the given name that has the same signature as `readFromXML()` of the `XMLSerialiation` class.
  `static Method`
  `findWriteMethod(Object o, String name)`
  returns the method with the given name that has the same signature as `writeToXML()` of the `XMLSerialiation` class.
  `String`
  `getRevision()`
  Returns the revision string.
  `MethodHandler`
  `read()`
  returns the handler for read methods
  `void`
  `register(Object handler, Class<?> cls, String name)`
  adds read and write methods for the given class, i.e., read&;lt;name> and write<name> ("name" is prefixed by read and write)
  `String`
  `toString()`
  returns the read and write method handlers as string
  `MethodHandler`
  `write()`
  returns the handler for write methods

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

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

- ## Constructor Details

  - ### XMLSerializationMethodHandler

    public XMLSerializationMethodHandler(Object owner) throws Exception
    initializes the method handling, executes also `clear()`, which adds initial methods automatically.
    Parameters:
      `owner` - the owner to retrieve the methods from
    Throws:
      `Exception` - if initialization fails
    See Also:
      - `clear()`

- ## Method Details

  - ### findReadMethod

    public static Method findReadMethod(Object o, String name)
    returns the method with the given name that has the same signature as `readFromXML()` of the `XMLSerialiation` class. simplifies the adding of custom methods.
    Parameters:
      `o` - the object to inspect
      `name` - the name of the method to return
    Returns:
      either `null` if no method was found or a reference
    See Also:
      - `XMLSerialization.readFromXML(Element)`

  - ### findWriteMethod

    public static Method findWriteMethod(Object o, String name)
    returns the method with the given name that has the same signature as `writeToXML()` of the `XMLSerialiation` class. simplifies the adding of custom methods.
    Parameters:
      `o` - the object to inspect
      `name` - the name of the method to return
    Returns:
      either `null` if no method was found or a reference
    See Also:
      - `XMLSerialization.writeToXML(Element, Object, String)`

  - ### clear

    public void clear()
    removes all current methods and adds the methods according to the

  - ### read

    public MethodHandler read()
    returns the handler for read methods
    Returns:
      the methodhandler for read methods

  - ### write

    public MethodHandler write()
    returns the handler for write methods
    Returns:
      the methodhandler for read methods

  - ### register

    public void register(Object handler, Class<?> cls, String name)
    adds read and write methods for the given class, i.e., read&;lt;name> and write<name> ("name" is prefixed by read and write)
    Parameters:
      `handler` - the handler class that contains the read and write method
      `cls` - the class to register the read and write method for
      `name` - the suffix of the read and write method

  - ### toString

    public String toString()
    returns the read and write method handlers as string
    Overrides:
      `toString` in class `Object`
    Returns:
      the read/write method handlers as string

  - ### getRevision

    public String getRevision()
    Returns the revision string.
    Specified by:
      `getRevision` in interface `RevisionHandler`
    Returns:
      the revision