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 T
clone(T object)
Creates a new Instance of the providedObject
by creating a XML-String of the Object Data and instantiating a new Object from that Stringprotected abstract com.thoughtworks.xstream.XStream
createXStream()
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.boolean
isCorrectFileName(java.lang.String fileName)
determines if the given name is a correct file nameT
load(java.io.File srcFile)
Creates an object from the given xmlFileT
load(java.io.InputStream inputStream)
loads a new object from an input stream.java.io.File
save(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.File
save(T object, java.io.File destFile, java.util.Map<?,?> context)
void
save(T object, java.io.OutputStream outStream)
Write an object as xml to the given output stream.void
save(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:PersistenceService
Write an object to the given xmlFile, the object/class must provide the appropriate annotations for writing the XML...- Specified by:
save
in 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:
isCorrectFileName
in 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:PersistenceService
Write an object as xml to the given output stream.- Specified by:
save
in 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:PersistenceService
Creates an object from the given xmlFile- Specified by:
load
in 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:PersistenceService
loads a new object from an input stream.- Specified by:
load
in 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:PersistenceService
Creates a new Instance of the providedObject
by creating a XML-String of the Object Data and instantiating a new Object from that String- Specified by:
clone
in interfacePersistenceService<T>
- Parameters:
object
- theObject
you want to get a clone from- Returns:
- the cloned Object
- Throws:
PersistenceServiceException
- if the cloning of the object fails
-
-