public interface BundleResource
Bundle
.Modifier and Type | Method and Description |
---|---|
java.lang.String |
getContentType()
Get the content type for this resource.
|
java.lang.String |
getDisplayName()
Get the display name for this resource.
|
java.util.Optional<java.lang.String> |
getFileFormat()
Get the file format for this resource.
|
java.util.Optional<java.io.InputStream> |
getInputStream()
Get an
InputStream for this resource, or Optional.empty. |
java.util.Optional<IOPath> |
getIOPath()
Get the
IOPath backing this resource, or Optional.empty. |
java.util.Optional<java.io.OutputStream> |
getOutputStream()
Get an
OutputStream for this resource, or Optional.empty. |
java.util.Optional<SeekableStream> |
getSeekableStream()
Get a
SeekableStream for this resource, or Optional.empty. |
SignatureStream |
getSignatureStream(int signatureProbeLength)
Get a
SignatureStream for this resource. |
boolean |
hasInputType()
Return true if is this resource is backed by a type that can be used for input.
|
boolean |
hasOutputType()
Return true if this resource is backed by a type that can be used for output.
|
boolean |
hasSeekableStream()
Returns true if this resource can be rendered as a
SeekableStream . |
java.lang.String getDisplayName()
java.lang.String getContentType()
java.util.Optional<java.lang.String> getFileFormat()
java.util.Optional<IOPath> getIOPath()
IOPath
backing this resource, or Optional.empty.java.util.Optional<java.io.InputStream> getInputStream()
InputStream
for this resource, or Optional.empty.InputStream
for this resource, or Optional.empty if hasInputType()
is false for this resource.
The stream returned by this method may be buffered or use read-ahead, which may not be
suitable for applications such as index creation that need control over the position of the
underlying stream.java.util.Optional<java.io.OutputStream> getOutputStream()
OutputStream
for this resource, or Optional.empty.OutputStream
for this resource, or Optional.empty if hasOutputType()
is false for this resourcejava.util.Optional<SeekableStream> getSeekableStream()
SeekableStream
for this resource, or Optional.empty.SeekableStream
for this resource, or Optional.empty if this is not an input
type (see hasInputType()
), or is an input type for which no SeekableStream
can be obtained (see hasSeekableStream()
).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 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
getSignatureStream(int)
on the same object are not necessarily idempotent; and implementations
are free to throw to prevent serial calls to this method.signatureProbeLength
- 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.SignatureStream
over the first signatureProbeLength
bytes of this
resource, for use with signature probing for codec resolution. Only applicable to resources for
which hasInputType()
is true.java.lang.IllegalArgumentException
- if this method has previously been called on this resource, or if
hasInputType()
is false for this resourceboolean hasInputType()
InputStreamResource
, can be used for input but not for output (see
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.
boolean hasOutputType()
InputStreamResource
, can be used for input but not for output (see
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 is actually writeable.
boolean hasSeekableStream()
SeekableStream
.SeekableStream
(see getSeekableStream()
)