Class ItemSerializer


  • public class ItemSerializer
    extends java.lang.Object
    ItemSerializer facilitates the compressing and writing of a data stream to a "packed" file. The resulting "packed" file will contain the following meta-data which is available after construction:
    • Item name
    • Content type (int)
    • File type (int)
    • Data length
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isPackedFile​(java.io.File file)
      A simple utility method to determine if the given file is a packed file as created by this class.
      static boolean isPackedFile​(java.io.InputStream inputStream)
      A convenience method for checking if the file denoted by the given inputStream is a packed file.
      static void outputItem​(java.lang.String itemName, java.lang.String contentType, int fileType, long length, java.io.InputStream content, java.io.File packedFile, TaskMonitor monitor)
      Read and compress data from the specified content stream and write to a packed file along with additional meta-data.
      • Methods inherited from class java.lang.Object

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

      • outputItem

        public static void outputItem​(java.lang.String itemName,
                                      java.lang.String contentType,
                                      int fileType,
                                      long length,
                                      java.io.InputStream content,
                                      java.io.File packedFile,
                                      TaskMonitor monitor)
                               throws CancelledException,
                                      java.io.IOException
        Read and compress data from the specified content stream and write to a packed file along with additional meta-data.
        Parameters:
        itemName - item name
        contentType - content type
        fileType - file type
        length - content length to be read
        content - content input stream
        packedFile - output packed file to be created
        monitor - task monitor
        Throws:
        CancelledException
        java.io.IOException
      • isPackedFile

        public static boolean isPackedFile​(java.io.File file)
                                    throws java.io.IOException
        A simple utility method to determine if the given file is a packed file as created by this class.
        Parameters:
        file - The file to check
        Returns:
        True if it is a packed file
        Throws:
        java.io.IOException - If there is a problem reading the given file
      • isPackedFile

        public static boolean isPackedFile​(java.io.InputStream inputStream)
                                    throws java.io.IOException
        A convenience method for checking if the file denoted by the given inputStream is a packed file.

        Note: This method will NOT close the given inputStream.

        Parameters:
        inputStream - a stream for accessing bytes of what may be a packed file
        Returns:
        true if the bytes from the inputStream represent the bytes of a packed file
        Throws:
        java.io.IOException - If there is a problem accessing the inputStream
        See Also:
        isPackedFile(File)