org.restlet.engine.local

## Class ZipEntryRepresentation

- java.lang.Object
- - org.restlet.representation.Variant
  - - org.restlet.representation.RepresentationInfo
    - - org.restlet.representation.Representation
      - - org.restlet.representation.StreamRepresentation
        - - org.restlet.engine.local.ZipEntryRepresentation

    public class ZipEntryRepresentation
    extends StreamRepresentation

An entry in a Zip/JAR file. It is very important `release()` is called to close the underlying Zip file.

Author:
  Remi Dewitte <remi@gide.net>

### Field Summary

Fields
`protected java.util.zip.ZipEntry` `entry` The Zip entry.
`protected java.util.zip.ZipFile` `zipFile` The Zip file.

### Fields inherited from class org.restlet.representation.Representation

`UNKNOWN_SIZE`

### Constructor Summary

Constructors
Constructor and Description
`ZipEntryRepresentation(MediaType mediaType, java.util.zip.ZipFile zipFile, java.util.zip.ZipEntry entry)` Constructor.

### Method Summary

Methods
`java.io.InputStream` `getStream()` Returns a stream with the representation's content.
`void` `release()` Releases the representation and all associated objects like streams, channels or files which are used to produce its content, transient or not.
`void` `write(java.io.OutputStream outputStream)` Writes the representation to a byte stream.

### Methods inherited from class org.restlet.representation.StreamRepresentation

`getChannel, getReader, write, write`

### Methods inherited from class org.restlet.representation.Representation

`checkDigest, checkDigest, computeDigest, createEmpty, exhaust, getAvailableSize, getDigest, getDisposition, getDownloadName, getExpirationDate, getRange, getSize, getText, isAvailable, isDownloadable, isTransient, setAvailable, setDigest, setDisposition, setDownloadable, setDownloadName, setExpirationDate, setRange, setSize, setTransient`

### Methods inherited from class org.restlet.representation.RepresentationInfo

`getModificationDate, getTag, setModificationDate, setTag`

### Methods inherited from class org.restlet.representation.Variant

`createClientInfo, equals, getCharacterSet, getEncodings, getIdentifier, getLanguages, getLocationRef, getMediaType, includes, isCompatible, setCharacterSet, setEncodings, setIdentifier, setIdentifier, setLanguages, setLocationRef, setLocationRef, setMediaType, toString`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### zipFile

    protected final java.util.zip.ZipFile zipFile

The Zip file.

#### entry

    protected final java.util.zip.ZipEntry entry

The Zip entry.

### Constructor Detail

#### ZipEntryRepresentation

    public ZipEntryRepresentation(MediaType mediaType,
                          java.util.zip.ZipFile zipFile,
                          java.util.zip.ZipEntry entry)

Constructor.

Parameters:
  `mediaType` - The entry media type.
  `zipFile` - The parent Zip archive file.
  `entry` - The Zip entry.

### Method Detail

#### release

    public void release()

Description copied from class: `Representation`
Releases the representation and all associated objects like streams, channels or files which are used to produce its content, transient or not. This method must be systematically called when the representation is no longer intended to be used. The framework automatically calls back this method via its connectors on the server-side when sending responses with an entity and on the client-side when sending a request with an entity. By default, it calls the `Representation.setAvailable(boolean)` method with "false" as a value.
Note that for transient socket-bound representations, calling this method after consuming the whole content shouldn't prevent the reuse of underlying socket via persistent connections for example. However, if the content hasn't been read, or has been partially read, the impact should be to discard the remaining content and to close the underlying connections.
Therefore, if you are not interested in the content, or in the remaining content, you should first call the `Representation.exhaust()` method or if this could be too costly, you should instead explicitly abort the parent request and the underlying connections using the `Request#abort()` method or a shortcut one like `ServerResource#abort()` or `Response#abort()`.

Overrides:
  `release` in class `Representation`

#### getStream

    public java.io.InputStream getStream()
                                  throws java.io.IOException

Description copied from class: `Representation`
Returns a stream with the representation's content. This method is ensured to return a fresh stream for each invocation unless it is a transient representation, in which case null is returned.

Specified by:
  `getStream` in class `Representation`
Returns:
  A stream with the representation's content.
Throws:
  `java.io.IOException`

#### write

    public void write(java.io.OutputStream outputStream)
               throws java.io.IOException

Description copied from class: `Representation`
Writes the representation to a byte stream. This method is ensured to write the full content for each invocation unless it is a transient representation, in which case an exception is thrown.
Note that the class implementing this method shouldn't flush or close the given `OutputStream` after writing to it as this will be handled by the Restlet connectors automatically.

Specified by:
  `write` in class `Representation`
Parameters:
  `outputStream` - The output stream.
Throws:
  `java.io.IOException`