Class GenericXStreamService<T>
- java.lang.Object
-
- cern.accsoft.steering.jmad.util.xml.GenericXStreamService<T>
-
- All Implemented Interfaces:
PersistenceService<T>
- Direct Known Subclasses:
AbstractXStreamService
public abstract class GenericXStreamService<T> extends java.lang.Object implements PersistenceService<T>
-
-
Constructor Summary
Constructors Constructor Description GenericXStreamService()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Tclone(T object)Creates a new Instance of the providedObjectby creating a XML-String of the Object Data and instantiating a new Object from that Stringprotected abstract com.thoughtworks.xstream.XStreamcreateXStream()This method must be implemented by subclass and has to return a properly configured XStream object.protected abstract java.lang.Class<? extends T>getSaveableClass()Has to return the class which can be saved by this service.booleanisCorrectFileName(java.lang.String fileName)determines if the given name is a correct file nameTload(java.io.File srcFile)Creates an object from the given xmlFileTload(java.io.InputStream inputStream)loads a new object from an input stream.java.io.Filesave(T object, java.io.File destFile)Write an object to the given xmlFile, the object/class must provide the appropriate annotations for writing the XML...java.io.Filesave(T object, java.io.File destFile, java.util.Map<?,?> context)voidsave(T object, java.io.OutputStream outStream)Write an object as xml to the given output stream.voidsave(T object, java.io.OutputStream outStream, java.util.Map<?,?> context)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface cern.accsoft.steering.jmad.util.xml.PersistenceService
getFileExtension
-
-
-
-
Method Detail
-
createXStream
protected abstract com.thoughtworks.xstream.XStream createXStream()
This method must be implemented by subclass and has to return a properly configured XStream object.- Returns:
- a fully configured xstream object
-
getSaveableClass
protected abstract java.lang.Class<? extends T> getSaveableClass()
Has to return the class which can be saved by this service. This is used for checking and producing an error message, if an object cannot be saved.- Returns:
- The class which can be saved by this persistence service
-
save
public final java.io.File save(T object, java.io.File destFile, java.util.Map<?,?> context) throws PersistenceServiceException
- Throws:
PersistenceServiceException
-
save
public final java.io.File save(T object, java.io.File destFile) throws PersistenceServiceException
Description copied from interface:PersistenceServiceWrite an object to the given xmlFile, the object/class must provide the appropriate annotations for writing the XML...- Specified by:
savein interfacePersistenceService<T>- Parameters:
object- Object to write to XMLdestFile- the file to write to...- Returns:
- the file where it was saved in the end ..
- Throws:
PersistenceServiceException- if the serializing fails
-
isCorrectFileName
public final boolean isCorrectFileName(java.lang.String fileName)
determines if the given name is a correct file name- Specified by:
isCorrectFileNamein interfacePersistenceService<T>- Parameters:
fileName- the file name to check- Returns:
- true if it is an xml file name, false if not
-
save
public void save(T object, java.io.OutputStream outStream, java.util.Map<?,?> context) throws PersistenceServiceException
- Throws:
PersistenceServiceException
-
save
public void save(T object, java.io.OutputStream outStream) throws PersistenceServiceException
Description copied from interface:PersistenceServiceWrite an object as xml to the given output stream.- Specified by:
savein interfacePersistenceService<T>- Parameters:
object- the object to writeoutStream- the output stream to write to- Throws:
PersistenceServiceException- if something fails
-
load
public T load(java.io.File srcFile) throws PersistenceServiceException
Description copied from interface:PersistenceServiceCreates an object from the given xmlFile- Specified by:
loadin interfacePersistenceService<T>- Parameters:
srcFile- the xmlFile to load the object from- Returns:
- the object created from XML or null in case of failure
- Throws:
PersistenceServiceException- if the loading of the object fails
-
load
public T load(java.io.InputStream inputStream) throws PersistenceServiceException
Description copied from interface:PersistenceServiceloads a new object from an input stream.- Specified by:
loadin interfacePersistenceService<T>- Parameters:
inputStream- the input stream from which to read- Returns:
- the new object
- Throws:
PersistenceServiceException- if the loading of the object fails
-
clone
public T clone(T object) throws PersistenceServiceException
Description copied from interface:PersistenceServiceCreates a new Instance of the providedObjectby creating a XML-String of the Object Data and instantiating a new Object from that String- Specified by:
clonein interfacePersistenceService<T>- Parameters:
object- theObjectyou want to get a clone from- Returns:
- the cloned Object
- Throws:
PersistenceServiceException- if the cloning of the object fails
-
-