Package org.cip4.jdflib.util.zip
Class ZipReader
- java.lang.Object
-
- org.cip4.jdflib.util.zip.ZipReader
-
public class ZipReader extends java.lang.Objectclass to read a zip file or stream
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbuffer()voidclose()java.util.zip.ZipEntryensureEntry()get the next entry - this can be used in non-buffered mode returns null in case of snafujava.util.Vector<java.util.zip.ZipEntry>getEntries()get the vector of zip entriesjava.util.zip.ZipEntrygetEntry(java.lang.String urlString)get an entry by name - note that we need to buffer the entire file for this random access methodstatic java.lang.StringgetEntryName(java.util.zip.ZipEntry ze)retrieves the name and replaces any '\' with '/' and removes any spurious '.' or '..' in the pathjava.io.InputStreamgetInputStream()get the stream to read this from; note that we must close manuallyJDFDocgetJDFDoc()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 methodjava.util.zip.ZipEntrygetMatchingEntry(java.lang.String expr, int iSkip)get an entry by name - note that we need to buffer the entire file for this random access methodintgetMaxBuffer()java.util.zip.ZipEntrygetNextEntry()get the next entry - this can be used in non-buffered mode returns null in case of snafujava.util.zip.ZipEntrygetNextMatchingEntry(java.lang.String expr)get the next entry by expression - note that we need to buffer the entire file for this random access methodjava.lang.StringgetRootEntry()Getter for rootEntry name attribute.XMLDocgetXMLDoc()get the xmlDoc of the current entry - note not threadsafe!static ZipReadergetZipReader(java.io.File jarFile)static ZipReadergetZipReader(java.io.File jarFile, boolean search)static ZipReadergetZipReader(java.io.InputStream is)get a zip reader that searches itself for a valid zip headerstatic ZipReadergetZipReader(java.io.InputStream is, boolean bSearch)get a zip reader that searches itself for a valid zip headerstatic java.util.Vector<ZipReader>getZipReaders(java.io.InputStream is, int max)get a zip reader that searches itself for a valid zip headerbooleanisCaseSensitive()return true if all checks are cese sensitive (the default)voidsetCaseSensitive(boolean caseSensitive)set the case sensitivity for matching strings and regexpbooleansetEntry(java.util.zip.ZipEntry zeSet)get an entry by name - note that we need to buffer the entire file for this random access methodvoidsetMaxBuffer(int maxBuffer)voidsetRootEntry(java.lang.String rootEntry)Setter for rootEntry attribute.java.lang.StringtoString()intunPack(java.io.File dir)unpack into a directorybooleanunPack(java.io.File dir, java.util.zip.ZipEntry ze)unpack an individual entry into a directory
-
-
-
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 acceptediSkip- 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:
toStringin classjava.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:
-
-