de.unihalle.informatik.Alida.dataio
Class ALDDataIOManager

java.lang.Object
  extended by de.unihalle.informatik.Alida.dataio.ALDDataIOManager
Direct Known Subclasses:
ALDDataIOManagerCmdline, ALDDataIOManagerSwing

public abstract class ALDDataIOManager
extends java.lang.Object

Class to manage data input and output in Alida. This is used, e.g., in Alida's mechanism to automaticaly generate user interfaces for Alida operators. This abstract class provides means to find a DataIO provider object for a given class. DataIO provider classes need to be annotated with ALDDataIOProvider and are expected to implement an interface which is derived from the interface ALDDataIO.

Each non-abstract class extending ALDDataIOManager will typically come in pair with an interface which extends ALDDataIO. The class extending ALDDataIOManager defines methods to read and write data which are delegated to the corresponding corresponding classes defined in the pairing interface and thus have to be defined there.

Author:
moeller,posch
See Also:
ALDDataIO

Field Summary
protected static boolean debug
          For internal debugging purposes
protected  java.util.HashMap<java.lang.Class,java.lang.String> mapTable
          Hashtable containing mappings of datatypes to DataIO provider classes.
private static java.lang.String providedClassesMethodName
          Name of the method which returns all classes supported by a DataIO provider class.
 
Constructor Summary
protected ALDDataIOManager()
          Default constructor.
 
Method Summary
 ALDDataIO getProvider(java.lang.Class cl, java.lang.Class interfaceRequired)
          Method to return an instance of the DataIO provider class for the class cl which implements the requested interface interfaceRequired (which has itself to implement ALDDataIO).
 java.util.HashMap<java.lang.Class,java.lang.String> getProviderMap()
          Method to return a clone of the mapping of classes to dataIO providers.
protected static java.util.HashMap<java.lang.Class,java.lang.String> initMapTable(java.lang.Class interfaceRequired)
          Method to initialize the hashmap which registers DataIO providers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

protected static boolean debug
For internal debugging purposes


mapTable

protected java.util.HashMap<java.lang.Class,java.lang.String> mapTable
Hashtable containing mappings of datatypes to DataIO provider classes. This is initialized using indices generated via the @ALDDataIOProvider annotation, see initMapTable(). The dataIO provider is specified with its full class name.


providedClassesMethodName

private static java.lang.String providedClassesMethodName
Name of the method which returns all classes supported by a DataIO provider class. This method is declared by the interface ALDDataIO and thus to be implemented by each DataIO provider class.

Constructor Detail

ALDDataIOManager

protected ALDDataIOManager()
Default constructor.

Method Detail

getProvider

public ALDDataIO getProvider(java.lang.Class cl,
                             java.lang.Class interfaceRequired)
                      throws ALDDataIOManagerException
Method to return an instance of the DataIO provider class for the class cl which implements the requested interface interfaceRequired (which has itself to implement ALDDataIO).

There are the following extensions if no DataIO provider for class cl is found. If cl is an enumeration class, a provider for Enum.class is returned (if found). If cl is an ALDOperator class, a provider for ALDOperator.class is returned (if found). If cl is a Collection, a provider for Collection.class is returned (if found). If cl is annotated as a parametrized class via ALDParametrizedClass, a provider for ALDParametrizedClassDummy is returned (if found).

Parameters:
cl - class to get an provider for
interfaceRequired - interface needed to be implemented by the provider
Returns:
provider instance or null if none found
Throws:
ALDDataIOManagerException

getProviderMap

public java.util.HashMap<java.lang.Class,java.lang.String> getProviderMap()
Method to return a clone of the mapping of classes to dataIO providers. This method will typically used only be admin tools. The dataIO provider is specified with its full class name.


initMapTable

protected static java.util.HashMap<java.lang.Class,java.lang.String> initMapTable(java.lang.Class interfaceRequired)
Method to initialize the hashmap which registers DataIO providers. Looking up DataIO providers is facilitated with annotions of type ALDDataIO, i.e. a DataIO provider will only be found and registerd, if it is annotated with @ALDDataIO. In addition it has to implement the interface interfaceRequired.

Parameters:
interfaceRequired - Interface which all providers registered are to implement. Is has to be derived from ALDDataIO.