Class ZipReader


  • public class ZipReader
    extends java.lang.Object
    class to read a zip file or stream
    • Constructor Summary

      Constructors 
      Constructor Description
      ZipReader​(java.io.File file)  
      ZipReader​(java.io.File file, int maxBuffer)  
      ZipReader​(java.io.InputStream inStream)  
      ZipReader​(java.io.InputStream inStream, int maxBuffer)  
      ZipReader​(java.lang.String fileName)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void buffer()  
      void close()  
      java.util.zip.ZipEntry ensureEntry()
      get the next entry - this can be used in non-buffered mode returns null in case of snafu
      java.util.Vector<java.util.zip.ZipEntry> getEntries()
      get the vector of zip entries
      java.util.zip.ZipEntry getEntry​(java.lang.String urlString)
      get an entry by name - note that we need to buffer the entire file for this random access method
      static java.lang.String getEntryName​(java.util.zip.ZipEntry ze)
      retrieves the name and replaces any '\' with '/' and removes any spurious '.' or '..' in the path
      java.io.InputStream getInputStream()
      get the stream to read this from; note that we must close manually
      JDFDoc getJDFDoc()
      get the xmlDoc of the current entry - note not threadsafe!
      java.util.Vector<java.util.zip.ZipEntry> getMatchingEntries​(java.lang.String expr, boolean sortName)
      get entries by name - note that we need to buffer the entire file for this random access method
      java.util.zip.ZipEntry getMatchingEntry​(java.lang.String expr, int iSkip)
      get an entry by name - note that we need to buffer the entire file for this random access method
      int getMaxBuffer()  
      java.util.zip.ZipEntry getNextEntry()
      get the next entry - this can be used in non-buffered mode returns null in case of snafu
      java.util.zip.ZipEntry getNextMatchingEntry​(java.lang.String expr)
      get the next entry by expression - note that we need to buffer the entire file for this random access method
      java.lang.String getRootEntry()
      Getter for rootEntry name attribute.
      XMLDoc getXMLDoc()
      get the xmlDoc of the current entry - note not threadsafe!
      static ZipReader getZipReader​(java.io.File jarFile)  
      static ZipReader getZipReader​(java.io.File jarFile, boolean search)  
      static ZipReader getZipReader​(java.io.InputStream is)
      get a zip reader that searches itself for a valid zip header
      static ZipReader getZipReader​(java.io.InputStream is, boolean bSearch)
      get a zip reader that searches itself for a valid zip header
      static java.util.Vector<ZipReader> getZipReaders​(java.io.InputStream is, int max)
      get a zip reader that searches itself for a valid zip header
      boolean isCaseSensitive()
      return true if all checks are cese sensitive (the default)
      void setCaseSensitive​(boolean caseSensitive)
      set the case sensitivity for matching strings and regexp
      boolean setEntry​(java.util.zip.ZipEntry zeSet)
      get an entry by name - note that we need to buffer the entire file for this random access method
      void setMaxBuffer​(int maxBuffer)  
      void setRootEntry​(java.lang.String rootEntry)
      Setter for rootEntry attribute.
      java.lang.String toString()  
      int unPack​(java.io.File dir)
      unpack into a directory
      boolean unPack​(java.io.File dir, java.util.zip.ZipEntry ze)
      unpack an individual entry into a directory
      • Methods inherited from class java.lang.Object

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

      • ZipReader

        public ZipReader​(java.io.InputStream inStream)
        Parameters:
        inStream -
        maxBuffer -
      • ZipReader

        public ZipReader​(java.io.InputStream inStream,
                         int maxBuffer)
        Parameters:
        inStream -
        maxBuffer -
      • ZipReader

        public ZipReader​(java.io.File file)
        Parameters:
        file - the file to read
      • ZipReader

        public ZipReader​(java.io.File file,
                         int maxBuffer)
        Parameters:
        file - the file to read
      • ZipReader

        public ZipReader​(java.lang.String fileName)
        Parameters:
        fileName -
    • Method Detail

      • getMaxBuffer

        public int getMaxBuffer()
      • setMaxBuffer

        public void setMaxBuffer​(int maxBuffer)
      • getRootEntry

        public java.lang.String getRootEntry()
        Getter for rootEntry name attribute.
        Returns:
        the rootEntry name, null if not set
      • setRootEntry

        public void setRootEntry​(java.lang.String rootEntry)
        Setter for rootEntry attribute. use this to allow local searches relative to rootEntry
        Parameters:
        rootEntry - the rootEntry to set
      • isCaseSensitive

        public boolean isCaseSensitive()
        return true if all checks are cese sensitive (the default)
        Returns:
      • setCaseSensitive

        public void setCaseSensitive​(boolean caseSensitive)
        set the case sensitivity for matching strings and regexp
        Parameters:
        caseSensitive -
      • getEntries

        public java.util.Vector<java.util.zip.ZipEntry> getEntries()
        get the vector of zip entries
        Returns:
      • ensureEntry

        public java.util.zip.ZipEntry ensureEntry()
        get the next entry - this can be used in non-buffered mode returns null in case of snafu
        Returns:
      • getNextEntry

        public java.util.zip.ZipEntry getNextEntry()
        get the next entry - this can be used in non-buffered mode returns null in case of snafu
        Returns:
      • unPack

        public int unPack​(java.io.File dir)
        unpack into a directory
        Parameters:
        dir - the destination directory
        Returns:
      • unPack

        public boolean unPack​(java.io.File dir,
                              java.util.zip.ZipEntry ze)
        unpack an individual entry into a directory
        Parameters:
        dir -
        ze -
        Returns:
        true if copied
      • getEntryName

        public static java.lang.String getEntryName​(java.util.zip.ZipEntry ze)
        retrieves the name and replaces any '\' with '/' and removes any spurious '.' or '..' in the path
        Parameters:
        ze -
        Returns:
      • getZipReader

        public static ZipReader getZipReader​(java.io.InputStream is)
        get a zip reader that searches itself for a valid zip header
        Parameters:
        is -
      • getZipReader

        public static ZipReader getZipReader​(java.io.InputStream is,
                                             boolean bSearch)
        get a zip reader that searches itself for a valid zip header
        Parameters:
        is -
      • getZipReaders

        public static java.util.Vector<ZipReader> getZipReaders​(java.io.InputStream is,
                                                                int max)
        get a zip reader that searches itself for a valid zip header
        Parameters:
        is -
      • getEntry

        public java.util.zip.ZipEntry getEntry​(java.lang.String urlString)
        get an entry by name - note that we need to buffer the entire file for this random access method
        Parameters:
        urlString - the file path (case sensitive)
        Returns:
      • setEntry

        public boolean setEntry​(java.util.zip.ZipEntry zeSet)
        get an entry by name - note that we need to buffer the entire file for this random access method
        Parameters:
        zeSet - the zip entry to set
        Returns:
      • getMatchingEntry

        public java.util.zip.ZipEntry getMatchingEntry​(java.lang.String expr,
                                                       int iSkip)
        get an entry by name - note that we need to buffer the entire file for this random access method
        Parameters:
        expr - the regexp of the path (including directories) to match - simplified regexp is accepted
        iSkip - how many to skip - default= 0
        Returns:
      • getMatchingEntries

        public java.util.Vector<java.util.zip.ZipEntry> getMatchingEntries​(java.lang.String expr,
                                                                           boolean sortName)
        get entries by name - note that we need to buffer the entire file for this random access method
        Parameters:
        expr - the regexp of the path (including directories) to match - simplified regexp is accepted
        Returns:
      • getNextMatchingEntry

        public java.util.zip.ZipEntry getNextMatchingEntry​(java.lang.String expr)
        get the next entry by expression - note that we need to buffer the entire file for this random access method
        Parameters:
        expr - the regexp to match - simplified regexp is accepted
        Returns:
      • getInputStream

        public java.io.InputStream getInputStream()
        get the stream to read this from; note that we must close manually
        Returns:
      • getXMLDoc

        public XMLDoc getXMLDoc()
        get the xmlDoc of the current entry - note not threadsafe!
        Returns:
      • getJDFDoc

        public JDFDoc getJDFDoc()
        get the xmlDoc of the current entry - note not threadsafe!
        Returns:
      • buffer

        public void buffer()
      • close

        public void close()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()
      • getZipReader

        public static ZipReader getZipReader​(java.io.File jarFile)
        Parameters:
        jarFile -
        Returns:
      • getZipReader

        public static ZipReader getZipReader​(java.io.File jarFile,
                                             boolean search)
        Parameters:
        jarFile -
        Returns: