Class ZipReader

java.lang.Object
org.cip4.jdflib.util.zip.ZipReader

public class ZipReader extends Object
class to read a zip file or stream
  • Constructor Details

    • ZipReader

      public ZipReader(InputStream inStream)
      Parameters:
      inStream -
      maxBuffer -
    • ZipReader

      public ZipReader(InputStream inStream, int maxBuffer)
      Parameters:
      inStream -
      maxBuffer -
    • ZipReader

      public ZipReader(File file)
      Parameters:
      file - the file to read
    • ZipReader

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

      public ZipReader(String fileName)
      Parameters:
      fileName -
  • Method Details

    • getMaxBuffer

      public int getMaxBuffer()
    • setMaxBuffer

      public void setMaxBuffer(int maxBuffer)
    • getRootEntry

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

      public void setRootEntry(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 Vector<ZipEntry> getEntries()
      get the vector of zip entries
      Returns:
    • ensureEntry

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

      public 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(File dir)
      unpack into a directory
      Parameters:
      dir - the destination directory
      Returns:
    • unPack

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

      public static String getEntryName(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(InputStream is)
      get a zip reader that searches itself for a valid zip header
      Parameters:
      is -
    • getZipReader

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

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

      public ZipEntry getEntry(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(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 ZipEntry getMatchingEntry(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 Vector<ZipEntry> getMatchingEntries(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 ZipEntry getNextMatchingEntry(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 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 String toString()
      Overrides:
      toString in class Object
      See Also:
    • getZipReader

      public static ZipReader getZipReader(File jarFile)
      Parameters:
      jarFile -
      Returns:
    • getZipReader

      public static ZipReader getZipReader(File jarFile, boolean search)
      Parameters:
      jarFile -
      Returns: