Interface PersistenceService<T>
-
- Type Parameters:
T
- the type of the object which can be saved and loaded
- All Known Subinterfaces:
ModelDefinitionPersistenceService
- All Known Implementing Classes:
AbstractModelDefinitionPersistenceService
,AbstractXStreamService
,GenericXStreamService
,JsonXStreamService
,MadxScriptModelDefinitionPersistenceService
,XmlModelDefinitionPersistenceService
,XmlXStreamService
public interface PersistenceService<T>
Represents a general service to store java objects into xml files. It uses theXStream
mechanism to accomplish this task.
-
-
Method Summary
All Methods Instance Methods Abstract 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 Stringjava.lang.String
getFileExtension()
boolean
isCorrectFileName(java.lang.String fileName)
T
load(java.io.File file)
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 file)
Write an object to the given xmlFile, the object/class must provide the appropriate annotations for writing the XML...void
save(T object, java.io.OutputStream outStream)
Write an object as xml to the given output stream.
-
-
-
Method Detail
-
save
java.io.File save(T object, java.io.File file) throws PersistenceServiceException
Write an object to the given xmlFile, the object/class must provide the appropriate annotations for writing the XML...- Parameters:
object
- Object to write to XMLfile
- the file to write to...- Returns:
- the file where it was saved in the end ..
- Throws:
PersistenceServiceException
- if the serializing fails
-
save
void save(T object, java.io.OutputStream outStream) throws PersistenceServiceException
Write an object as xml to the given output stream.- Parameters:
object
- the object to writeoutStream
- the output stream to write to- Throws:
PersistenceServiceException
- if something fails
-
load
T load(java.io.File file) throws PersistenceServiceException
Creates an object from the given xmlFile- Parameters:
file
- 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
T load(java.io.InputStream inputStream) throws PersistenceServiceException
loads a new object from an input stream.- Parameters:
inputStream
- the input stream from which to read- Returns:
- the new object
- Throws:
PersistenceServiceException
- if the loading of the object fails
-
clone
T clone(T object) throws PersistenceServiceException
Creates a new Instance of the providedObject
by creating a XML-String of the Object Data and instantiating a new Object from that String- Parameters:
object
- theObject
you want to get a clone from- Returns:
- the cloned Object
- Throws:
PersistenceServiceException
- if the cloning of the object fails
-
getFileExtension
java.lang.String getFileExtension()
- Returns:
- the file extension which is used to load/save files
-
isCorrectFileName
boolean isCorrectFileName(java.lang.String fileName)
-
-