public class SeekableStreamResource extends InputStreamResource
BundleResource backed by a SeekableStream.| Constructor and Description |
|---|
SeekableStreamResource(SeekableStream seekableStream,
java.lang.String displayName,
java.lang.String contentType)
Create a
BundleResource backed by an SeekableStream, specifying a display name and
content type. |
SeekableStreamResource(SeekableStream seekableStream,
java.lang.String displayName,
java.lang.String contentType,
java.lang.String format)
Create a
BundleResource backed by an SeekableStream, specifying a display name, content
type and format. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o) |
java.util.Optional<java.io.InputStream> |
getInputStream()
Get the
SeekableStream managed by this resource as an InputStream. |
java.util.Optional<SeekableStream> |
getSeekableStream()
Get a
SeekableStream for this resource, or Optional.empty. |
SignatureStream |
getSignatureStream(int signatureProbeLength)
Get a
SignatureStream for this resource. |
int |
hashCode() |
boolean |
hasInputType()
Return true if is this resource is backed by a type that can be used for input.
|
boolean |
hasSeekableStream()
Returns true if this resource can be rendered as a
SeekableStream. |
java.lang.String |
toString() |
getContentType, getDisplayName, getFileFormat, getIOPath, getOutputStream, hasOutputTypepublic SeekableStreamResource(SeekableStream seekableStream, java.lang.String displayName, java.lang.String contentType)
BundleResource backed by an SeekableStream, specifying a display name and
content type.seekableStream - The SeekableStream to use for this resource. May not be null.displayName - The display name for this resource. May not be null or 0-length.contentType - The content type for this resource. May not be null or 0-length.public SeekableStreamResource(SeekableStream seekableStream, java.lang.String displayName, java.lang.String contentType, java.lang.String format)
BundleResource backed by an SeekableStream, specifying a display name, content
type and format.seekableStream - The SeekableStream to use for this resource. May not be null.displayName - The display name for this resource. May not be null or 0-length.contentType - The content type for this resource. May not be null or 0-length.format - The format for this resource. May not be null or 0-length.public java.util.Optional<java.io.InputStream> getInputStream()
SeekableStream managed by this resource as an InputStream. Does not
alter or reset the underlying stream.getInputStream in interface BundleResourcegetInputStream in class InputStreamResourcepublic java.util.Optional<SeekableStream> getSeekableStream()
BundleResourceSeekableStream for this resource, or Optional.empty.getSeekableStream in interface BundleResourcegetSeekableStream in class BundleResourceBaseSeekableStream for this resource, or Optional.empty if this is not an input
type (see BundleResource.hasInputType()), or is an input type for which no SeekableStream
can be obtained (see BundleResource.hasSeekableStream()).public SignatureStream getSignatureStream(int signatureProbeLength)
SignatureStream for this resource.
This method requires access to the first signatureProbeLength bytes of the underlying
resource. BundleResource implementations that are backed by raw streams that can only be consumed
once, such as InputStreamResource, may consume and buffer a portion of the underlying resource's
stream in order to allow subsequent callers of the BundleResource.getInputStream()) method to be presented with
the entire stream, including the signature. Calls to this method may have the side effect of changing
or resetting the current position of the underlying stream; serial calls to
BundleResource.getSignatureStream(int) on the same object are not necessarily idempotent; and implementations
are free to throw to prevent serial calls to this method.getSignatureStream in interface BundleResourcegetSignatureStream in class InputStreamResourcesignatureProbeLength - the number of bytes of the underlying resource to include in the
SignatureStream stream. signatureProbeLength should be
expressed in "compressed(/encrypted)" space rather than "plaintext" space.
For example, a file format signature may consist of n bytes of ASCII,
but for formats that use compressed streams, the codec may need access to an
entire compressed block in order to inspect those n bytes. signatureProbeLength should use the compressed block size, in order to ensure
that the SignatureStream contains a semantically meaningful fragment
of the underlying input.public boolean hasInputType()
BundleResourceInputStreamResource, can be used for input but not for output (see
BundleResource.hasOutputType(). Others, such as OutputStreamResource, can be used for output but not
for input. Some resource types may be suitable for both (for example see IOPathResource).
The determination is based only on the type of the resource, and does not imply a guarantee about whether the resource type is actually readable.
hasInputType in interface BundleResourcehasInputType in class InputStreamResourcepublic boolean hasSeekableStream()
BundleResourceSeekableStream.hasSeekableStream in interface BundleResourcehasSeekableStream in class BundleResourceBaseSeekableStream (see BundleResource.getSeekableStream())public boolean equals(java.lang.Object o)
equals in class InputStreamResourcepublic int hashCode()
hashCode in class InputStreamResourcepublic java.lang.String toString()
toString in class InputStreamResource