de.unihalle.informatik.Alida.dataio
Class ALDDataIOManagerXmlbeans

java.lang.Object
  extended by de.unihalle.informatik.Alida.dataio.ALDDataIOManager
      extended by de.unihalle.informatik.Alida.dataio.ALDDataIOManagerXmlbeans

public class ALDDataIOManagerXmlbeans
extends ALDDataIOManager

This class implements a DataIO manager for reading/writing from xml using xmlbeans. For reading and writing, it essentially looks up the correct provider for xml using the method of its super class and invokes its method.

It does its work in collaboration with ALDDataIOXmlbeans.

Author:
posch

Field Summary
private  boolean allowAdditionalFields
          If true additional fields/variables and so on should be tolerated by providers
private  boolean doHistory
          If true writeData should try to write the history to file if the object itself is written to a file
(package private) static ALDDataIOManagerXmlbeans instance
          The singleton instance of this class
 
Fields inherited from class de.unihalle.informatik.Alida.dataio.ALDDataIOManager
debug, mapTable
 
Constructor Summary
private ALDDataIOManagerXmlbeans()
          private constructor
 
Method Summary
static ALDDataIOManagerXmlbeans getInstance()
          Return the single instance of this class
 boolean isAllowAdditionalFields()
           
 boolean isDoHistory()
           
 java.lang.Object readData(java.lang.reflect.Field field, java.lang.Class<?> cl, de.unihalle.informatik.Alida_xml.ALDXMLObjectType xmlObject)
          Reads data of given class from a specified source.
static java.lang.Object readXml(java.io.File file, java.lang.Class<?> clazz)
          Read Object from a file using xmlbeans providers
static java.lang.Object readXml(java.lang.String filename, java.lang.Class<?> clazz)
          Read Object from a file using xmlbeans providers
 void setAllowAdditionalFields(boolean allowAdditionalFields)
           
 void setDoHistory(boolean doHistory)
           
 de.unihalle.informatik.Alida_xml.ALDXMLObjectType writeData(java.lang.Object obj)
          Writes data to the specified location.
static void writeXml(java.io.File file, java.lang.Object obj)
          Write to object to a file using xmlbeans providers
static void writeXml(java.lang.String filename, java.lang.Object obj)
          Write to object to a file using xmlbeans providers
 
Methods inherited from class de.unihalle.informatik.Alida.dataio.ALDDataIOManager
getProvider, getProviderMap, initMapTable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

allowAdditionalFields

private boolean allowAdditionalFields
If true additional fields/variables and so on should be tolerated by providers


doHistory

private boolean doHistory
If true writeData should try to write the history to file if the object itself is written to a file


instance

static final ALDDataIOManagerXmlbeans instance
The singleton instance of this class

Constructor Detail

ALDDataIOManagerXmlbeans

private ALDDataIOManagerXmlbeans()
private constructor

Method Detail

getInstance

public static ALDDataIOManagerXmlbeans getInstance()
Return the single instance of this class

Returns:
single instance

isAllowAdditionalFields

public boolean isAllowAdditionalFields()
Returns:
the allowAdditionalFields

isDoHistory

public boolean isDoHistory()
Returns:
the writeHistory

readData

public java.lang.Object readData(java.lang.reflect.Field field,
                                 java.lang.Class<?> cl,
                                 de.unihalle.informatik.Alida_xml.ALDXMLObjectType xmlObject)
                          throws ALDDataIOManagerException,
                                 ALDDataIOProviderException
Reads data of given class from a specified source. If both field and cl are non-null, the class defined in field is used and cl ignored. If one of field or cl is null, the other non null argument will be used. Some objects can only be read if field is supplied, e.g. Collections.

The xmlObject is used to actually read the data. The interpretation is specific to the class to be read and defined by the corresponding provider class.

Parameters:
field - field of object to be returned.
cl - Class of data to be read.
xmlObject - xml object to read data from.
Returns:
Read data object
Throws:
ALDDataIOManagerException
ALDDataIOProviderException

readXml

public static java.lang.Object readXml(java.io.File file,
                                       java.lang.Class<?> clazz)
                                throws org.apache.xmlbeans.XmlException,
                                       ALDDataIOManagerException,
                                       ALDDataIOProviderException
Read Object from a file using xmlbeans providers

Parameters:
filename -
clazz -
Returns:
Throws:
org.apache.xmlbeans.XmlException
java.io.IOException
ALDDataIOManagerException
ALDDataIOProviderException

readXml

public static java.lang.Object readXml(java.lang.String filename,
                                       java.lang.Class<?> clazz)
                                throws org.apache.xmlbeans.XmlException,
                                       ALDDataIOManagerException,
                                       ALDDataIOProviderException
Read Object from a file using xmlbeans providers

Parameters:
filename -
clazz -
Returns:
Throws:
org.apache.xmlbeans.XmlException
java.io.IOException
ALDDataIOManagerException
ALDDataIOProviderException

setAllowAdditionalFields

public void setAllowAdditionalFields(boolean allowAdditionalFields)
Parameters:
allowAdditionalFields - the allowAdditionalFields to set

setDoHistory

public void setDoHistory(boolean doHistory)
Parameters:
writeHistory - the writeHistory to set

writeData

public de.unihalle.informatik.Alida_xml.ALDXMLObjectType writeData(java.lang.Object obj)
                                                            throws ALDDataIOManagerException,
                                                                   ALDDataIOProviderException
Writes data to the specified location. This method may return a xml object with a representation of parameters value.

Parameters:
obj - Object to write.
Returns:
ALDXMLObjectType from obj
Throws:
ALDDataIOManagerException
ALDDataIOProviderException

writeXml

public static void writeXml(java.io.File file,
                            java.lang.Object obj)
                     throws ALDDataIOProviderException,
                            ALDDataIOManagerException
Write to object to a file using xmlbeans providers

Parameters:
file -
obj -
Throws:
ALDDataIOProviderException
ALDDataIOManagerException

writeXml

public static void writeXml(java.lang.String filename,
                            java.lang.Object obj)
                     throws ALDDataIOProviderException,
                            ALDDataIOManagerException
Write to object to a file using xmlbeans providers

Parameters:
filename -
obj -
Throws:
ALDDataIOProviderException
ALDDataIOManagerException