Package weka.core.xml
Class XMLSerializationMethodHandler
- java.lang.Object
-
- weka.core.xml.XMLSerializationMethodHandler
-
- All Implemented Interfaces:
RevisionHandler
public class XMLSerializationMethodHandler extends java.lang.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 thereadFromXML()
andwriteToXML()
methods in theXMLSerialization
class.- Version:
- $Revision: 1.5 $
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
MethodHandler
,XMLSerialization
-
-
Constructor Summary
Constructors Constructor Description XMLSerializationMethodHandler(java.lang.Object owner)
initializes the method handling, executes alsoclear()
, which adds initial methods automatically.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
removes all current methods and adds the methods according to thestatic java.lang.reflect.Method
findReadMethod(java.lang.Object o, java.lang.String name)
returns the method with the given name that has the same signature asreadFromXML()
of theXMLSerialiation
class.static java.lang.reflect.Method
findWriteMethod(java.lang.Object o, java.lang.String name)
returns the method with the given name that has the same signature aswriteToXML()
of theXMLSerialiation
class.java.lang.String
getRevision()
Returns the revision string.MethodHandler
read()
returns the handler for read methodsvoid
register(java.lang.Object handler, java.lang.Class cls, java.lang.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)java.lang.String
toString()
returns the read and write method handlers as stringMethodHandler
write()
returns the handler for write methods
-
-
-
Constructor Detail
-
XMLSerializationMethodHandler
public XMLSerializationMethodHandler(java.lang.Object owner) throws java.lang.Exception
initializes the method handling, executes alsoclear()
, which adds initial methods automatically.- Parameters:
owner
- the owner to retrieve the methods from- Throws:
java.lang.Exception
- if initialization fails- See Also:
clear()
-
-
Method Detail
-
findReadMethod
public static java.lang.reflect.Method findReadMethod(java.lang.Object o, java.lang.String name)
returns the method with the given name that has the same signature asreadFromXML()
of theXMLSerialiation
class. simplifies the adding of custom methods.- Parameters:
o
- the object to inspectname
- 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 java.lang.reflect.Method findWriteMethod(java.lang.Object o, java.lang.String name)
returns the method with the given name that has the same signature aswriteToXML()
of theXMLSerialiation
class. simplifies the adding of custom methods.- Parameters:
o
- the object to inspectname
- 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(java.lang.Object handler, java.lang.Class cls, java.lang.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 methodcls
- the class to register the read and write method forname
- the suffix of the read and write method
-
toString
public java.lang.String toString()
returns the read and write method handlers as string- Overrides:
toString
in classjava.lang.Object
- Returns:
- the read/write method handlers as string
-
getRevision
public java.lang.String getRevision()
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Returns:
- the revision
-
-