Package 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
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
FieldsModifier and TypeFieldDescriptionprotected final ZipEntryThe Zip entry.protected final ZipFileThe Zip file.Fields inherited from class org.restlet.representation.Representation
UNKNOWN_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionZipEntryRepresentation(MediaType mediaType, ZipFile zipFile, ZipEntry entry, int timeToLive) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionReturns a stream with the representation's content.voidrelease()Releases the representation and all associated objects like streams, channels or files which are used to produce its content, transient or not.voidwrite(OutputStream outputStream) Writes the representation to a byte stream.Methods inherited from class org.restlet.representation.StreamRepresentation
getReader, writeMethods inherited from class org.restlet.representation.Representation
append, exhaust, getAvailableSize, getDigest, getDisposition, getExpirationDate, getRange, getSize, getText, hasKnownSize, isAvailable, isEmpty, isTransient, setAvailable, setDigest, setDisposition, setExpirationDate, setRange, setSize, setTransientMethods inherited from class org.restlet.representation.RepresentationInfo
getModificationDate, getTag, setModificationDate, setTagMethods inherited from class org.restlet.representation.Variant
createClientInfo, equals, getCharacterSet, getEncodings, getLanguages, getLocationRef, getMediaType, hashCode, includes, isCompatible, setCharacterSet, setEncodings, setLanguages, setLocationRef, setLocationRef, setMediaType, toString
-
Field Details
-
entry
The Zip entry. -
zipFile
The Zip file.
-
-
Constructor Details
-
ZipEntryRepresentation
Constructor.- Parameters:
mediaType- The entry media type.zipFile- The parent Zip archive file.entry- The Zip entry.timeToLive- The time to live before it expires (in seconds).
-
-
Method Details
-
getStream
Description copied from class:RepresentationReturns 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:
getStreamin classRepresentation- Returns:
- A stream with the representation's content.
- Throws:
IOException
-
release
public void release()Description copied from class:RepresentationReleases 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 theRepresentation.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 theRepresentation.exhaust()method or if this could be too costly, you should instead explicitly abort the parent request and the underlying connections using theRequest.abort()method or a shortcut one likeServerResource.abort()orResponse.abort().- Overrides:
releasein classRepresentation
-
write
Description copied from class:RepresentationWrites 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 givenOutputStreamafter writing to it as this will be handled by the Restlet connectors automatically.- Specified by:
writein classRepresentation- Parameters:
outputStream- The output stream.- Throws:
IOException
-