Class TransferUtil


  • public class TransferUtil
    extends java.lang.Object
    Transfer object utilities Includes various methods for object serialization/deserialization
    Author:
    Ruslan Nazirov
    • Constructor Summary

      Constructors 
      Constructor Description
      TransferUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] compress​(byte[] data)
      Compress selected serialized data
      static byte[] decompress​(byte[] compressedData)
      Deserialize selected compressed data
      static java.lang.Object decompressAndDecerialize​(byte[] data)
      Decompress and deserialize selected data
      static java.lang.Object deserialize​(byte[] data)
      Deserialize selected serialized data
      static byte[] serialize​(java.lang.Object object)
      Serialize selected object
      static byte[] serializeAndCompress​(java.lang.Object object)
      Serialize and compress selected object
      static java.util.HashMap<java.util.zip.ZipEntry,​java.io.ByteArrayOutputStream> unzip​(int bufferSize, java.lang.String zipExtension, java.io.ByteArrayOutputStream zippedFileOS)
      Unzip archive on file system and get it content to operate
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TransferUtil

        public TransferUtil()
    • Method Detail

      • serializeAndCompress

        public static byte[] serializeAndCompress​(java.lang.Object object)
                                           throws java.lang.Exception
        Serialize and compress selected object
        Parameters:
        object - Object to operate
        Returns:
        Serialized and compressed data or null if error happened
        Throws:
        java.lang.Exception - exception, which happened during this method execution
      • decompressAndDecerialize

        public static java.lang.Object decompressAndDecerialize​(byte[] data)
                                                         throws java.lang.Exception
        Decompress and deserialize selected data
        Parameters:
        data - Compressed and serialized data
        Returns:
        Decompressed and deserialized object or null if error happened
        Throws:
        java.lang.Exception - exception, which happened during this method execution
      • serialize

        public static byte[] serialize​(java.lang.Object object)
                                throws java.lang.Exception
        Serialize selected object
        Parameters:
        object - Object to serialize
        Returns:
        Serialized data
        Throws:
        java.lang.Exception - exception, which happened during this method execution
      • compress

        public static byte[] compress​(byte[] data)
                               throws java.lang.Exception
        Compress selected serialized data
        Parameters:
        data - Serialized data
        Returns:
        Compressed data
        Throws:
        java.lang.Exception - exception, which happened during this method execution
      • deserialize

        public static java.lang.Object deserialize​(byte[] data)
                                            throws java.lang.Exception
        Deserialize selected serialized data
        Parameters:
        data - Serialized data
        Returns:
        Original object
        Throws:
        java.lang.Exception - exception, which happened during this method execution
      • unzip

        public static java.util.HashMap<java.util.zip.ZipEntry,​java.io.ByteArrayOutputStream> unzip​(int bufferSize,
                                                                                                          java.lang.String zipExtension,
                                                                                                          java.io.ByteArrayOutputStream zippedFileOS)
        Unzip archive on file system and get it content to operate
        Parameters:
        bufferSize - size of the buffer
        zipExtension - extension of zipped archives to search archives inside archive
        zippedFileOS - zip archive file via ByteArrayOutputStream
        Returns:
        HashMap with ZipEntry and ByteArrayOutputStream, which allows you to access files inside zip archive
      • decompress

        public static byte[] decompress​(byte[] compressedData)
                                 throws java.lang.Exception
        Deserialize selected compressed data
        Parameters:
        compressedData - Compressed Data
        Returns:
        Decompressed Data
        Throws:
        java.lang.Exception - exception, which happened during this method execution