Class TCZ


  • public class TCZ
    extends java.lang.Object
    A tcz (TotalCross Zip) file has the following format:
    • version (2 bytes)
    • attributes (2 bytes)
    • base offset (header size + 4)
    • header
    • compressed data chunks
    The header is:
    • length (4 bytes)
    • offsets array (length+1) - offset[i+1]-offset[i] gives the compressed size
    • uncompressed sizes array (length)
    • names array (length)
    The header is compressed to save space. The first record is the class that implements totalcross.MainClass or extends totalcross.ui.MainWindow.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  TCZ.Entry
      An entry of the TCZ file.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int attr
      The attributes.
      static short ATTR_HAS_MAINCLASS
      Defines that the tcz file has a MainClass at the first record.
      static short ATTR_HAS_MAINWINDOW
      Defines that the tcz file has a MainWindow at the first record.
      static short ATTR_LIBRARY
      Defines that the tcz file is a library-only module.
      static short ATTR_RESIZABLE_WINDOW
      Defines that the application has resizable window.
      static short ATTR_WINDOWFONT_DEFAULT
      Defines that the application uses the default font.
      static short ATTR_WINDOWSIZE_320X480
      Defines that the application uses the given window size.
      static short ATTR_WINDOWSIZE_480X640
      Defines that the application uses the given window size.
      static short ATTR_WINDOWSIZE_600X800
      Defines that the application uses the given window size.
      java.lang.Object bag
      Bag that can be used to store anything that the user wants.
      static java.lang.String mainClassName
      Set this to be the main class name.
      java.lang.String[] names
      The names of the files.
      int numberOfChunks
      The number of chunks.
      int[] offsets
      Offsets to the compressed data chunks
      int size
      Stores the total size when a TCZ file is created.
      static short TCZ_VERSION  
      int[] uncompressedSizes
      Sizes of the data chunks when they are uncompressed.
      int version
      Version of the tcz file.
    • Constructor Summary

      Constructors 
      Constructor Description
      TCZ​(Stream fin)
      Reads a TCZ file and fill the public members available in this class: version, attr, baseOffset, offsets, uncompressedSizes, names, chunks, numberOfChunks.
      TCZ​(Vector vout, java.lang.String outName, short attr)
      Create a TCZ file with the given vector of Entry(s).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int findNamePosition​(java.lang.String name)
      Finds the position of the given name in this tcz.
      int getNextChunkSize()
      Returns the size of the next available chunk
      void readNextChunk​(Stream out)
      Fills the given stream with the next available chunk.
      • Methods inherited from class java.lang.Object

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

      • mainClassName

        public static java.lang.String mainClassName
        Set this to be the main class name. It is stored in record #0.
      • ATTR_HAS_MAINCLASS

        public static final short ATTR_HAS_MAINCLASS
        Defines that the tcz file has a MainClass at the first record. If false, it is a library-only module
        See Also:
        Constant Field Values
      • ATTR_HAS_MAINWINDOW

        public static final short ATTR_HAS_MAINWINDOW
        Defines that the tcz file has a MainWindow at the first record.
        See Also:
        Constant Field Values
      • ATTR_LIBRARY

        public static final short ATTR_LIBRARY
        Defines that the tcz file is a library-only module.
        See Also:
        Constant Field Values
      • ATTR_RESIZABLE_WINDOW

        public static final short ATTR_RESIZABLE_WINDOW
        Defines that the application has resizable window.
        See Also:
        Constant Field Values
      • ATTR_WINDOWFONT_DEFAULT

        public static final short ATTR_WINDOWFONT_DEFAULT
        Defines that the application uses the default font.
        See Also:
        Constant Field Values
      • ATTR_WINDOWSIZE_320X480

        public static final short ATTR_WINDOWSIZE_320X480
        Defines that the application uses the given window size.
        See Also:
        Constant Field Values
      • ATTR_WINDOWSIZE_480X640

        public static final short ATTR_WINDOWSIZE_480X640
        Defines that the application uses the given window size.
        See Also:
        Constant Field Values
      • ATTR_WINDOWSIZE_600X800

        public static final short ATTR_WINDOWSIZE_600X800
        Defines that the application uses the given window size.
        See Also:
        Constant Field Values
      • names

        public java.lang.String[] names
        The names of the files.
      • version

        public int version
        Version of the tcz file.
        See Also:
        TCZ_VERSION
      • offsets

        public int[] offsets
        Offsets to the compressed data chunks
      • uncompressedSizes

        public int[] uncompressedSizes
        Sizes of the data chunks when they are uncompressed.
      • numberOfChunks

        public int numberOfChunks
        The number of chunks.
      • size

        public int size
        Stores the total size when a TCZ file is created.
      • bag

        public java.lang.Object bag
        Bag that can be used to store anything that the user wants.
    • Constructor Detail

      • TCZ

        public TCZ​(Stream fin)
            throws IOException
        Reads a TCZ file and fill the public members available in this class: version, attr, baseOffset, offsets, uncompressedSizes, names, chunks, numberOfChunks. To preserve memory, you must request each chunk using readNextChunk right after you call this constructor.
        Throws:
        IOException
    • Method Detail

      • getNextChunkSize

        public int getNextChunkSize()
        Returns the size of the next available chunk
      • readNextChunk

        public void readNextChunk​(Stream out)
                           throws IOException
        Fills the given stream with the next available chunk. The size of the chunk can be retrieved with getNextChunkSize. If out is a ByteArrayStream, don't forget to call reset before starting to read from it!
        Throws:
        IOException
      • findNamePosition

        public int findNamePosition​(java.lang.String name)
        Finds the position of the given name in this tcz.