com.atlassian.jira.issue.attachment
Class AttachmentZipKit

java.lang.Object
  extended by com.atlassian.jira.issue.attachment.AttachmentZipKit

public class AttachmentZipKit
extends Object

This class will help when working with zip files

Since:
4.1

Nested Class Summary
static interface AttachmentZipKit.AttachmentZipEntries
           
static interface AttachmentZipKit.AttachmentZipEntry
          These are the data returned about entries in a zip file
static class AttachmentZipKit.FileCriteria
           
static class AttachmentZipKit.ZipEntryInputStream
           
 
Constructor Summary
AttachmentZipKit()
           
 
Method Summary
 AttachmentZipKit.ZipEntryInputStream extractFile(File zipFile, long entryIndex)
          This will extract an OutputStream of the contents of the file at entryIndex within the zip file.
 boolean isZip(File file)
          This will return true if the file is in fact a valid zip file.
 AttachmentZipKit.AttachmentZipEntries listEntries(File zipFile, int maxEntries, AttachmentZipKit.FileCriteria criteria)
          This will return a list of AttachmentZipKit.AttachmentZipEntrys for a given zip file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttachmentZipKit

public AttachmentZipKit()
Method Detail

isZip

public boolean isZip(File file)
This will return true if the file is in fact a valid zip file.

Parameters:
file - the file in play.
Returns:
true if its actually a readable zip file.

extractFile

public AttachmentZipKit.ZipEntryInputStream extractFile(File zipFile,
                                                        long entryIndex)
                                                 throws IOException
This will extract an OutputStream of the contents of the file at entryIndex within the zip file. If no file can be found be at that entryIndex or the entry is a directory then null will be returned.

Parameters:
zipFile - the zip file in play
entryIndex - the entryIndex of the entry to return
Returns:
an AttachmentZipKit.ZipEntryInputStream that can be read from for data and has extra ZipArchiveEntry information.
Throws:
IOException - if things go wrong during reading

listEntries

public AttachmentZipKit.AttachmentZipEntries listEntries(File zipFile,
                                                         int maxEntries,
                                                         AttachmentZipKit.FileCriteria criteria)
                                                  throws IOException
This will return a list of AttachmentZipKit.AttachmentZipEntrys for a given zip file

Parameters:
zipFile - the ZIP file in play
criteria - the criteria of which entries to return
maxEntries - the maximum number of entries to put in th list. If this is -negative then not maximum is used.
Returns:
a list of entries
Throws:
IOException - if the file cant be read or is not a zip. file.


Copyright © 2002-2013 Atlassian. All Rights Reserved.