Class GenericXStreamService<T>

    • 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 provided Object by creating a XML-String of the Object Data and instantiating a new Object from that String
      protected 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 name
      T load​(java.io.File srcFile)
      Creates an object from the given xmlFile
      T 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
    • Constructor Detail

      • GenericXStreamService

        public GenericXStreamService()
    • 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)
                                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 interface PersistenceService<T>
        Parameters:
        object - Object to write to XML
        destFile - 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 interface PersistenceService<T>
        Parameters:
        fileName - the file name to check
        Returns:
        true if it is an xml file name, false if not