Interface PersistenceService<T>

    • Method Summary

      All Methods Instance Methods Abstract 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
      java.lang.String getFileExtension()  
      boolean isCorrectFileName​(java.lang.String fileName)  
      T load​(java.io.File file)
      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 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 XML
        file - 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 write
        outStream - 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 provided Object by creating a XML-String of the Object Data and instantiating a new Object from that String
        Parameters:
        object - the Object 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)