# Class: com.pnfsoftware.jeb.util.encoding.zip.fsr.ZipFailSafeReader

PNF Software's Zip Fail Safe Reader \(PZFSR\). This parser attempts to handle corner\-cases that fail Oracle's and Apache Commons parsers. 

 Limitations: 
 
- limited to 2Gb archives at most \(and the size of an uncompressed entry may not exceed [#ENTRY_MAXSIZE](#ENTRY_MAXSIZE) bytes\) 
- zip64 is not supported 
- uncommon flags are not supported 
- non\-standard attributes are disregarded 
- the only compression scheme supported is DEFLATE

## Constructor: ZipFailSafeReader
- parameter: `file`, type: `java.io.File`

Description: Construct with all optional settings set to false.
parameter: file: input file
throws: if the archive cannot be opened or parsed

## Constructor: ZipFailSafeReader
- parameter: `channel`, type: `java.nio.channels.SeekableByteChannel`

Description: Construct with all optional settings set to false.
parameter: channel: input \(closed when the client invokes [#close()](#close())\)
throws: if the archive cannot be parsed

## Constructor: ZipFailSafeReader
- parameter: `file`, type: `java.io.File`
- parameter: `treatUnsupportedCompressionAsMethod`, type: `int`
- parameter: `ignoreEncryption`, type: `boolean`
- parameter: `recoveryMode`, type: `boolean`
- parameter: `doNotParseEntries`, type: `boolean`

Description: Construct a zip parser.
parameter: file: input file
parameter: treatUnsupportedCompressionAsMethod: optional \(use \-1 to fail when an unsupported            compression method is encountered\); else, a compression method id
parameter: ignoreEncryption: true to read encrypted entries as if they were not encrypted
parameter: recoveryMode: optional; if true, the reader will attempt to recover zip entries of            truncated files, including those with incomplete Central Directory
parameter: doNotParseEntries: optional; if true, the zip entries will not be pre\-emptively parsed,            and it will be up to the user to trigger parsing through enumeration, via            [#enumerateEntries()](#enumerateEntries()) \(this will result in faster opening of large archives\)
throws: if the archive cannot be opened or parsed

## Constructor: ZipFailSafeReader
- parameter: `channel`, type: `java.nio.channels.SeekableByteChannel`
- parameter: `treatUnsupportedCompressionAsMethod`, type: `int`
- parameter: `ignoreEncryption`, type: `boolean`
- parameter: `recoveryMode`, type: `boolean`
- parameter: `doNotParseEntries`, type: `boolean`

Description: Construct a zip parser.
parameter: channel: input \(closed when the client invokes [#close()](#close())\)
parameter: treatUnsupportedCompressionAsMethod: optional \(use \-1 to fail when an unsupported            compression method is encountered\); else, a compression method id
parameter: ignoreEncryption: true to read encrypted entries as if they were not encrypted
parameter: recoveryMode: optional; if true, the reader will attempt to recover zip entries of            truncated files, including those with incomplete Central Directory
parameter: doNotParseEntries: optional; if true, the zip entries will not be pre\-emptively parsed,            and it will be up to the user to trigger parsing through enumeration, via            [#enumerateEntries()](#enumerateEntries()) \(this will result in faster opening of large archives\)
throws: if the archive cannot be parsed

## Static Field: DEFLATED
Type: `int`

Constant value: `8`
Description: Zip compression method identifier for deflated entries.

## Static Field: ENTRY_MAXSIZE
Type: `int`

Constant value: `1073741824`
Description: Maximum supported uncompressed size for a single entry.

## Static Field: EOCD_MINSIZE
Type: `int`

Constant value: `22`

## Static Field: STORED
Type: `int`

Constant value: `0`
Description: Zip compression method identifier for stored entries.

## Method: close


## Method: enumerateEntries
- return type: `java.lang.Iterable<com.pnfsoftware.jeb.util.encoding.zip.fsr.ZipEntry>`

Description: Get the iterable to parse and enumerate over the zip entries. This method should be called once, and once only, if the object was constructed with `doNotParseEntries=true`. Any [IOException](IOException) raised will be wrapped in a [RuntimeException](RuntimeException).
return: the iterable that will iterate and parse the zip entries

## Method: getEntries
- return type: `java.util.List<com.pnfsoftware.jeb.util.encoding.zip.fsr.ZipEntry>`

Description: Retrieve a read\-only list of the current entries. 

 This method may be called even if not all entries were enumerated \(incomplete parsing\). if so, it will return an incomplete list.
return: read\-only view of the parsed entries

## Method: getEntry
- parameter: `filename`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.util.encoding.zip.fsr.ZipEntry`

Description: Retrieve an entry by name. 

 This method may be called even if not all entries were enumerated \(incomplete parsing\). It will fail if the entry has not been parsed yet.
parameter: filename: entry file name
return: matching entry, or null

## Method: getNumberOfEntries
- return type: `int`


## Method: getOffsetAppendedData
- return type: `int`


## Method: getOffsetFirstEntry
- return type: `int`


## Method: hasAppendedData
- return type: `boolean`


## Method: hasEntry
- parameter: `filename`, type: `java.lang.String`
- return type: `boolean`

Description: Determine whether an entry exists. 

 This method may be called even if not all entries were enumerated \(incomplete parsing\). It will fail if the entry has not been parsed yet.
parameter: filename: entry file name
return: true if the entry has already been parsed

## Method: hasPrependedData
- return type: `boolean`


## Method: isClosed
- return type: `boolean`


## Method: isTruncated
- return type: `boolean`


## Method: readData
- parameter: `filename`, type: `java.lang.String`
- return type: `com.pnfsoftware.jeb.util.encoding.zip.fsr.ZipData`

Description: Read an entry's data and provide the decompressed bytes. 

 This method may be called even if not all entries were enumerated \(incomplete parsing\). It will fail if the entry has not been parsed yet.
parameter: filename: entry file name
return: decompressed entry data and optional read exception
throws: if the entry does not exist or cannot be read

## Method: readData
- parameter: `e`, type: `com.pnfsoftware.jeb.util.encoding.zip.fsr.ZipEntry`
- return type: `com.pnfsoftware.jeb.util.encoding.zip.fsr.ZipData`

Description: Read an entry's data and provide the decompressed bytes. 

 This method may be called even if not all entries were enumerated \(incomplete parsing\). It will fail if the entry has not been parsed yet.
parameter: e: entry descriptor
return: decompressed entry data and optional read exception
throws: if the entry cannot be read

## Method: toString
- return type: `java.lang.String`


