Cytoscape 2.8.0 API

cytoscape.util
Class ZipUtil

java.lang.Object
  extended by cytoscape.util.ZipUtil

public class ZipUtil
extends Object

Compression-related methods mainly for Session Writer.
The created zip files can be decompressed by any zip utilities.

Since:
Cytoscape 2.3
Version:
0.9
Author:
kono
See Also:
CytoscapeSessionWriter

Field Summary
static int DEF_COMPRESSION_LEVEL
           
 
Constructor Summary
ZipUtil(String zipFile, String[] fileNameList, String sessionDir)
          Constructor.
ZipUtil(String zipFile, String[] fileNameList, String sessionDir, String fileDir)
          Constructor.
 
Method Summary
 void compressFast(int compressionLevel, boolean cleanFlag)
          Faster version of compression method.
static List<ZipEntry> getAllFiles(String zipName, String fileNameRegEx)
          Reads zip file, returns a list of all entries that match the given regular expression
static InputStream readFile(String zipName, String fileNameRegEx)
          Deprecated.  
static InputStream readFile(ZipFile sessionZipFile, String fileNameRegEx)
          Reads a file contained within a zip file and returns an InputStream for the specific file you want from within the zip file.
 void setPluginFileMap(HashMap pMap)
          DOCUMENT ME!
static List<String> unzip(String zipName, String unzipDir, TaskMonitor taskMonitor)
          Unzips the given zip file and returns a list of all files unzipped
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEF_COMPRESSION_LEVEL

public static final int DEF_COMPRESSION_LEVEL
See Also:
Constant Field Values
Constructor Detail

ZipUtil

public ZipUtil(String zipFile,
               String[] fileNameList,
               String sessionDir)
Constructor.

Parameters:
zipFile - Output zip file name.
fileNameList - List of file names to be compressed.
sessionDir - Root dir created in the zip archive.

ZipUtil

public ZipUtil(String zipFile,
               String[] fileNameList,
               String sessionDir,
               String fileDir)
Constructor.

Parameters:
zipFile - Output zip file name.
fileNameList - List of file names to be compressed.
sessionDir - Root dir created in the zip archive.
fileDir - root directory of files in fileList.
Method Detail

compressFast

public void compressFast(int compressionLevel,
                         boolean cleanFlag)
                  throws IOException
Faster version of compression method.

Parameters:
compressionLevel - Level of compression. Range = 0-9. 0 is no-compression, and 9 is most space-efficeint. However, 9 is slow.
cleanFlag - If true, remove all imput files.
Throws:
IOException

setPluginFileMap

public void setPluginFileMap(HashMap pMap)
DOCUMENT ME!

Parameters:
pMap - DOCUMENT ME!

readFile

@Deprecated
public static InputStream readFile(String zipName,
                                              String fileNameRegEx)
                            throws IOException
Deprecated. 

Reads a file contained within a zip file and returns an InputStream for the specific file you want from within the zip file.

Parameters:
zipName - The name of the zip file to read.
fileNameRegEx - A regular expression that identifies the file to be read. In general this should just be the file name you're looking for. If more than one file matches the regular expression, only the first will be returned. If you're looking for a specific file remeber to build your regular expression correctly. For example, if you're looking for the file 'vizmap.props', make your regular expression '.*vizmap.props' to accomodate any clutter from the zip file.
Returns:
An InputStream of the zip entry identified by the regular expression or null if nothing matches.
Throws:
IOexception
IOException

readFile

public static InputStream readFile(ZipFile sessionZipFile,
                                   String fileNameRegEx)
                            throws IOException
Reads a file contained within a zip file and returns an InputStream for the specific file you want from within the zip file.

Parameters:
sessionZipFile - The ZipFile in which to look for an entry matching fileNameRegEx.
fileNameRegEx - A regular expression that identifies the file to be read. In general this should just be the file name you're looking for. If more than one file matches the regular expression, only the first will be returned. If you're looking for a specific file remeber to build your regular expression correctly. For example, if you're looking for the file 'vizmap.props', make your regular expression '.*vizmap.props' to accomodate any clutter from the zip file.
Returns:
An InputStream of the zip entry identified by the regular expression or null if nothing matches.
Throws:
IOexception
IOException

getAllFiles

public static List<ZipEntry> getAllFiles(String zipName,
                                         String fileNameRegEx)
                                  throws IOException
Reads zip file, returns a list of all entries that match the given regular expression

Parameters:
zipName -
fileNameRegEx -
Returns:
Throws:
IOException

unzip

public static List<String> unzip(String zipName,
                                 String unzipDir,
                                 TaskMonitor taskMonitor)
                          throws IOException
Unzips the given zip file and returns a list of all files unzipped

Parameters:
is - InputStream for a zip file
Throws:
IOException

Cytoscape 2.8.0 API

Copyright 2010 Cytoscape Consortium. All rights reserved.